802 lines
14 KiB
Plaintext
802 lines
14 KiB
Plaintext
|
|
|||
|
# 1 "C:\Users\132033dt\Desktop\RC5_Remote_Control\src\main.c"
|
|||
|
|
|||
|
# 81 "C:\Program Files\HI-TECH Software\PICC\9.82\include\pic16f628a.h"
|
|||
|
volatile unsigned char INDF @ 0x000;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
volatile unsigned char TMR0 @ 0x001;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
volatile unsigned char PCL @ 0x002;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
volatile unsigned char STATUS @ 0x003;
|
|||
|
|
|||
|
volatile bit CARRY @ ((unsigned)&STATUS*8)+0;
|
|||
|
volatile bit DC @ ((unsigned)&STATUS*8)+1;
|
|||
|
volatile bit ZERO @ ((unsigned)&STATUS*8)+2;
|
|||
|
volatile bit nPD @ ((unsigned)&STATUS*8)+3;
|
|||
|
volatile bit nTO @ ((unsigned)&STATUS*8)+4;
|
|||
|
volatile bit IRP @ ((unsigned)&STATUS*8)+7;
|
|||
|
volatile bit RP0 @ ((unsigned)&STATUS*8)+5;
|
|||
|
volatile bit RP1 @ ((unsigned)&STATUS*8)+6;
|
|||
|
|
|||
|
volatile union {
|
|||
|
struct {
|
|||
|
unsigned C : 1;
|
|||
|
unsigned DC : 1;
|
|||
|
unsigned Z : 1;
|
|||
|
unsigned nPD : 1;
|
|||
|
unsigned nTO : 1;
|
|||
|
unsigned RP : 2;
|
|||
|
unsigned IRP : 1;
|
|||
|
};
|
|||
|
struct {
|
|||
|
unsigned : 5;
|
|||
|
unsigned RP0 : 1;
|
|||
|
unsigned RP1 : 1;
|
|||
|
};
|
|||
|
} STATUSbits @ 0x003;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
volatile unsigned char FSR @ 0x004;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
volatile unsigned char PORTA @ 0x005;
|
|||
|
|
|||
|
volatile bit RA0 @ ((unsigned)&PORTA*8)+0;
|
|||
|
volatile bit RA1 @ ((unsigned)&PORTA*8)+1;
|
|||
|
volatile bit RA2 @ ((unsigned)&PORTA*8)+2;
|
|||
|
volatile bit RA3 @ ((unsigned)&PORTA*8)+3;
|
|||
|
volatile bit RA4 @ ((unsigned)&PORTA*8)+4;
|
|||
|
volatile bit RA5 @ ((unsigned)&PORTA*8)+5;
|
|||
|
volatile bit RA6 @ ((unsigned)&PORTA*8)+6;
|
|||
|
volatile bit RA7 @ ((unsigned)&PORTA*8)+7;
|
|||
|
|
|||
|
volatile union {
|
|||
|
struct {
|
|||
|
unsigned RA0 : 1;
|
|||
|
unsigned RA1 : 1;
|
|||
|
unsigned RA2 : 1;
|
|||
|
unsigned RA3 : 1;
|
|||
|
unsigned RA4 : 1;
|
|||
|
unsigned RA5 : 1;
|
|||
|
unsigned RA6 : 1;
|
|||
|
unsigned RA7 : 1;
|
|||
|
};
|
|||
|
} PORTAbits @ 0x005;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
volatile unsigned char PORTB @ 0x006;
|
|||
|
|
|||
|
volatile bit RB0 @ ((unsigned)&PORTB*8)+0;
|
|||
|
volatile bit RB1 @ ((unsigned)&PORTB*8)+1;
|
|||
|
volatile bit RB2 @ ((unsigned)&PORTB*8)+2;
|
|||
|
volatile bit RB3 @ ((unsigned)&PORTB*8)+3;
|
|||
|
volatile bit RB4 @ ((unsigned)&PORTB*8)+4;
|
|||
|
volatile bit RB5 @ ((unsigned)&PORTB*8)+5;
|
|||
|
volatile bit RB6 @ ((unsigned)&PORTB*8)+6;
|
|||
|
volatile bit RB7 @ ((unsigned)&PORTB*8)+7;
|
|||
|
|
|||
|
volatile union {
|
|||
|
struct {
|
|||
|
unsigned RB0 : 1;
|
|||
|
unsigned RB1 : 1;
|
|||
|
unsigned RB2 : 1;
|
|||
|
unsigned RB3 : 1;
|
|||
|
unsigned RB4 : 1;
|
|||
|
unsigned RB5 : 1;
|
|||
|
unsigned RB6 : 1;
|
|||
|
unsigned RB7 : 1;
|
|||
|
};
|
|||
|
} PORTBbits @ 0x006;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
volatile unsigned char PCLATH @ 0x00A;
|
|||
|
|
|||
|
|
|||
|
volatile union {
|
|||
|
struct {
|
|||
|
unsigned PCLATH : 5;
|
|||
|
};
|
|||
|
} PCLATHbits @ 0x00A;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
volatile unsigned char INTCON @ 0x00B;
|
|||
|
|
|||
|
volatile bit RBIF @ ((unsigned)&INTCON*8)+0;
|
|||
|
volatile bit INTF @ ((unsigned)&INTCON*8)+1;
|
|||
|
volatile bit T0IF @ ((unsigned)&INTCON*8)+2;
|
|||
|
volatile bit RBIE @ ((unsigned)&INTCON*8)+3;
|
|||
|
volatile bit INTE @ ((unsigned)&INTCON*8)+4;
|
|||
|
volatile bit T0IE @ ((unsigned)&INTCON*8)+5;
|
|||
|
volatile bit PEIE @ ((unsigned)&INTCON*8)+6;
|
|||
|
volatile bit GIE @ ((unsigned)&INTCON*8)+7;
|
|||
|
volatile bit TMR0IF @ ((unsigned)&INTCON*8)+2;
|
|||
|
volatile bit TMR0IE @ ((unsigned)&INTCON*8)+5;
|
|||
|
|
|||
|
volatile union {
|
|||
|
struct {
|
|||
|
unsigned RBIF : 1;
|
|||
|
unsigned INTF : 1;
|
|||
|
unsigned T0IF : 1;
|
|||
|
unsigned RBIE : 1;
|
|||
|
unsigned INTE : 1;
|
|||
|
unsigned T0IE : 1;
|
|||
|
unsigned PEIE : 1;
|
|||
|
unsigned GIE : 1;
|
|||
|
};
|
|||
|
struct {
|
|||
|
unsigned : 2;
|
|||
|
unsigned TMR0IF : 1;
|
|||
|
unsigned : 2;
|
|||
|
unsigned TMR0IE : 1;
|
|||
|
};
|
|||
|
} INTCONbits @ 0x00B;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
volatile unsigned char PIR1 @ 0x00C;
|
|||
|
|
|||
|
volatile bit TMR1IF @ ((unsigned)&PIR1*8)+0;
|
|||
|
volatile bit TMR2IF @ ((unsigned)&PIR1*8)+1;
|
|||
|
volatile bit CCP1IF @ ((unsigned)&PIR1*8)+2;
|
|||
|
volatile bit TXIF @ ((unsigned)&PIR1*8)+4;
|
|||
|
volatile bit RCIF @ ((unsigned)&PIR1*8)+5;
|
|||
|
volatile bit CMIF @ ((unsigned)&PIR1*8)+6;
|
|||
|
volatile bit EEIF @ ((unsigned)&PIR1*8)+7;
|
|||
|
|
|||
|
volatile union {
|
|||
|
struct {
|
|||
|
unsigned TMR1IF : 1;
|
|||
|
unsigned TMR2IF : 1;
|
|||
|
unsigned CCP1IF : 1;
|
|||
|
unsigned : 1;
|
|||
|
unsigned TXIF : 1;
|
|||
|
unsigned RCIF : 1;
|
|||
|
unsigned CMIF : 1;
|
|||
|
unsigned EEIF : 1;
|
|||
|
};
|
|||
|
struct {
|
|||
|
unsigned : 1;
|
|||
|
unsigned : 1;
|
|||
|
unsigned : 1;
|
|||
|
unsigned : 3;
|
|||
|
unsigned : 1;
|
|||
|
unsigned : 1;
|
|||
|
};
|
|||
|
} PIR1bits @ 0x00C;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
volatile unsigned char TMR1L @ 0x00E;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
volatile unsigned char TMR1H @ 0x00F;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
volatile unsigned int TMR1 @ 0x00E;
|
|||
|
|
|||
|
|
|||
|
volatile unsigned char T1CON @ 0x010;
|
|||
|
|
|||
|
volatile bit TMR1ON @ ((unsigned)&T1CON*8)+0;
|
|||
|
volatile bit TMR1CS @ ((unsigned)&T1CON*8)+1;
|
|||
|
volatile bit nT1SYNC @ ((unsigned)&T1CON*8)+2;
|
|||
|
volatile bit T1OSCEN @ ((unsigned)&T1CON*8)+3;
|
|||
|
volatile bit T1CKPS0 @ ((unsigned)&T1CON*8)+4;
|
|||
|
volatile bit T1CKPS1 @ ((unsigned)&T1CON*8)+5;
|
|||
|
|
|||
|
volatile union {
|
|||
|
struct {
|
|||
|
unsigned TMR1ON : 1;
|
|||
|
unsigned TMR1CS : 1;
|
|||
|
unsigned nT1SYNC : 1;
|
|||
|
unsigned T1OSCEN : 1;
|
|||
|
unsigned T1CKPS : 2;
|
|||
|
};
|
|||
|
struct {
|
|||
|
unsigned : 4;
|
|||
|
unsigned T1CKPS0 : 1;
|
|||
|
unsigned T1CKPS1 : 1;
|
|||
|
};
|
|||
|
} T1CONbits @ 0x010;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
volatile unsigned char TMR2 @ 0x011;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
volatile unsigned char T2CON @ 0x012;
|
|||
|
|
|||
|
volatile bit TMR2ON @ ((unsigned)&T2CON*8)+2;
|
|||
|
volatile bit T2CKPS0 @ ((unsigned)&T2CON*8)+0;
|
|||
|
volatile bit T2CKPS1 @ ((unsigned)&T2CON*8)+1;
|
|||
|
volatile bit TOUTPS0 @ ((unsigned)&T2CON*8)+3;
|
|||
|
volatile bit TOUTPS1 @ ((unsigned)&T2CON*8)+4;
|
|||
|
volatile bit TOUTPS2 @ ((unsigned)&T2CON*8)+5;
|
|||
|
volatile bit TOUTPS3 @ ((unsigned)&T2CON*8)+6;
|
|||
|
|
|||
|
volatile union {
|
|||
|
struct {
|
|||
|
unsigned T2CKPS : 2;
|
|||
|
unsigned TMR2ON : 1;
|
|||
|
unsigned TOUTPS : 4;
|
|||
|
};
|
|||
|
struct {
|
|||
|
unsigned T2CKPS0 : 1;
|
|||
|
unsigned T2CKPS1 : 1;
|
|||
|
unsigned : 1;
|
|||
|
unsigned TOUTPS0 : 1;
|
|||
|
unsigned TOUTPS1 : 1;
|
|||
|
unsigned TOUTPS2 : 1;
|
|||
|
unsigned TOUTPS3 : 1;
|
|||
|
};
|
|||
|
} T2CONbits @ 0x012;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
volatile unsigned char CCPR1L @ 0x015;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
volatile unsigned char CCPR1H @ 0x016;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
volatile unsigned int CCPR1 @ 0x015;
|
|||
|
|
|||
|
|
|||
|
volatile unsigned char CCP1CON @ 0x017;
|
|||
|
|
|||
|
volatile bit CCP1Y @ ((unsigned)&CCP1CON*8)+4;
|
|||
|
volatile bit CCP1X @ ((unsigned)&CCP1CON*8)+5;
|
|||
|
volatile bit CCP1M0 @ ((unsigned)&CCP1CON*8)+0;
|
|||
|
volatile bit CCP1M1 @ ((unsigned)&CCP1CON*8)+1;
|
|||
|
volatile bit CCP1M2 @ ((unsigned)&CCP1CON*8)+2;
|
|||
|
volatile bit CCP1M3 @ ((unsigned)&CCP1CON*8)+3;
|
|||
|
|
|||
|
volatile union {
|
|||
|
struct {
|
|||
|
unsigned CCP1M : 4;
|
|||
|
unsigned CCP1Y : 1;
|
|||
|
unsigned CCP1X : 1;
|
|||
|
};
|
|||
|
struct {
|
|||
|
unsigned CCP1M0 : 1;
|
|||
|
unsigned CCP1M1 : 1;
|
|||
|
unsigned CCP1M2 : 1;
|
|||
|
unsigned CCP1M3 : 1;
|
|||
|
};
|
|||
|
} CCP1CONbits @ 0x017;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
volatile unsigned char RCSTA @ 0x018;
|
|||
|
|
|||
|
volatile bit RX9D @ ((unsigned)&RCSTA*8)+0;
|
|||
|
volatile bit OERR @ ((unsigned)&RCSTA*8)+1;
|
|||
|
volatile bit FERR @ ((unsigned)&RCSTA*8)+2;
|
|||
|
volatile bit ADEN @ ((unsigned)&RCSTA*8)+3;
|
|||
|
volatile bit CREN @ ((unsigned)&RCSTA*8)+4;
|
|||
|
volatile bit SREN @ ((unsigned)&RCSTA*8)+5;
|
|||
|
volatile bit RX9 @ ((unsigned)&RCSTA*8)+6;
|
|||
|
volatile bit SPEN @ ((unsigned)&RCSTA*8)+7;
|
|||
|
volatile bit ADDEN @ ((unsigned)&RCSTA*8)+3;
|
|||
|
|
|||
|
volatile union {
|
|||
|
struct {
|
|||
|
unsigned RX9D : 1;
|
|||
|
unsigned OERR : 1;
|
|||
|
unsigned FERR : 1;
|
|||
|
unsigned ADEN : 1;
|
|||
|
unsigned CREN : 1;
|
|||
|
unsigned SREN : 1;
|
|||
|
unsigned RX9 : 1;
|
|||
|
unsigned SPEN : 1;
|
|||
|
};
|
|||
|
struct {
|
|||
|
unsigned : 3;
|
|||
|
unsigned ADDEN : 1;
|
|||
|
};
|
|||
|
} RCSTAbits @ 0x018;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
volatile unsigned char TXREG @ 0x019;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
volatile unsigned char RCREG @ 0x01A;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
volatile unsigned char CMCON @ 0x01F;
|
|||
|
|
|||
|
volatile bit CIS @ ((unsigned)&CMCON*8)+3;
|
|||
|
volatile bit C1INV @ ((unsigned)&CMCON*8)+4;
|
|||
|
volatile bit C2INV @ ((unsigned)&CMCON*8)+5;
|
|||
|
volatile bit C1OUT @ ((unsigned)&CMCON*8)+6;
|
|||
|
volatile bit C2OUT @ ((unsigned)&CMCON*8)+7;
|
|||
|
volatile bit CM0 @ ((unsigned)&CMCON*8)+0;
|
|||
|
volatile bit CM1 @ ((unsigned)&CMCON*8)+1;
|
|||
|
volatile bit CM2 @ ((unsigned)&CMCON*8)+2;
|
|||
|
|
|||
|
volatile union {
|
|||
|
struct {
|
|||
|
unsigned CM : 3;
|
|||
|
unsigned CIS : 1;
|
|||
|
unsigned C1INV : 1;
|
|||
|
unsigned C2INV : 1;
|
|||
|
unsigned C1OUT : 1;
|
|||
|
unsigned C2OUT : 1;
|
|||
|
};
|
|||
|
struct {
|
|||
|
unsigned CM0 : 1;
|
|||
|
unsigned CM1 : 1;
|
|||
|
unsigned CM2 : 1;
|
|||
|
};
|
|||
|
} CMCONbits @ 0x01F;
|
|||
|
|
|||
|
# 438
|
|||
|
volatile unsigned char OPTION_REG @ 0x081;
|
|||
|
|
|||
|
volatile bit PSA @ ((unsigned)&OPTION_REG*8)+3;
|
|||
|
volatile bit T0SE @ ((unsigned)&OPTION_REG*8)+4;
|
|||
|
volatile bit T0CS @ ((unsigned)&OPTION_REG*8)+5;
|
|||
|
volatile bit INTEDG @ ((unsigned)&OPTION_REG*8)+6;
|
|||
|
volatile bit nRBPU @ ((unsigned)&OPTION_REG*8)+7;
|
|||
|
volatile bit PS0 @ ((unsigned)&OPTION_REG*8)+0;
|
|||
|
volatile bit PS1 @ ((unsigned)&OPTION_REG*8)+1;
|
|||
|
volatile bit PS2 @ ((unsigned)&OPTION_REG*8)+2;
|
|||
|
|
|||
|
volatile union {
|
|||
|
struct {
|
|||
|
unsigned PS : 3;
|
|||
|
unsigned PSA : 1;
|
|||
|
unsigned T0SE : 1;
|
|||
|
unsigned T0CS : 1;
|
|||
|
unsigned INTEDG : 1;
|
|||
|
unsigned nRBPU : 1;
|
|||
|
};
|
|||
|
struct {
|
|||
|
unsigned PS0 : 1;
|
|||
|
unsigned PS1 : 1;
|
|||
|
unsigned PS2 : 1;
|
|||
|
};
|
|||
|
} OPTION_REGbits @ 0x081;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
volatile unsigned char TRISA @ 0x085;
|
|||
|
|
|||
|
volatile bit TRISA0 @ ((unsigned)&TRISA*8)+0;
|
|||
|
volatile bit TRISA1 @ ((unsigned)&TRISA*8)+1;
|
|||
|
volatile bit TRISA2 @ ((unsigned)&TRISA*8)+2;
|
|||
|
volatile bit TRISA3 @ ((unsigned)&TRISA*8)+3;
|
|||
|
volatile bit TRISA4 @ ((unsigned)&TRISA*8)+4;
|
|||
|
volatile bit TRISA5 @ ((unsigned)&TRISA*8)+5;
|
|||
|
volatile bit TRISA6 @ ((unsigned)&TRISA*8)+6;
|
|||
|
volatile bit TRISA7 @ ((unsigned)&TRISA*8)+7;
|
|||
|
|
|||
|
volatile union {
|
|||
|
struct {
|
|||
|
unsigned TRISA0 : 1;
|
|||
|
unsigned TRISA1 : 1;
|
|||
|
unsigned TRISA2 : 1;
|
|||
|
unsigned TRISA3 : 1;
|
|||
|
unsigned TRISA4 : 1;
|
|||
|
unsigned TRISA5 : 1;
|
|||
|
unsigned TRISA6 : 1;
|
|||
|
unsigned TRISA7 : 1;
|
|||
|
};
|
|||
|
} TRISAbits @ 0x085;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
volatile unsigned char TRISB @ 0x086;
|
|||
|
|
|||
|
volatile bit TRISB0 @ ((unsigned)&TRISB*8)+0;
|
|||
|
volatile bit TRISB1 @ ((unsigned)&TRISB*8)+1;
|
|||
|
volatile bit TRISB2 @ ((unsigned)&TRISB*8)+2;
|
|||
|
volatile bit TRISB3 @ ((unsigned)&TRISB*8)+3;
|
|||
|
volatile bit TRISB4 @ ((unsigned)&TRISB*8)+4;
|
|||
|
volatile bit TRISB5 @ ((unsigned)&TRISB*8)+5;
|
|||
|
volatile bit TRISB6 @ ((unsigned)&TRISB*8)+6;
|
|||
|
volatile bit TRISB7 @ ((unsigned)&TRISB*8)+7;
|
|||
|
|
|||
|
volatile union {
|
|||
|
struct {
|
|||
|
unsigned TRISB0 : 1;
|
|||
|
unsigned TRISB1 : 1;
|
|||
|
unsigned TRISB2 : 1;
|
|||
|
unsigned TRISB3 : 1;
|
|||
|
unsigned TRISB4 : 1;
|
|||
|
unsigned TRISB5 : 1;
|
|||
|
unsigned TRISB6 : 1;
|
|||
|
unsigned TRISB7 : 1;
|
|||
|
};
|
|||
|
} TRISBbits @ 0x086;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
volatile unsigned char PIE1 @ 0x08C;
|
|||
|
|
|||
|
volatile bit TMR1IE @ ((unsigned)&PIE1*8)+0;
|
|||
|
volatile bit TMR2IE @ ((unsigned)&PIE1*8)+1;
|
|||
|
volatile bit CCP1IE @ ((unsigned)&PIE1*8)+2;
|
|||
|
volatile bit TXIE @ ((unsigned)&PIE1*8)+4;
|
|||
|
volatile bit RCIE @ ((unsigned)&PIE1*8)+5;
|
|||
|
volatile bit CMIE @ ((unsigned)&PIE1*8)+6;
|
|||
|
volatile bit EEIE @ ((unsigned)&PIE1*8)+7;
|
|||
|
|
|||
|
volatile union {
|
|||
|
struct {
|
|||
|
unsigned TMR1IE : 1;
|
|||
|
unsigned TMR2IE : 1;
|
|||
|
unsigned CCP1IE : 1;
|
|||
|
unsigned : 1;
|
|||
|
unsigned TXIE : 1;
|
|||
|
unsigned RCIE : 1;
|
|||
|
unsigned CMIE : 1;
|
|||
|
unsigned EEIE : 1;
|
|||
|
};
|
|||
|
} PIE1bits @ 0x08C;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
volatile unsigned char PCON @ 0x08E;
|
|||
|
|
|||
|
volatile bit nBOR @ ((unsigned)&PCON*8)+0;
|
|||
|
volatile bit nPOR @ ((unsigned)&PCON*8)+1;
|
|||
|
volatile bit OSCF @ ((unsigned)&PCON*8)+3;
|
|||
|
volatile bit nBO @ ((unsigned)&PCON*8)+0;
|
|||
|
volatile bit nBOD @ ((unsigned)&PCON*8)+0;
|
|||
|
|
|||
|
volatile union {
|
|||
|
struct {
|
|||
|
unsigned nBOR : 1;
|
|||
|
unsigned nPOR : 1;
|
|||
|
unsigned : 1;
|
|||
|
unsigned OSCF : 1;
|
|||
|
};
|
|||
|
struct {
|
|||
|
unsigned nBO : 1;
|
|||
|
};
|
|||
|
struct {
|
|||
|
unsigned nBOD : 1;
|
|||
|
};
|
|||
|
} PCONbits @ 0x08E;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
volatile unsigned char PR2 @ 0x092;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
volatile unsigned char TXSTA @ 0x098;
|
|||
|
|
|||
|
volatile bit TX9D @ ((unsigned)&TXSTA*8)+0;
|
|||
|
volatile bit TRMT @ ((unsigned)&TXSTA*8)+1;
|
|||
|
volatile bit BRGH @ ((unsigned)&TXSTA*8)+2;
|
|||
|
volatile bit SYNC @ ((unsigned)&TXSTA*8)+4;
|
|||
|
volatile bit TXEN @ ((unsigned)&TXSTA*8)+5;
|
|||
|
volatile bit TX9 @ ((unsigned)&TXSTA*8)+6;
|
|||
|
volatile bit CSRC @ ((unsigned)&TXSTA*8)+7;
|
|||
|
|
|||
|
volatile union {
|
|||
|
struct {
|
|||
|
unsigned TX9D : 1;
|
|||
|
unsigned TRMT : 1;
|
|||
|
unsigned BRGH : 1;
|
|||
|
unsigned : 1;
|
|||
|
unsigned SYNC : 1;
|
|||
|
unsigned TXEN : 1;
|
|||
|
unsigned TX9 : 1;
|
|||
|
unsigned CSRC : 1;
|
|||
|
};
|
|||
|
} TXSTAbits @ 0x098;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
volatile unsigned char SPBRG @ 0x099;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
volatile unsigned char EEDATA @ 0x09A;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
volatile unsigned char EEADR @ 0x09B;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
volatile unsigned char EECON1 @ 0x09C;
|
|||
|
|
|||
|
volatile bit RD @ ((unsigned)&EECON1*8)+0;
|
|||
|
volatile bit WR @ ((unsigned)&EECON1*8)+1;
|
|||
|
volatile bit WREN @ ((unsigned)&EECON1*8)+2;
|
|||
|
volatile bit WRERR @ ((unsigned)&EECON1*8)+3;
|
|||
|
|
|||
|
volatile union {
|
|||
|
struct {
|
|||
|
unsigned RD : 1;
|
|||
|
unsigned WR : 1;
|
|||
|
unsigned WREN : 1;
|
|||
|
unsigned WRERR : 1;
|
|||
|
};
|
|||
|
} EECON1bits @ 0x09C;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
volatile unsigned char EECON2 @ 0x09D;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
volatile unsigned char VRCON @ 0x09F;
|
|||
|
|
|||
|
volatile bit VRR @ ((unsigned)&VRCON*8)+5;
|
|||
|
volatile bit VROE @ ((unsigned)&VRCON*8)+6;
|
|||
|
volatile bit VREN @ ((unsigned)&VRCON*8)+7;
|
|||
|
volatile bit VR0 @ ((unsigned)&VRCON*8)+0;
|
|||
|
volatile bit VR1 @ ((unsigned)&VRCON*8)+1;
|
|||
|
volatile bit VR2 @ ((unsigned)&VRCON*8)+2;
|
|||
|
volatile bit VR3 @ ((unsigned)&VRCON*8)+3;
|
|||
|
|
|||
|
volatile union {
|
|||
|
struct {
|
|||
|
unsigned VR : 4;
|
|||
|
unsigned : 1;
|
|||
|
unsigned VRR : 1;
|
|||
|
unsigned VROE : 1;
|
|||
|
unsigned VREN : 1;
|
|||
|
};
|
|||
|
struct {
|
|||
|
unsigned VR0 : 1;
|
|||
|
unsigned VR1 : 1;
|
|||
|
unsigned VR2 : 1;
|
|||
|
unsigned VR3 : 1;
|
|||
|
};
|
|||
|
} VRCONbits @ 0x09F;
|
|||
|
|
|||
|
|
|||
|
# 27 "C:\Program Files\HI-TECH Software\PICC\9.82\include\pic.h"
|
|||
|
#pragma inline(_nop)
|
|||
|
extern void _nop(void);
|
|||
|
|
|||
|
# 80
|
|||
|
extern unsigned int flash_read(unsigned short addr);
|
|||
|
|
|||
|
# 144
|
|||
|
extern void flash_erase(unsigned short addr);
|
|||
|
|
|||
|
# 41 "C:\Program Files\HI-TECH Software\PICC\9.82\include\eeprom_routines.h"
|
|||
|
extern unsigned char eeprom_write(unsigned char addr, unsigned char value);
|
|||
|
extern unsigned char eeprom_read(unsigned char addr);
|
|||
|
extern void eecpymem(volatile unsigned char *to, eeprom unsigned char *from, unsigned char size);
|
|||
|
extern void memcpyee(eeprom unsigned char *to, const unsigned char *from, unsigned char size);
|
|||
|
|
|||
|
|
|||
|
# 153 "C:\Program Files\HI-TECH Software\PICC\9.82\include\pic.h"
|
|||
|
#pragma inline(_delay)
|
|||
|
extern void _delay(unsigned long);
|
|||
|
|
|||
|
# 43 "C:\Users\132033dt\Desktop\RC5_Remote_Control\src\main.c"
|
|||
|
asm("\tpsect config,class=CONFIG,delta=2"); asm("\tdw ""0xFF7F & 0xFFBF & 0xFFFF & 0xFFDF & 0xFFF7 & 0xFFFB & 0xFFED");
|
|||
|
|
|||
|
|
|||
|
unsigned char PhaseDemod();
|
|||
|
|
|||
|
|
|||
|
|
|||
|
unsigned char toggle = 0;
|
|||
|
unsigned char counterus = 0;
|
|||
|
unsigned char counterms = 0;
|
|||
|
unsigned int cycl_1;
|
|||
|
unsigned int cycl_2, CountA, CountB, CountC;
|
|||
|
unsigned int somethingpressed = 0;
|
|||
|
|
|||
|
void samplebit();
|
|||
|
|
|||
|
void AN()
|
|||
|
{
|
|||
|
unsigned char i = 0;
|
|||
|
do
|
|||
|
{
|
|||
|
RA0 = 1;
|
|||
|
RA0 = 1;
|
|||
|
RA0 = 1;
|
|||
|
RA0 = 1;
|
|||
|
|
|||
|
RA0 = 0;
|
|||
|
RA0 = 0;
|
|||
|
RA0 = 0;
|
|||
|
RA0 = 0;
|
|||
|
RA0 = 0;
|
|||
|
RA0 = 0;
|
|||
|
RA0 = 0;
|
|||
|
RA0 = 0;
|
|||
|
RA0 = 0;
|
|||
|
RA0 = 0;
|
|||
|
RA0 = 0;
|
|||
|
i++;
|
|||
|
}
|
|||
|
while(i<32);
|
|||
|
|
|||
|
RA0 = 0;
|
|||
|
|
|||
|
# 130
|
|||
|
}
|
|||
|
|
|||
|
void AUS()
|
|||
|
{
|
|||
|
unsigned char i = 0;
|
|||
|
do
|
|||
|
{
|
|||
|
RA0=0;
|
|||
|
}
|
|||
|
while(i++<59);
|
|||
|
|
|||
|
# 154
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
void interrupt ISR (void)
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
void delay_89ms()
|
|||
|
{
|
|||
|
|
|||
|
# 166
|
|||
|
#asm
|
|||
|
pause89ms
|
|||
|
clrf _CountA
|
|||
|
clrf _CountB
|
|||
|
clrf _CountC
|
|||
|
movlw 0x74
|
|||
|
movwf _CountB
|
|||
|
movlw 0x02
|
|||
|
movwf _CountA
|
|||
|
movlw 0x01
|
|||
|
movwf _CountC
|
|||
|
|
|||
|
Loop ;Wiederholung der Zeitverz<72>gerung
|
|||
|
decfsz _CountA
|
|||
|
goto Loop
|
|||
|
decfsz _CountB
|
|||
|
goto Loop
|
|||
|
decfsz _CountC
|
|||
|
goto Loop
|
|||
|
#endasm
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
void SendEins()
|
|||
|
{
|
|||
|
AUS();
|
|||
|
AN();
|
|||
|
}
|
|||
|
void SendNull()
|
|||
|
{
|
|||
|
AN();
|
|||
|
AUS();
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
void evaluate_tastatur(char *comcode)
|
|||
|
{
|
|||
|
unsigned char i;
|
|||
|
unsigned char a;
|
|||
|
unsigned char e;
|
|||
|
e = 0;
|
|||
|
|
|||
|
for(i=3; i != 255; i--)
|
|||
|
{
|
|||
|
PORTB = 0xFF;
|
|||
|
PORTB &= ~(1<<i);
|
|||
|
for(a=4; a <= 7; a++)
|
|||
|
{
|
|||
|
e++;
|
|||
|
if( ((PORTB>>a) & 1) == 0)
|
|||
|
{
|
|||
|
*comcode = e;
|
|||
|
somethingpressed = 1;
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
void SendRc5(char* command, char *group)
|
|||
|
{
|
|||
|
unsigned char i;
|
|||
|
SendEins();
|
|||
|
SendEins();
|
|||
|
|
|||
|
toggle = toggle ^ 1 & 1;
|
|||
|
if(toggle == 1)
|
|||
|
SendEins();
|
|||
|
else
|
|||
|
SendNull();
|
|||
|
|
|||
|
for(i = 4; i != 255; i--)
|
|||
|
{
|
|||
|
if(((*group>>i))&1)
|
|||
|
SendEins();
|
|||
|
else
|
|||
|
SendNull();
|
|||
|
}
|
|||
|
for(i = 5; i != 255; i--)
|
|||
|
{
|
|||
|
if(((*command)>>i)&1)
|
|||
|
SendEins();
|
|||
|
else
|
|||
|
SendNull();
|
|||
|
}
|
|||
|
delay_89ms();
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
void main(void)
|
|||
|
{
|
|||
|
unsigned char comcode = 0;
|
|||
|
char subcode = 0;
|
|||
|
|
|||
|
OPTION_REG = 0b00000010;
|
|||
|
CMCON = 0x07;
|
|||
|
TRISA = 0x00;
|
|||
|
TRISB = 0xF0;
|
|||
|
|
|||
|
GIE = 1;
|
|||
|
CM0 = 1;
|
|||
|
CM1 = 1;
|
|||
|
CM2 = 1;
|
|||
|
PORTA = 0;
|
|||
|
PORTB = 0xFF;
|
|||
|
subcode = 29;
|
|||
|
|
|||
|
|
|||
|
INTCON = 0;
|
|||
|
RBIE = 1;
|
|||
|
char help = 0;
|
|||
|
|
|||
|
while(1)
|
|||
|
{
|
|||
|
while(!RBIF)
|
|||
|
asm("sleep");
|
|||
|
PORTB = 0xFF;
|
|||
|
evaluate_tastatur(&comcode);
|
|||
|
if(somethingpressed == 1)
|
|||
|
{
|
|||
|
SendRc5(&comcode, &subcode);
|
|||
|
somethingpressed = 0;
|
|||
|
help = 1;
|
|||
|
}
|
|||
|
|
|||
|
# 303
|
|||
|
}
|
|||
|
}
|
|||
|
|