LS,
I use controlled hardware and make sure that data received enters the chip at pin 12.
However RCIF is not set.
Transmit is working correct.
What do I do wrong??
Picbuster
Setup code.
Mod:added Code tags.
I use controlled hardware and make sure that data received enters the chip at pin 12.
However RCIF is not set.
Transmit is working correct.
What do I do wrong??
Picbuster
Setup code.
Mod:added Code tags.
C-like:
ANSEL=0;
OSCCON=0b01100110; //8 Mhz
TRISA= 0b00000010;
TRISB= 0b11100000; // bit 5 transmit bit7 receive
TRISC= 0b11010000;
ANSEL =0b00000000; // analog
BAUDCON=0;
//========== transmit
TXSTAbits.SYNC=0;
TXSTAbits.TXEN=1;
//======== Receive
RCSTA=0; // all zero
RCSTAbits.CREN =1;
RCSTAbits.SPEN=1;
//========= baudrate
SPBRG = 25; // 19200
BRGH=1;
BRG16=0;
//===================
PIE1bits.RCIE=On;
//===================
TMR1IE=On;
PEIE=1;
GIE=1;
//========================
T1CON=0b10111101;
putch('!');
putch(13);
putch(10);
putch(13);
putch(10);
putch('S');
//================================== interrupt =======================
void __interrupt()
Isr(void)
{
if (TMR1IF)
{
TMR1IF=0; // always running
Timer++;
if (Timer >1)
{
Timer=0;
Alive=!Alive; // working
}
}
if (PIR1bits.RCIF) // usart received char
{
// PIR1bits.RCIF=0; not allowed is read only
if (RCSTAbits.OERR) // check for overrun.
{
RCSTAbits.CREN=0; // clear receiver
RCSTAbits.CREN=1; // re-enable
}
Led_Rd=1;
if (RCREG){Transmit=Off;}
if (RCREG== SOH){In_Pointer=0;}
if (RCREG == EOT)
{
Block_In=On;
Led_Rd=0;
}
else
{
In_Data[In_Pointer]=RCREG;
In_Pointer++;
}
// }
}
//===================== end data read ==========================================
}
Last edited by a moderator: