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 support@ccsinfo.com

Trouble with RS232

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







Trouble with RS232
PostPosted: Thu Jul 10, 2003 5:16 am     Reply with quote

Hello everybody,
I use a PIC16F876 with MPLAB 5.7, PCWH3.116 and ICE2000. For debbuging I want to send a single char on rs232 with #use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7, bits=8). Code in main is only: putc(lakkuaverage);
To see the result on my osci I have to send putc(lakkuaverage) three times! After the third codeline the osci triggers. Why this? Thanks in advance for every hint!

Werner
___________________________
This message was ported from CCS's old forum
Original Post ID: 144515841
R.J.Hamlett
Guest







Re: Trouble with RS232
PostPosted: Thu Jul 10, 2003 8:01 am     Reply with quote

:=Hello everybody,
:=I use a PIC16F876 with MPLAB 5.7, PCWH3.116 and ICE2000. For debbuging I want to send a single char on rs232 with #use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7, bits=8). Code in main is only: putc(lakkuaverage);
:=To see the result on my osci I have to send putc(lakkuaverage) three times! After the third codeline the osci triggers. Why this? Thanks in advance for every hint!
:=
:=Werner
The key line, is your statement that the 'code in main is only putc(lakkuaverage)'. The system, transfers the character to the hardware UART, and then goes to sleep. The CCS compiler, puts a hidden 'sleep' instruction, off the end of the main routine, to 'catch' the code, if it runs off the end. Now when the chip goes to sleep, the hardware UART is switched off, so the character doesn't get sent. The hardware UART, has the actual 'output' buffer, and one higher buffer level. Hence when you send the character three times, on the third transmission, the hardware buffers are full, and the code has to wait for the first character to send, before transferring the third character into the UART. This results in the first character being sent before the chip goes to sleep.
Hence, code as:

main() {
putc(lakkuaverage);
//This allows long enough for the character to send
delay_ms(2);
}

or as:

main() {
putc(lakkuaverage);
//This stops the code here, preventing the 'sleep'.
while(1) ;
}

Best Wishes
___________________________
This message was ported from CCS's old forum
Original Post ID: 144515844
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