sayf alawneh
Junior Member level 3
- Joined
- Aug 15, 2014
- Messages
- 27
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 256
hello guys , i tried to do it all my self and i have to tell u that i have a terrible headache
any ways this code is to decode any remote control's signal protocol using mikroc pro and pic 16f877a and am sure there are lot of mistakes there please help me i think no body tried it before i couldnt find any info on the web :bang:
RC2(ccp1) is recieving the signal
where is/are the problems guys ?
isnt this code supposed to give me the time for every positive pulse in the remote signal ?
i used a signal generator in proteus but look what i had
any ways this code is to decode any remote control's signal protocol using mikroc pro and pic 16f877a and am sure there are lot of mistakes there please help me i think no body tried it before i couldnt find any info on the web :bang:
RC2(ccp1) is recieving the signal
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 int m ;char txt1[5],txt2[5]; int time1=0,time2=0; sbit LCD_RS at RB2_bit; sbit LCD_EN at RB3_bit; sbit LCD_D7 at RB7_bit; sbit LCD_D6 at RB6_bit; sbit LCD_D5 at RB5_bit; sbit LCD_D4 at RB4_bit; sbit LCD_RS_Direction at TRISB2_bit; sbit LCD_EN_Direction at TRISB3_bit; sbit LCD_D7_Direction at TRISB7_bit; sbit LCD_D6_Direction at TRISB6_bit; sbit LCD_D5_Direction at TRISB5_bit; sbit LCD_D4_Direction at TRISB4_bit; void main() { CMCON=7;//disable comparator TRISC=255;// portc as input. TRISB=0;portb as output. PORTC=0; PORTB=0; T1CON=0B00000101;//enabling timer one in asynchronized timer mode. INTCON=0B11000000;//enabling GIE and PEIE bits to allow interrupts PIR1=0; //CCP1IF and TMR1IF are both zeros TMR1L=0; TMR1H=0;// initializing TMR1L and TMR1H LCD_INIT(); LCD_CMD(_LCD_CLEAR); LCD_CMD(_LCD_CURSOR_OFF); while(1){ CCP1CON=0B00000101; capture every rising edge (the first one) and as i understood when first rising edge is captured CCP1IF will be 1 PIE1=0B00000101;//TMR1IE and CCP1IE bits are enabled if(CCP1IF_BIT==1){// when this bit is 1 the first rising edge is captured time1=CCPR1L+(256*CCPR1H);//the time of the first rising edge TMR1IF_BIT=0;//set the interrupt flag to zero to enable another oncoming one CCP1IF_BIT=0; } CCP1CON=0B00000100;// capture every falling edge () the first falling edge) PIE1=0B00000101;// CCP1IE and TMR1IE bits are enabled if(CCP1IF_BIT==1){ if the first falling edge is captured time2=CCPR1L+(256*CCPR1H);// the time of the first falling edge TMR1IF_BIT=0;//set the interrupt flag to zero to enable another oncoming one CCP1IF_BIT=0; } ____ m=time2-time1;// m presents the time of an on pulse only i mean the 1 part (the positive part of the pulse) | | inttostr(m,txt1); LCD_OUT(1,1,txt1); delay_ms(1000); } }
where is/are the problems guys ?
isnt this code supposed to give me the time for every positive pulse in the remote signal ?
i used a signal generator in proteus but look what i had
Last edited: