-
9-Bit Send/Receive
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
-
Re: 9-Bit Send/Receive
I found something like this here:
The second characteristic is parity. The parity characteristic can be even, odd, mark, space, or none. If even parity, then the last data bit transmitted will be a logical 1 if the data transmitted had an even amount of 0 bits. If odd parity, then the last data bit transmitted will be a logical 1 if the data transmitted had an odd amount of 0 bits. If MARK parity, then the last transmitted data bit will always be a logical 1. If SPACE parity, then the last transmitted data bit will always be a logical 0. If no parity then there is no parity bit transmitted.
Hope is useful. Odd parity is probably the problem.
-
Re: 9-Bit Send/Receive
Hello,
My source code which I have already written it here, is all right.
Without any doubt, I should express my gratitude to Darrel Taylor, Mister_e and, Henrik Olsson, . . . and many other expert guys who participate here and help people.
I have read their already-published posts and I found the clues.
My Fault was somewhere else in target device. I didn't read the target catalogue well.
I apologize.
Kind regards,
Good Luck.
Andy