btbass
Advanced Member level 5
My code is working ok.
With the lower prescale I had to increase the timeout in two functions.
This code is working ok.
With the lower prescale I had to increase the timeout in two functions.
Code:
/*--- Timer 4 one shot Interrupt ---*/
void __attribute__((__interrupt__, no_auto_psv)) _T4Interrupt(void)
{
if(!Decoder.error)
{
if(Decoder.bit_counter == 0x0b){
save_data(0);
}
RC5_Code.address = (Decoder.rc_data >> 6) & 0x001f;
RC5_Code.command = Decoder.rc_data & 0x003f;
RC5_Code.toggle = (Decoder.rc_data >> 11) & 0x0001;
RC5_Code.valid = 1;
}
IFS1bits.T4IF = 0;
IEC1bits.T4IE = 0;
T4CONbits.TON = 0;
[B]PR4 = 0x2000; !!!!!! increase timeout[/B]
Decoder.State = START_S;
}
/*--- Initialise Timer 4 (Used as RC timer) ---*/
static void init_timer_4(void)
{
T4CON = 0;
IPC6bits.T4IP = 6; /* High priority */
[B]T4CONbits.TCKPS = 1; /* Prescale 1:8 */ [/B]
[B]PR4 = 0x2000; /* Time out */ !!!!!! increase timeout [/B]
IFS1bits.T4IF = 0;
IEC1bits.T4IE = 0; /* Interrupt enable bit */
T4CONbits.TON = 0;
}
/*--- End of File ---*/
This code is working ok.
Code:
#include "rc5_decoder.h"
_CONFIG1( JTAGEN_OFF & GCP_OFF & GWRP_OFF & COE_OFF & FWDTEN_OFF & ICS_PGx2)
_CONFIG2( FCKSM_CSDCMD & OSCIOFNC_ON & POSCMOD_NONE & FNOSC_FRC)
/*--- RC5 infra red codes ---*/
#define RC5_ADDRESS 20U
#define STOP 54U
#define PLAY 53U
#define PAUSE 48U
#define NEXT_TRACK 32U
#define PREV_TRACK 33U
#define SCAN_FORWARDS 52U
#define SCAN_BACKWARDS 50U
/*--- Program entry ---*/
int main(void)
{
init_rc5_decoder(); /* Initialise decoder */
TRISA = 0;
AD1PCFG = 0xffff;
while(1)
{
if(RC5_Code.valid)
{
PORTA = RC5_Code.command;
RC5_Code.valid = 0;
}
}
}
/*--- End of File ---*/
Last edited: