EasyManuals Logo

Texas Instruments MSP430 Student Guide

Texas Instruments MSP430
398 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #184 background imageLoading...
Page #184 background image
(Optional) Lab 4c Using Crystal Oscillators
(Optional) Lab 4c – Using Crystal Oscillators
1. Import lab_04a_clock_solution.
If you don’t remember how to do this, refer back to lab step 1 (on page 4-47).
2. Rename the project to lab_04c_crystals.
3. Make sure the project builds correctly.
4. Delete two files from the project:
myClocks.c
Old readme file (not required, but might make things less confusing later on)
5. Add files to project.
Add the following two files to the project:
myClocksWithCrystals.c
lab_04_crystals_readme.txt (again, not required, but helpful)
You’ll find them along the path
C:\msp430_workshop\
<target>\lab_04c_crystals\
6. Examine the new C file.
Notice the following:
We need to “start” the crystal oscillators before selecting them as a clock source.
Two different ways to “start” a crystal with and without a timeout.
If no timeout is used, then that function will continue until the oscillator is started. That
could effectively halt the program indefinitely, if there is a problem with the crystal
(say, it breaks, has a solder fault, or has fallen off the board).
A better solution might be to specify a timeout … as long as you check for the result
after the function completes. (In our example, we just used an indefinite wait loop, but
“in real life” you might choose another clock source based on a failed crystal.)
7. Build to verify the file import was OK.
8. Add the following code to the initGpio() function in main.c.
Rather than having you build and run the project only to find out it doesn’t work (like what
happened to the course author), we’ll give you a hint: connect the clock pins to the crystals.
//Connect pins to crystal in/out pins
GPIO_setAsPeripheralModuleFunctionInputPin(
GPIO_PORT_P5,
GPIO_PIN5 + // XOUT on P5.5
GPIO_PIN4 + // XIN on P5.4
GPIO_PIN3 + // XT2OUT on P5.3
GPIO_PIN2 // XT2IN on P5.2
);
By default on some MSP430 devices, such as the F5529 these pins default to GPIO
mode. Thus, we have to connect them by reprogramming the GPIO.
4 - 58 MSP430 Workshop - MSP430 Clocks & Initialization

Table of Contents

Other manuals for Texas Instruments MSP430

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Texas Instruments MSP430 and is the answer not in the manual?

Texas Instruments MSP430 Specifications

General IconGeneral
BrandTexas Instruments
ModelMSP430
CategoryMicrocontrollers
LanguageEnglish

Related product manuals