Hello everyone,
In brief, I would like to send/receive 9600,8,O,1. (RS485) by using 16F876A like this format:
Address, command1, command2, command3 ,checksum.
I start my work first for sending and now I am still involved at sending-section. I use these below settings:
And the problem is:
It always sends the first byte correctly, after that, the second and third is not the case which I respect. Depends on case 7th bit is one “1” and changes commands and checksum. seems they sum by 80 Hex.
Any suggestion, please? Or a sample routine which has been already tested for 9600,8,O,1.
ManyThanks in advance.
Code:; With 4Mhz Osc DEFINE HSER_BAUD 9600 DEFINE HSER_BITS 9 DEFINE HSER_ODD 1 'Set ODD Parity DEFINE HSER_SPBRG 25 DEFINE HSER_CLROERR 1 TRISB=$FF TRISC=0 Address VAR BYTE Command1 VAR BYTE Command2 VAR BYTE Command3 VAR BYTE Checksum VAR BYTE Address = $40 Command1 = $50 Command2 = $44 Command3 = $A5 Checksum = Address ^ Command1 ^ Command2 ^ Command3 while (PORTB.0 = 1) HSEROUT [ Address ] pause 1 HSEROUT [ Command1 ] pause 1 HSEROUT [ Command2 ] pause 1 HSEROUT [ Command3 ] pause 1 HSEROUT [ Checksum ] PAUSE 1 WEND




Bookmarks