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

Error Serial Communication!!

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







Error Serial Communication!!
PostPosted: Tue Dec 16, 2008 2:40 am     Reply with quote

MPLAB 8.10 + CCS3.203 + PIC16F877

Hi, I have a problem about RS232 serial communication
I have sucessed to write internal eeprom. but after write I can't use RS232 communication.

Code:
char Control_EEPROM(){

   write_eeprom(0x00, serial_Data[3]);
   delay_ms(10);
   write_eeprom(0x01, serial_Data[2]);
   delay_ms(10);
   
   serial_Data[0] = RPY_ACK;


   
   return(1);
}   
Ttelmah
Guest







PostPosted: Tue Dec 16, 2008 3:29 am     Reply with quote

You don't say what is wrong with the serial, but my 'guess' would be that it is going into an overrun error, and no longer receiving.
First comment, you don't need the delays. The write eeprom function already waits for the write to complete. This takes something between 2, and 4mSec, depending on the PIC involved.
Now, you write two bytes to the EEPROM, which with the delays present, will then take possible 28mSec. Assuming your serial is 9600bps, this could be 10 characters arriving. Now the internal buffer in the UART, can handle just a couple of characters. So the UART, goes into an 'overrun' state, _and stops working for receive_.
You need to do two things:
First, add the kyword 'ERRORS' to your RS232 declaration. This adds code to automatically clear this condition.
Second (and more importantly really), you need to _stop_ the serial transmission, while you are writing to the EEPROM. Depending on your serial layout, and the code involved, choices are:
1) Add a simple delay at the transmitting end, after you have send the characters that trigger the EEPROM write.
2) Add flow control to your serial communication.

Best Wishes
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