PDA

View Full Version : Serial inputting



Peter987
- 2nd January 2007, 01:27
Howdy
Can anyone give me some examples please in more detailed depth regarding the MELabs Pic Compiler command serin.

I have two 16F84 PICS communicating perfectly using one byte at a time, however I am in the dark as to how to use the command
serin 1,N1200,b10,b11,b12,b13 to receive multiple bytes.

How does the serin command know when the last byte is sent etc. What choices do I have?

What do you do in the case of less bytes are transmitted than there are variables allocated for in the serin command?

Some examples would be much appreciated.

Many thanks in advance,
Peter987

skimask
- 2nd January 2007, 14:31
Howdy
Can anyone give me some examples please in more detailed depth regarding the MELabs Pic Compiler command serin.

I have two 16F84 PICS communicating perfectly using one byte at a time, however I am in the dark as to how to use the command
serin 1,N1200,b10,b11,b12,b13 to receive multiple bytes.

How does the serin command know when the last byte is sent etc. What choices do I have?

What do you do in the case of less bytes are transmitted than there are variables allocated for in the serin command?

Some examples would be much appreciated.

Many thanks in advance,
Peter987

->How does the serin command know when the last byte is sent etc.
Depends on what you mean by 'last byte'. If you mean the last byte in a block of data, well, that's all up to you, a counter, a stop character, knowing that there are always X numbers of bytes in a block of data, anything you want. If you mean the last byte in a serin command with 4 variables, then it's when the 4th variable gets received.

->What do you do in the case of less bytes are transmitted than there are variables allocated for in the serin command?
Check out the 'timeout' option of the serin command as described in the PBP manual. Remember, serin, and PBP in general, are only as smart as you make them. If serin is written to get one byte, it's going to get one byte, if it's written to get 10 bytes, it's getting 10 bytes, unless you tell it to do something else, like timeout.

mister_e
- 2nd January 2007, 21:06
Howdy
Can anyone give me some examples please in more detailed depth regarding the MELabs Pic Compiler command serin.

Welcome on the forum Peter987. Well there's many code example in here, just type SERIN in the search engine. OK you'll have to spend few minutes/hours days, but you may found some interesting tips as well.



I have two 16F84 PICS communicating perfectly using one byte at a time, however I am in the dark as to how to use the command
serin 1,N1200,b10,b11,b12,b13 to receive multiple bytes.

How does the serin command know when the last byte is sent etc.

Well, serin will receive one byte at the time and will finish once B13 is received... even if it take 1 mSec, 1minute or 1 Hour to have it.



What choices do I have?

It always depend of what else you PIC will do, and what you need to do with those data... tell us more... don't be afraid, you won't break your keyboard by typing more infos ;)



What do you do in the case of less bytes are transmitted than there are variables allocated for in the serin command?
usually, i will cry or find a solution :D

As Skimask said, the Timeout option may work.

If it was me, i would choose another PIC with a USART for that... it open a wide range of better option than using a Timeout label.