I use 19200bps baudrate to send data from rcm5600w microcontroller to picasso display 4.3". Before I sending data from rabbit to picasso, I try to send data from the rabbit to the serial port of the computer and I look the data in hyperterminal, all goes according to expectations.
when I replace the computer with picasso, the data appeared in realtime, but after a moment data seemed to freeze. I am sure the error occurred in serial communication of picasso. Is the correct way to handle serial communication error in picasso like this? Thanks.
Completed Code:
when I replace the computer with picasso, the data appeared in realtime, but after a moment data seemed to freeze. I am sure the error occurred in serial communication of picasso. Is the correct way to handle serial communication error in picasso like this? Thanks.
Code:
if((com1_Full() & (com1_Count()==0)) || com1_Error()) com1_Init(packetIn, SERIN_BUFFER, 0); endif
Completed Code:
Code:
// constant #CONST TOUCH_HANDSHAKING 0x40 MASTER_ID 0xFF SLAVE_ID 0x01 STX 0x02 ETX 0x03 ACK 0x06 NAK 0x15 BAUDRATE 1920 // DON'T CHANGE SERIN_BUFFER 255 // DON'T CHANGE RX_TMOUT 100 #END // member variable var packetIn[SERIN_BUFFER]; // function func reqHandshaking() var BCC, dt, n, pSTX, tmOut; // request handshake to rabbit serout1(STX); BCC := 0; serout1(MASTER_ID); BCC ^= MASTER_ID; serout1(TOUCH_HANDSHAKING); BCC ^= TOUCH_HANDSHAKING; serout1(ETX); BCC ^= ETX; serout1(BCC); // read response of rabbit mem_Set(packetIn, NULL, sizeof(packetIn)); n := 0; pSTX := -1; tmOut:= RX_TMOUT; while(tmOut--) if((com1_Full() & (com1_Count()==0)) || com1_Error()) com1_Init(packetIn, SERIN_BUFFER, 0); endif if((dt := serin1())>=0) packetIn[n] := dt&0xFF; if(n==0 && packetIn[0]==STX) tmOut:= RX_TMOUT; pSTX := 0; BCC := 0; n++; continue; else if(n>0 && pSTX==0) tmOut:= RX_TMOUT; if(n==6 && packetIn[n-1]==ETX) if(packetIn[n]==BCC) if(packetIn[1]==SLAVE_ID) if(packetIn[2]==TOUCH_HANDSHAKING) return (packetIn[3]<<4 + packetIn[4]); endif endif endif endif BCC ^= packetIn[n]; n++; endif endif if(n>sizeof(packetIn)-1) break; wend return -1; endfunc
Comment