Crane
February 15, 2008, 11:33pm
1
I am using an Olimex board with a MSP430f169 device. I plugged in an 8MHz crystal from SparkFun and soldered in two 20pf caps. I have done this with the MSP430f1232 Olimex board and it worked fine.
On this board, however, it hangs up in the test loop. I copied the code from the …169 user guide. If I enable the ‘skip option’ it runs the
DCO at a little above 8MHz.
The code is:
RESET:
StopWDT mov.w #WDTPW+WDTHOLD, &WDTCTL ; Stop watchdog
mov.w #02FEh, SP ; Initialize stackpointer
call #Clear_Ram
mov.w #0200h, R4 ; Initialize RAM Pointer
BIC #OSCOFF, SR ; Turn on oscillator
mov.b #000h, DCOCTL
bis.b #XTS, &BCSCTL1
mov.b #088h, &BCSCTL2
;jmp skip ; Option to skip external xtal
;Select xtal osc:
bic #OSCOFF, SR ; Turn on Osc
BIS.B #XTS, &BCSCTL1 ; HF MODE
InitL1: bic.b #OFIFG, &IFG1 ; Clear OFIFG
MOV #0FFh, R15 ; Delay
InitL2: dec R15 ;
jnz InitL2
bit.b #OFIFG, &IFG1 ; Re-test OFIFG
jnz InitL1 ; Repeat test if needed
bis.b #SELM1+SELM0, &BCSCTL2 ; Select LFXT1CLK
Skip:
Any thoughts?
Tom
OldCow
February 16, 2008, 3:41am
2
Your code is for a “high frequency” crystal connected to the XTIN and XTOUT pins. Is that where your 8MHz crystal connected?
You may have connected the crystal to XT2IN and XT2OUT pins instead. If that is the case, you have to either change you code, or re-solder the crystal.
Crane
February 16, 2008, 4:10pm
3
I see the mistake. So, I reread the User Guide and changed the code to:
;Select xtal osc:
bic.b #XT2OFF, &BCSCTL1 ; Turn on Osc
BIS.B #XTS, &BCSCTL1 ; HF MODE
InitL1: bic.b #OFIFG, &IFG1 ; Clear OFIFG
MOV #0FFFh, R15 ; Delay
InitL2: dec R15 ;
jnz InitL2
bit.b #OFIFG, &IFG1 ; Re-test OFIFG
jnz InitL1 ; Repeat test if needed
mov.b #088h, &BCSCTL2 ; Select XT2
It still hangs up in the test loop. If I comment out the loop, it runs. I think it has to be running on the Xt2 osc because of the mov.b #088h , &BCSCTL2 statement, but not sure.
Don’t think it is working yet.
Tom
Hi Crane
I suggest
Go to www.ti.com/msp430
next Code Examples Download MSP430x1
MSP430x2
MSP430x4
SLAU049 User’s Guide
SLAU144
SLAU056
Hope this will help you
OldCow
February 17, 2008, 3:42pm
5
Crane,
I agree with Ben. You misunderstood (not your fault, MSP430 documents are very confusion.)
You can use XTIN/XTOUT for either “low frequency” or “high frequency” crystal. This is controlled by the XTS bit.
You can only use XT2IN/XT2OUT for “high frequency” crystal. XT2OFF controls if it should be turned off.
Your modified code will work only if you have two “high frequency” crystals.
You do not have one at XTIN/XTOUT, thus you should delete the line:
bis.b #XTS , &BCSCTL1
Crane
February 17, 2008, 6:48pm
6
Thanks guys!
I printed the clock section and spent some time with the schematic and your comments.
This code works:
RESET:
StopWDT mov.w #WDTPW+WDTHOLD, &WDTCTL ; Stop watchdog timer
mov.w #02FEh, SP ; Initialize stackpointer
call #Clear_Ram
mov.w #0200h, R4 ; Initialize RAM Pointer
bic.b #XT2OFF, &BCSCTL1 ; Turn on Osc
bis #OSCOFF, SR ; Turn off Low Freq Osc
InitL1: xor.b #01h, P6OUT ; Toggle LED
bic.b #OFIFG, &IFG1 ; Clear OFIFG
MOV #0FFh, R15 ; Delay
InitL2: dec R15 ; Decrement delay count
jnz InitL2 ; If not 0 continue count
bit.b #OFIFG, &IFG1 ; Re-test OFIFG
jnz InitL1 ; Repeat test if needed
mov.b #088h, &BCSCTL2 ; Select XT2
Thanks again,
Tom