PDA

View Full Version : How does serin function?



a_critchlow
- 26th January 2006, 21:39
Hi, i am new to this forum so.. hi.
I was wondering how the serin command functions.

I know the PIC executes line by line instructions, so with the serin command does the PIC wait to receive so many bits before executing the next instruction. The problem being say if i want to send 8bits and 2 bits are lost, will the PIC wait untill it receives another 2 bits to make up for the lost ones or will it clock to empty spaces and move onto the next instruction?

Secondly does anyone know what the encoder and decoder chip does? I want to bypass this and go straight from the RF module to the PIC. (The PIC will act as to whether or not it will receive the data or not). Are there any problems with this?



Thank you to anyone who can help.

sean-h
- 6th February 2006, 20:53
Serial data is just 1 and 0's.

So if receving say a byte the the serial packet will have a start bit, 8 bits of data, parity bit and then Stop bits.

But it is all done on timing, so if the pic does not receive a say a 1 within the time delay set by the baud rate between bits, then it will just take it as being a 0

This is where you need to use the parity bit and do a calculation against the 8 data bits received.
So basically receive your 8 bits and your parity bit, do the calculation and if incorrect request the byte again from the device sending the data.

Regards

Sean.

a_critchlow
- 6th February 2006, 21:52
hi thanks for that, could you elaborate on the parity bit? is this either a 1 or a zero? what calculation is there? i am planning on using 8N1 so it isnt vital but the parity may come in useful! Especially for fault tollerence.





thanks for your time,
andrew.

sean-h
- 7th February 2006, 09:10
The Parity bit can be either odd or even.

Check this link for more details:

http://www.lammertbies.nl/comm/info/RS-232_specs.html#erro

Regards

Sean.