Hi community member,
Please provide your advice in order to resolve the following phenomenon.
[Phenomenon]
When added one line as below in the interrupt routine of Time A, not outputted the expected frequency from the port 4.5 which controlled by Timer B interrupt.
[Inserted line]
InterruptVectors_init.c: Line 56
// P2SEL &= ~(BIT1); // reset P2.1 for output ???
[Overview of program]
Timer B input clock source is set ACLK which was provided by external crystal(32.768kHz).
Timer A input clock source is set TAICLK(P2.0). SMCLK(P2.1) is connected to TAICLK(P2.0) in order to supply the clock from SMCLK to TAICLK.
Use the DCO(8MHz) as MCLK. And DCO supply the frequency that divided 4 the DCO frequency to SMCLK.
Operation of interrupt
* Timer A interrupt: Stop the Timer A and clear the LPM1 and set the P2.1 as output pin
During the Timer A is stopping, customer would like to use this port(P2.1) as output pin.
So, they will change the function from SMCLK output to GPIO output pin in timer A service routine.
[Code]
///////////////////////////////////////////
__interrupt void TIMER1_A1_ISR_HOOK(void)
{
/* USER CODE START (section: TIMER1_A1_ISR_HOOK) */
/* replace this comment with your code */
char iflag;
iflag = TA1IV & 0x0e;
if(iflag == 0x0A){
// Stop Timer0_A1
TA1CTL &= ~(MC1 + MC0); // Clear MCx bits
//P2SEL &= ~(BIT1); // reset P2.1 for output ???
__bic_SR_register_on_exit(LPM1_bits); // Exit LPM
}
/* USER CODE END (section: TIMER1_A1_ISR_HOOK) */
}
///////////////////////////////////////////
* Timer B interrupt: Start the Timer A and clear the LPM3 and invert the output status of P4.5.
[Code]
///////////////////////////////////////////
__interrupt void TIMERB1_ISR_HOOK(void)
{
/* USER CODE START (section: TIMERB1_ISR_HOOK) */
/* replace this comment with your code */
char iflag;
iflag = TB0IV & 0x0e;
if(iflag == 0x02){
// Clear and start Timer0_A1
TA1CTL |= MC_1 | TACLR; // Upmode
/* Port 2.1 : output SMCLK */
P2SEL |= BIT1; // P2.1 SMCLK output
P4OUT ^= BIT5; // measure ACLK 32kHz
__bic_SR_register_on_exit(LPM3_bits); // Exit LPM
}
/* USER CODE END (section: TIMERB1_ISR_HOOK) */
}
///////////////////////////////////////////
The interrupt of Timer A is stopped until happen the interrupt of Timer B.
(i.e. In order to enable the Timer A is trigger the Timer B interrupt.)
And they enter the LPM at the following timing.
* Disable Timer A: LPM3.
* Enable Timer A: LPM1
I attached the used program as below.
[Used program]
[Used Evaluation Board]
* MSP-FET430U38 with external crystal(32.768kHz) and load capacitors.
-> Connect the pin of P2.0 and P2.1
* MSP430G2955
* CCS ver 5.5
[Others]
1. When we set the High for P2.1, this phenomenon was improved. I do not understand this reason.
2. The correct operation did not confirm with connecting JTAG. So we need to write the program to flash and stop the debug. I do not understand this reason why we can confirm the correct operation by disconnected the JTAG.
If you have any questions, please let me know.
Best regards.
Kaka