xv4y 46 Posted May 20, 2012 Share Posted May 20, 2012 Hi, What are the default clock settings (BCSCTLx registers) for an MSP430G2553 in Energia ? I have my beacon running but the clock is slowly drifting (30 seconds in 12 hours) and the beacon sequence is not synchronized anymore so the receivers are not decoding it. I think this is because I have interrupts call too often (each 1/256th of second) and the MCU too slow, but I am not sure... Thanks, Yan. Quote Link to post Share on other sites
CorB 64 Posted May 20, 2012 Share Posted May 20, 2012 Hi, You might have a look into this: http://electronics.stackexchange.com/qu ... ld-weather The DCO is rather sensitive for temperature changes. cheers CorB xv4y 1 Quote Link to post Share on other sites
Rickta59 589 Posted May 20, 2012 Share Posted May 20, 2012 What are the default clock settings (BCSCTLx registers) for an MSP430G2553 in Energia ? It defaults to 16MHz for the msp430g2553. The value of the define 'F_CPU' is determined by which board is selected in the Energia IDE. This value is stored in the boards.txt file and each board can have its own .f_cpu. value. Here is the default entry for the msp430g2553: lpmsp430g2553.build.f_cpu=16000000L The core code uses the F_CPU value to decide at compile time which precalibrated setting to use for the BSCCTL1 and DCOCTL registers. void initClocks(void) { #if defined(CALBC1_16MHZ_) && F_CPU >= 16000000L BCSCTL1 = CALBC1_16MHZ; DCOCTL = CALDCO_16MHZ; #elif defined(CALBC1_12MHZ_) && (F_CPU >= 12000000L) BCSCTL1 = CALBC1_12MHZ; DCOCTL = CALDCO_12MHZ; #elif defined(CALBC1_8MHZ_) && (F_CPU >= 8000000L) BCSCTL1 = CALBC1_8MHZ; DCOCTL = CALDCO_8MHZ; #elif defined(CALBC1_1MHZ_) && (F_CPU >= 1000000L) BCSCTL1 = CALBC1_1MHZ; DCOCTL = CALDCO_1MHZ; #else #warning No Suitable Frequency found! #endif /* SMCLK = DCO / DIVS = nMHz */ BCSCTL2 &= ~(DIVS_0); /* ACLK = VLO = ~ 12 KHz */ BCSCTL3 |= LFXT1S_2; } -rick xv4y 1 Quote Link to post Share on other sites
xv4y 46 Posted May 20, 2012 Author Share Posted May 20, 2012 Hi, Thanks for your replies. CorB, I forgot to tell I hooked up a 32KHz Xtal to the LaunchPad external clock pads. I am rather used to solder SMD but this one was not the easiest to solder since the board is already populated... Rick, yes I saw the second code you give but missed the board.txt... I think my problem is somewhere else... the drift is worst than I thought! I also use the delay() function which make usage of the WatchDogTimer. I will try to use only my own "delay" using the RTC lib. Regards, Yan. Quote Link to post Share on other sites
energia 485 Posted May 21, 2012 Share Posted May 21, 2012 Note that Energia uses the internal VLO for ACLK and not the 32KHz XTAL. See hardware/msp430/cores/msp430/wiring.c /* ACLK = VLO = ~ 12 KHz */ BCSCTL3 |= LFXT1S_2; This makes me realize that there is there is no way for the user to set the ACLK to the external XTAL using a higher level API. -robertinant xv4y 1 Quote Link to post Share on other sites
xv4y 46 Posted May 21, 2012 Author Share Posted May 21, 2012 Note that Energia uses the internal VLO for ACLK and not the 32KHz XTAL. See hardware/msp430/cores/msp430/wiring.c-robertinant Hi Robert, Does this mean that I am unable to set ACLK so it uses the XTAL ? The results I have are in line with my expectations... I think I found my error but I have to run a long test to check the RTC drift. I set CCR0 to 128 (as I want to mesure 128 periods of the xtal oscillator) but I read that CCR0 counts N+1 not N. No it is to 128-1 and hover 10 minutes the clock is ok. TI documentation is not really precise about this, and the examples not all good. Sometime you find CRR0 = N-1 but nobody explains why... Yan. Quote Link to post Share on other sites
oPossum 1,083 Posted May 21, 2012 Share Posted May 21, 2012 For 128 cycles, you have to set CCR to 127. This is explained in SLAU144 section 12.2.3.1: "The number of timer counts in the period is TACCR0+1" I think you can set the ACLK source to whatever you want after Energia has done it's initialization. Quote Link to post Share on other sites
energia 485 Posted May 21, 2012 Share Posted May 21, 2012 Hi Yan, You can set XTAL as ACLK source and can do so by setting BCSCTL3 in wiring.c. But I am sure you already figured that one out :-) It would be nice if this was possible using a higher level API. Anyways, happy you got it to work! -robertinant Quote Link to post Share on other sites
xv4y 46 Posted May 22, 2012 Author Share Posted May 22, 2012 Hi, Now my beacon is working and signals have been received by another station. The only problem is that the output power is a bit low (100mW) and propagation conditions not great at this season for the band I choose (30 meters band is more a winter band), but this RF related, not MSP430 related. The clock drift is around 1 second less for 4 hours but I have to measure it. It seems in line with the 20ppm rating of the xtal. I will have to correct the drift either by software (adding a leap second), by changing the XCAP_x value in BSCTL3 or by hardware pulling a little bit the xtal (adding an adjustable cap)... Perhaps I can read one pin and depending off the presence of a jumper, set XCAP_x value... Thanks for your help. Yan. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.