Part Number: MSP430FR5994
Other Parts Discussed in Thread: MSP-EXP430FR5994
-
Board Used: MSP-EXP430FR5994
-
Hi, I am trying to use the Timer A0 in external clock pulse counting mode. I have used the code as presented below. The code seems to work fine if I set the clock source as TIMER_A_CLOCKSOURCE_ACLK. This ensures that the timer configurations are correct.
Now I am trying to map MCU pin 3 (Port 1.2) of the MCU chip to the clock input of the Timer/Counter 0. To achieve this, I have used the function GPIO_setAsPeripheralModuleFunctionInputPin() where the last parameter I have tried all three (GPIO_PRIMARY_MODULE_FUNCTION, GPIO_SECONDARY_MODULE_FUNCTION & GPIO_TERNARY_MODULE_FUNCTION). But none of these options seems to work.
Single stepping the code in debug mode showed no change in TA0R register under TA0 in Register Watch Window. If clock source is selected as ACLK, then I am noticing gradual increase of TA0R register value in debug mode.
To send clock pulses to the MCU pin 3, I have used a jumper wire to connect the P1.2 pin in the board's header. The other end of the jumper wire I was connecting alternately to GND and 3.3V pins of the headers. Can anyone suggest whether there is anything missed out in the code? Or may be I am doing something wrong conceptually.
-
Code:
-
// Configure counter
Timer_A_initContinuousModeParam timerAContiModeCfgParams;
timerAContiModeCfgParams.clockSource = TIMER_A_CLOCKSOURCE_EXTERNAL_TXCLK;
timerAContiModeCfgParams.clockSourceDivider = TIMER_A_CLOCKSOURCE_DIVIDER_1;
timerAContiModeCfgParams.startTimer = true;
timerAContiModeCfgParams.timerClear = TIMER_A_DO_CLEAR;
timerAContiModeCfgParams.timerInterruptEnable_TAIE = TIMER_A_TAIE_INTERRUPT_DISABLE;
Timer_A_initContinuousMode(TIMER_A0_BASE,
&timerAContiModeCfgParams);
// Configure GPIO pin for external CLK input
GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P1,
GPIO_PIN2,
GPIO_TERNARY_MODULE_FUNCTION);
// Test Loop
while(1)
{
counterValue_u16 = Timer_A_getCounterValue(TIMER_A0_BASE);
if(counterValue_u16 % 2)
{
LED_RED_ON;
}
else
{
LED_RED_OFF;
}
}
-
Regards
Soumyajit