PIC18F2620/4620 with ZigBee MRF24J40的USART通訊
|
||||
---|---|---|---|---|
新會員
|
小弟正將RS232通訊功能加入ZigBee firmware
我以interrupt routing server方式將RS232加入ZigBee中斷, 但是module在接收PC的RS232資料時 常常會發生掉Byte或接收成亂碼..... Ex,我要收19 10 38 30 17 卻常收成19 38 30 17或19 30 17或84 82 DA 拜託各位先進能幫幫忙, 以下是我的source code... #define CLOCK_FREQ 16000000 #define BAUD_RATE 115200 void ConsoleInit(void) { #if defined(USART_USE_BRGH_HIGH) TXSTA = 0x24; #else TXSTA = 0x20; #endif RCSTA = 0x90; SPBRG = SPBRG_VAL=0x08; } void UARTIntISR(void) { #if RXON { if(!vUARTIntStatus.UARTIntRxBufferFull && RCIF == 1) { vUARTIntStatus.UARTIntRxOverFlow = 0; vUARTIntStatus.UARTIntRxBufferEmpty = 0; vUARTIntRxBuffer[vUARTIntRxBufWrPtr] = RCREG; RCIF = 0; vUARTIntRxBufDataCnt ++; if(vUARTIntRxBufDataCnt == RS485_RX_BUFFER_SIZE) vUARTIntStatus.UARTIntRxBufferFull = 1; vUARTIntRxBufWrPtr++; if(vUARTIntRxBufWrPtr == RS485_RX_BUFFER_SIZE) vUARTIntRxBufWrPtr = 0; } } #endif } THX Earnie
發表於: 2008/5/10 2:02
|
|||
|