Hi,I having problem with decoding the received IR signal from the normal 38 Khz remote and I am using the 38Khz receiver from the vishay. I am using the capture & compare timer of the msp430g2253.but the problem I am facing is in my code below is it can capture the falling edge and produce the interrupt but when I change capture mode to capture rising edge it doesnt detect the rising edge and remains in the low power mode.another problem with this code is that after getting the first falling edge interrupt it remains in the sleep mode only though I am clearing the cpuoff bit in the ISR. Please help me I have hit the wall and provide any code which can caputure both rising edge and falling edge and at the same time it should save the CCR value so that I can have the timing between falling and rising edge. please it is for the project.Your help is appreciated.
my code is as below.it doesnt execute the colored part and remains in the sleep mode.
#include "io430.h"unsigned int rxdata = 0; // received data: A4-A0 and C6-C0 0000 AAAA ACCC CCCCunsigned int bitCounter = 0;void main(void){ WDTCTL = WDTPW + WDTHOLD; // stop WDT BCSCTL1 = CALBC1_1MHZ; // load calibrated data DCOCTL = CALDCO_1MHZ; P1DIR &= ~BIT1; // P1.1 input P1SEL = BIT1; // P1.1 Timer_A CCI0A P1OUT &= ~(BIT0 + BIT6 + BIT5); // P1.3-1.5 out P1DIR |= (BIT0 + BIT6 + BIT5); TACTL = TASSEL_2 | MC_2; // SMCLK, continuous mode CCTL0 = CM_2 | CCIS_0 | CAP | CCIE; // falling edge capture mode, CCI0A, enable IE __bis_SR_register(CPUOFF + GIE); rxdata = CCR0; CCTL0 = CM_1 | CCIS_0 | CAP | CCIE; __bis_SR_register(CPUOFF + GIE); bitCounter = CCR0; }#pragma vector = TIMER0_A0_VECTOR__interrupt void Timer_A (void){ __bic_SR_register(GIE); P1OUT = P1OUT ^ BIT0; TACCTL0 &= ~CCIFG; __bic_SR_register(CPUOFF); }
The reason that the CPU does not wake up after your ISR exits is because you did not clear the CPUOFF bit of SR in the saved copy in the stack. Thus when the ISR exits, the SR is restored by the interrupt hardware with CPUOFF bit still set.
You use __bic_SR_register(CPUOFF); in your ISR. This will clear CPUOFF bit in SR, which is already 0 (otherwise the CPU is asleep and will not execute this statement). You should have cleared that bit of the save copy on the stack instead.
You also use __bic_SR_register(GIE); in your ISR. This will clear GIE bit in SR, which is already cleared by the interrupt hardware. You do not need this statement.
The rest is not "in the history" yet -- your main() need to do more before it exits.
Now my question is how to change the content of the SR in the stack in C because the instruction in assembly for changing the SR in the stack is known to me but I dont know how to do that in C.So please help. and I have cleared GIE to check if another interrupt is causing this issue (or) not. Thank You for attention and help.
It depends on which c-compiler you are using. Something like: __bic_SR_register_on_exit ( CPUOFF );