I was looking into the code that is provided to create an interrupt based on time. I have a MSP430FG6418 chip on an experimenter's board.
This is the code im trying to understand as of right now:
---------------------------------------------------------
#include <msp430xG46x.h>
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
FLL_CTL0 |= XCAP18PF; // Set load cap for 32k xtal
P5DIR |= 0x02; // Set P5.1 as output
BTCTL = BTDIV + BT_fCLK2_DIV16; // ACLK/(256*16)
IE2 |= BTIE; // Enable BT interrupt
_BIS_SR(LPM3_bits + GIE); // Enter LPM3, enable interrupts
}
// Basic Timer Interrupt Service Routine
#pragma vector=BASICTIMER_VECTOR
__interrupt void basic_timer_ISR(void)
{
P5OUT ^= 0x02; // Toggle P5.1
}
---------------------------------------------------------
The thing is, i really dont understand how to set the interrupt time itself. My guess is:
BTCTL = BTDIV + BT_fCLK2_DIV16;
But i really dont know what BTDIV or BT_fCLK2_DIV16 are. I tried just putting numbers and i managed to changed the frequency of the toggling by directly assigning a value like this:
BTCTL = 300
But I still dont understand how it works, and when i use any value below 300 or above 3000 the led will not turn on at all...
Im new to this, and i know its something simple, but I really cannot understand this. All I want is a simple way to say "every x seconds, cause interrupt"
thanks for any help yall can provide