jmofthenorth
Joined: 27 Sep 2006 Posts: 11 Location: ITHACA,NY
|
Questions on RS232 Receiving |
Posted: Sun Oct 01, 2006 9:05 pm |
|
|
Hi,
I'm new to the "PIC WORLD" and so these questions may seem a little foolish, but any insight would be greatly appreciated. I'm using the USB Protyping board (with a 18F4550 PIC) to test out RS232 communication with a microscope stage. I am able to transmit commands to the stage without a problem, however, after telling the stange controller to, for example, go to position (x,y), the controller is supposed to return 5 bytes upon the stage having reached that position. I am having difficulty recieving these status bytes. The code that I have been playing around with looks like this...
Code: |
//code here telling the stage to go to (x,y)
while(!kbhit()){};
for(int8 i = 1; i<=5; i++)
getc();
|
Following this I try to send more commands to the stage controller, but for some reason the system hangs. Do I need to worry about the fact that the pic set up has no RTS/CTS lines?
Also, I think i read somewhere that the buffer can only store 3 bytes, and so I am worried that 5 bytes coming in rapidly is somehow crashing the system. Is this possible?
Thanks for any help, it's much appreciated. |
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Oct 02, 2006 1:47 am |
|
|
getc() will wait for a kbhit(). You don't need to check it first.
If you're worried about over-running the hardware receive fifo,
the standard method is to use an interrupt-driven software receive fifo.
See the CCS example file, EX_SISR.C.
It's in this folder: c:\Program Files\Picc\Examples |
|