|
|
View previous topic :: View next topic |
Author |
Message |
John Morley
Joined: 09 Aug 2004 Posts: 97
|
Serial Receive Problem... |
Posted: Mon Feb 26, 2007 9:52 pm |
|
|
Hi All,
Processor: 16F628A with 4MHz internal oscillator
Compiler: v3.249
I'm working on the design of an LCD display terminal for a industrial process controller. The display hangs on an RS-485 bus, and displays data sent by the controller. Up to 8 such displays can be accomodated on the bus. The controller sends addressed "packets" of data which the display terminal receives, decodes, and displays if there is an address match. The controller sends data in the format:
#CS DATA <CR>
I have an INT_RDA interrupt handler which captures the data, and looks for the '#' character to start writing to a receive buffer (buffer index set to 0), and the <CR> to set a flag to process the data string in MAIN. Everything is working great when I simulate the controller with a VB program, and send one command string at a time. Things fall apart, however, when I connect the display terminal to the controller, or send multiple command strings to the display terminal in quick succession using the VB program. The problem, in this instance, is that I seem to be receiving only the first 1 or 2 characters of the command string.
What I think is happening is this: After the <CR> is received, I set a flag (Rx_CMD_Ready = TRUE;) to let MAIN know that it needs to disable interrupts and process a command string. I think that a new character (or two) is being received before MAIN has a chance to disable interrupts (globally), and act upon the command string. The receipt of a new character resets the Rx buffer index, which puts my code in the weeds.......
Possible solutions include a faster clock speed, although this is not too attractive, and investigating the speed advantages of disabling INT_RDA alone vs. a global interrupt disable.
Any other thoughts?
Thanks,
John _________________ John Morley |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
John Morley
Joined: 09 Aug 2004 Posts: 97
|
|
Posted: Tue Feb 27, 2007 4:29 pm |
|
|
PCM,
OK, the problem appears to be more involved than I thought! I guess the "answer" is to use a circular buffer and never turn off the INT_RDA interrupt? I guess I need to do some searching, and reading on this one!
John _________________ John Morley |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|