Part Number: CC2530
//Initialisation;
void irLearnerInit(uint8 irType)
{
//Timer Clock Source = 32MHz
CLKCONCMD &= 0x80;
//Timer-1 priority over uart
P2DIR |= BV(7);
//Timer-1 channel0 alternate2 i.e. P1_2
PERCFG &= ~BV(4);
P1INP |= BV(2);
P1SEL |= BV(2);
P1DIR &= ~BV(2);
//timer1 channel0 interrupt mask
T1CCTL0 |= BV(6);
//rest channel interrupt disabled
T1CCTL1 &= ~BV(6);
T1CCTL2 &= ~BV(6);
T1CCTL3 &= ~BV(6);
T1CCTL4 &= ~BV(6);
T1OVFIM = 0;
T1STAT &= ~BV(0);
//Enables interrupt
T1IE = 1;
T1IF = 0;
EA = 1;
T1CCTL0 &= ~BV(2);
//interrupt on all edge
T1CCTL0 |= BV(1);
T1CCTL0 |= BV(0);
//Timer1 clock frequency 1MHz
T1CTL |= 0x08;
//free-running mode active
T1CTL |= 0x01;
}
HAL_ISR_FUNCTION( IRisr, T1_VECTOR )
{
HAL_ENTER_ISR();
if(T1STAT & BV(0)) //overflow interrupt occur
{
T1STAT &= ~BV(0); //clear interrupt flag
irProcessInterrupt();
}
T1IF = 0;
CLEAR_SLEEP_MODE();
HAL_EXIT_ISR();
}
void irProcessInterrupt(void)
{
LED = ~LED;
irRcvBuff[pulseCount] = T1CC0H;
pulseCount++;
irRcvBuff[pulseCount] = T1CC0L;
pulseCount++;
timeoutCountStart = 1;
}
Tool/software: WEBENCH® Design Tools
I have successfully implemented the IR blaster using Timer 1 and Timer 3.
But now I want to implement IR Learner but don't know how to setup for it.
I know little bit about Timer1 & Timer 3 capture but don't know exactly what to do.
Can anybody help me with this??