Part Number:MSP430FR5739
Hi,
I try to get the Timer A working in capture mode:
#include <msp430.h>
#include <stdint.h>
/**
* main.c
*/
uint32_t count_rotate = 0;
uint16_t count_time = 0;
int main(void){
WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer
CSCTL0_H = 0xA5; // Unlock Clock Door
CSCTL1 |= DCORSEL + DCOFSEL0 + DCOFSEL1; // DCO on 24 MHz for MSP DCORSEL = 1 , DCOFSEL = 11
CSCTL2 = SELA_0 + SELS_0 + SELM_3; // ACLK(Periph) -> XT1CLK / SMCLK(Periph) -> XT1CLK / MCLK -> DCOCLK
CSCTL3 = DIVA_0 + DIVS_0 + DIVM_0; // Div = 0 -> FULL SPEED
CSCTL4 |= XT1DRIVE_0; // Enable LOW POWER
CSCTL4 &= ~XT1OFF; // XT1 enable
P1DIR &= ~BIT0;
P1SEL0 |= BIT0; // Enable CCI1A on 1.2
P1SEL1 &= ~BIT0;
P3DIR = BIT4; // Enable LED
P3OUT ^= BIT4;
TA0CCTL1 = CM_1 + CCIS_0 + SCS + CAP + CCIE; // Capture On Rising Edge + Capture Mode + Capture Interrupt + CCI1A + Sync
TA0EX0 = TAIDEX_3; //Divide by 4 -> get 1024
TA0CTL = TASSEL_1 + MC_2 + ID__8; // ACLK(32kHz), continuous mode -> 32768 / 8 -> 4096
//TA0CTL |= TACLR; // Reset Timer
for (;;)
{
}
return 0;
}
#pragma vector = TIMER0_A0_VECTOR
__interrupt void Timer0_A0_ISR(void)
{
switch (__even_in_range(TA0IV, 0x0E)) //Check which interrupt was selected
{
case 2:{ //CCR1
P3OUT ^= BIT4;
count_rotate++;
count_time = TA0CCR1;
}
}
}
The Counter is counting up in TA0R when I watch the registers in Debug but it will not copy the value to TA0CCR1 when a raising edge is coming..
Also the CCI in TA0CCTL1 always stays on '1' independently from P1.0.
Someone see the error?
Greetings
Eric