Let me start by saying that I am very new to the MSP430, and microcontrollers in general. I just decided to jump in and try to swim. I'm still in the stage of trying assemble a large number of chunks of information into something coherent in my mind. Anyway, I'm trying to set up a MSP430G2231 to read a moisture sensor every 15 minutes or so, well actually any amount of time around 5 minutes or longer would be fine, and I can't seem to get everything slowed so the timer takes that long to count.
My thought process is such...
VLO =12,000Hz (Give or take, I read about how its not very accurate)
Use VLO to source ACLK.
Then divide ACLK by 8 = 1500Hz
Use ACLK to clock Timer A.
Divide source clock on Timer A by 8 = 187.5Hz
Seeing as how Timer A is 16 bits it can count to 65536, and if you take 65536/187.5 you get about 350 seconds or about 5.8 minutes for the timer to count all the way up. The problem I am having is that currently I have my code set up to blink LED's and I'm only getting about a minute of delay between LED changes. I really don't know what else to try.
My code is as follows. I haven't done anything with the moisture sensor yet. My first step is just trying to get everything slowed down.
#include <intrinsics.h>
//#include <msp430g2231.h>
#include <io430g2231.h>
#define red_LED BIT0
#define grn_LED BIT6
void main(void)
{
//configure clocks
BCSCTL3 |= LFXT1S_2; // LFXT1 = VLO
BCSCTL2 |= SELM_3 + SELS; // SMCLK = MCLK = VLO = 12Khz
IFG1 &= ~OFIFG; // Clear OSCFault flag
__bis_SR_register(SCG1 + SCG0); // Stop DCO
BCSCTL1 |= DIVA_3 + LFXT1S0; //Divide ACLK by 8
WDTCTL = WDTPW | WDTHOLD;
P1OUT = ~red_LED;
P1DIR = red_LED | grn_LED;
TACTL = MC_2 | ID_3 | TASSEL_1 | TACLR; //Configure Timer A
for (;;) {
while (TACTL_bit.TAIFG == 0) {
}
TACTL_bit.TAIFG = 0;
P1OUT ^= red_LED | grn_LED;
}
}