Other Parts Discussed in Thread: MSP430WARE
I know Capture Mode is not used very much, but I am trying to configure Timer0_A5. I am also using the MSP430ware rather then the memory-mapped C macors.
I configure the Timer to run in UpMode:
Timer_A_initUpModeParam inittaram = {0};
inittaram.clockSource = TIMER_A_CLOCKSOURCE_ACLK;
inittaram.clockSourceDivider = TIMER_A_CLOCKSOURCE_DIVIDER_1;
inittaram.timerPeriod = 0x08FF;
inittaram.timerInterruptEnable_TAIE = TIMER_A_TAIE_INTERRUPT_ENABLE;
inittaram.captureCompareInterruptEnable_CCR0_CCIE = TIMER_A_CCIE_CCR0_INTERRUPT_ENABLE;
inittaram.timerClear = TIMER_A_DO_CLEAR;
inittaram.startTimer = false;
Timer_A_initUpMode(TIMER_A0_BASE, &inittaram);
This code works great. I get and detect both interrupts for TAR=0 and for TAR=CCR0. My problem comes when I try to use CCR1 to perform a capture:
Timer_A_initCaptureModeParam inittaram = {
.captureRegister = TIMER_A_CAPTURECOMPARE_REGISTER_1,
.captureMode = TIMER_A_CAPTUREMODE_RISING_EDGE,
.captureInputSelect = TIMER_A_CAPTURE_INPUTSELECT_GND, // Switch to Vcc should cause interrupt
.synchronizeCaptureSource = TIMER_A_CAPTURE_ASYNCHRONOUS,
.captureInterruptEnable = TIMER_A_CAPTURECOMPARE_INTERRUPT_ENABLE,
.captureOutputMode = TIMER_A_OUTPUTMODE_TOGGLE,
};
Timer_A_initCaptureMode(TIMER_A0_BASE, &inittaram);
In my main loop, when I toggle TA0CCTL1 ^= CCIS_1; I get the Capture Interrupt. However, the TA0.1 pin (P1.2), doesn't seem to toggle at the correct moment.
I think my understanding of the outputMode for a capture timer is unclear. I expect the TA0.1 pin to toggle every time I toggle the CCIS_1 bit.
It may help if I show you my main loop:
while (1 /* data != 0x00 */)
{
xferData(&data, 1);
data--;
__delay_cycles(100);
/* This causes an edge on the input of CCR1 which is configured as a */
/* Capture Timer. This generates an INT. */
if (data == 0x00)
{
TA0CCTL1 ^= CCIS_1;
}
}
The data that is being transferred is a single byte via SPI. So I would expect to see my TA0.1 pin toggle at the same time my SPI data is 0x00. It looks like it is toggling more with TAR=CCR0
Can someone explain how the TA0.1 signal works when configuring CCR1 isn Capture Mode?
Thanks,
Jim