Hello guys,
I have a project based on MSP430I2021 and it has no external clock source, crystal or oscilator, so I need to use DCO.
I am using CCS v7.
Also I want to use Timer module to occur 1ms interrupt. My code is below;
#include <msp430.h>
void board_init(void);
void initTimer_A(void);
void Blynk();
volatile unsigned int TimerCnt;
void main(void) {
board_init();
initTimer_A();
_enable_interrupt();
for(;;) {
Blynk();
}
}
void board_init()
{
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
/* DCO = 16.384MHz
* MCLK = 16.384MHz
* SMCLK = 1.024MHz
* ACLK = 32KHz
* */
CSCTL1 = (DIVM0 | DIVS2);
P2DIR |= BIT0;
}
void Blynk()
{
if (TimerCnt == 1000)
{
P2OUT ^= BIT0;
TimerCnt = 0;
}
}
void initTimer_A(void)
{
/* Set 1ms Timer Interrupt */
TACCTL0 &= ~CCIE;
TACCR0 = 0; //Initially, Stop the Timer
TACCTL0 = CCIE;
TACCR0 = 1000-1;
TACTL = TASSEL_2 + ID_0 + MC_1; //Select SMCLK, SMCLK/1, Up Mode
}
//Timer ISR
#pragma vector = TIMER0_A0_VECTOR
__interrupt void Timer_A_CCR0_ISR(void)
{
TimerCnt++;
}
When this code runs, LED blinks faster than 1 second. I decided that DCO calibration is wrong but I don't understand how can I calibrate DCO.
I find some documents like slaa336, but they are writen for msp430g2553 or f series. 430i2021 has no DCOCTL or BCSCTL registers.
I found code below but I don't understand what is "TLV_address_for_parse"?
/ * Calibrate REF * /
REFCAL1 = * (TLV_address_for_parse + TLV_CAL_REFCAL1);
REFCAL0 = * (TLV_address_for_parse + TLV_CAL_REFCAL0);
/ * Calibrate DCO * /
CSIRFCAL = * (TLV_address_for_parse + TLV_CAL_CSIRFCAL);
CSIRTCAL = * (TLV_address_for_parse + TLV_CAL_CSIRTCAL);
CSERFCAL = * (TLV_address_for_parse + TLV_CAL_CSERFCAL);
CSERTCAL = * (TLV_address_for_parse + TLV_CAL_CSERTCAL);
Could you help me how can I calibrate DCO?
Thanks