Other Parts Discussed in Thread: MSP430G2553, MSP430G2452, MSP430WARE
I have a Launchpad with MSP430G2553 chip and i'm trying to run DS18B20 sensor which needs proper timing. I spend all day to figure out why my code does not work and finally I realized it was DCO. I checked it on my oscilloscope with some simple code which I posted below:
int main( void )
{
int i;
WDTCTL = WDTPW + WDTHOLD; //Stop watchdog timer
BCSCTL1 = CALBC1_12MHZ; //Basic Clock System Control 1 = Index for BCSCTL1 Calibration Data for 1MHz
DCOCTL = CALDCO_12MHZ; //DCO Clock Frequency Control = Index for DCOCTL Calibration Data for 1MHz
BCSCTL2 = SELM_0 + DIVM_0 + DIVS_0; // DCO for Main and Subsytem CLK (w/o divider)
P1DIR |= BIT4; //Sets CLK on P1.4 for measurement
P1SEL |= BIT4;
while(1) i++; //dummy
}
Results are:
for 1MHz I got 860kHz on my oscilloscope,
for 8MHz I got 444kHz,
for 12MHz I got 227kHz,
for 16MHz I got 113kHz.
I changed my chip for MSP430G2452 and repeated measurements - I got exactly what I set, even 16MHz.
What is wrong with my MSP430G2553? How to fix it?
