CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Serial Receive Problem...

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
John Morley



Joined: 09 Aug 2004
Posts: 97

View user's profile Send private message

Serial Receive Problem...
PostPosted: Mon Feb 26, 2007 9:52 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Feb 26, 2007 11:05 pm     Reply with quote

This thread is similar to your problem.
http://www.ccsinfo.com/forum/viewtopic.php?t=25425
John Morley



Joined: 09 Aug 2004
Posts: 97

View user's profile Send private message

PostPosted: Tue Feb 27, 2007 4:29 pm     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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