Hello my name is Jose Miguel, I write from spain and I’m having some problems to set the frequency of my msp430. (f2013, the one with de detachable board). I want the signal to change every 10ms and this is what I think:
timer interrupts: Ti = CCR0 / f
The thing is that actually period is: (T) 7 interrupciones del timer,
And: T = Ti * 7; luego, I know T=10 ms and I think f=16MHz (?) so CCR0 = 22857
Well, it seems that CCR0 doesn’t work, because it doesn’t matter the value it’s ascribed and it’s in the for loop when I have to ascribe one or another value to i, but I don’t know exactly how long does it take for the loop to increase the i.
This is the code and I hope someone help me.
Thanks all.
#include <msp430x20x3.h>
void main(void)
{
WDTCTL = WDTPW + WDTHOLD;
P1DIR |= 0xFF;
CCTL0 = CCIE;
CCR0 = 22857;
TACTL = TASSEL_2 + MC_1;
BCSCTL2 |= SELM_3 + DIVM_3;
_BIS_SR(LPM0_bits + GIE);
}
unsigned int n=7;
char s = {0x01, 0x42, 0x81, 0x48, 0x81, 0x42, 0x01};
#pragma vector = TIMERA0_VECTOR
__interrupt void Timer_A (void)
{
volatile unsigned int i;
volatile unsigned int j;
volatile unsigned int k;
for (i=0; i<n; i++)
{
P1OUT = s*;*
for (k=0; j<100; j++) //100 times 10ms (should be 1s)
{
for (j=0; j<22857; j++); //software delay (should be 10ms)
}
}