SneaKSz
Member
Hello all,
I am facing a stupid problem , I am able to send data to the pc and send data to the PIC.
The problem is that the pic doesnt set the receive bit.
This is a typical usart TX RC code .
I see the data on the Rx pin , but the interrupt flag doesnt set.
Thanks in advance!
I am facing a stupid problem , I am able to send data to the pc and send data to the PIC.
The problem is that the pic doesnt set the receive bit.
Code:
void init();
void Strans(unsigned char W);
void InterruptHandlerHigh (void);
// High priority interrupt vector
#pragma code InterruptVectorHigh = 0x08 // comp mode default vector
void InterruptVectorHigh (void)
{
_asm
goto InterruptHandlerHigh //jump to interrupt routine
_endasm
}
//----------------------------------------------------------------------------
// High priority interrupt routine
#pragma code
#pragma interrupt InterruptHandlerHigh
void InterruptHandlerHigh ()
{
unsigned int i = RCREG;
LATCbits.LATC1=1;
if(PIR1bits.RCIF==1){
if ( i==1){
}
}
}
void main(void){
init();// setup
while(1){
// Strans(0x54);//T
// Strans(0x45);//E
// Strans(0x53);//S
// Strans(0x54);//T
LATCbits.LATC1=1;
if(PIR1bits.RCIF==1){
unsigned int i = RCREG;
LATCbits.LATC0=0;
}
}
} // end main
void init(){
ADCON0=0x0;//Configure A/D
TRISCbits.TRISC0=0;
TRISCbits.TRISC1=0;
LATCbits.LATC0=1;
LATCbits.LATC1=0;
// Serial communication
TXSTA=0x20;// enable transmit
SPBRG=19; // 9600 bps
TRISBbits.TRISB7=0;//TX out
TRISBbits.TRISB5=1; //RX
RCSTA=0x90;//enable receive + serial port.
TXSTAbits.TXEN=1;
PIE1bits.RCIE=1;
INTCONbits.GIE=1;
INTCONbits.PEIE=1;
}
void Strans(unsigned char W){
while(PIR1bits.TXIF==0); // wait until the last bit is gone
TXREG=W;
}
This is a typical usart TX RC code .
I see the data on the Rx pin , but the interrupt flag doesnt set.
Thanks in advance!