#define InitUART( BRGVal, BRGHighVal ) { \
UARTTxD = UARTTxDInit; \
DirUARTTxD = DirOutput; \
DirUARTRxD = DirInput; \
SPBRG2 = BRGVal; \
TXSTA2bits.BRGH = BRGHighVal; \
TXSTA2bits.SYNC = 0; \
TXSTA2bits.TX9 = 0; \
TXSTA2bits.TXEN = 1; \
RCSTA2bits.SPEN = 1; \
RCSTA2bits.RX9 = 0; \
IPR3bits.RC2IP = 1; \
IPR3bits.TX2IP = 0; \
PIE3bits.TX2IE = 0; \
PIE3bits.RC2IE = 1; \
RCSTA2bits.CREN = 0; \
}
for the last line, why RCSTA2bits.CREN need to be set to 0? how can i receive the data that come in if it set to be o?
initializes the UsART2 with high priority receive interrupt
InitUART (9600,1);// initialise the USART2 with high priority receive interrupt
this is my high interrupt code
//when some data is transmitted in through USART2
if (UARTRxIntFlag == 1) {
//receive interrupt occurs, do receive function(UARTChIn = ?)
}
this is my low interrupt code
rom unsigned char * szHello = "Hello\r\n";
if (IsSWI( SWI_LMTData ) ){
unsigned char ch = *LMTRxCh;
// if the received character from USART1 is an 'H'
if (ch=='h' || ch=='H'){
// say hello back through USART1
LMTTransmit( szHello, 0, 7, 255, LogicalChannel );
// send 'H' through USART2
UARTChOut = ch;
}
// remove the character from the receive buffer
LMTRxAdvanceCh;
//Receive enable for USART2(RCSTA2bits.CREN = 1;)
UARTEnable = 1;
ClearSWI( SWI_LMTData ); // Clear interrupt flag
return;
}
if (IsSWI( SWI_Tick ) ){
ClearSWI( SWI_Tick ); // Clear interrupt flag
return;
}
PAGE 106 0F http://www.flexipanel.com/Docs/Toothpick%202.1%20DS484.pdf
this code is not working and i don't know why. can you guys help me with that?