|
|
View previous topic :: View next topic |
Author |
Message |
Neumue Guest
|
Trouble with RS232 |
Posted: Thu Jul 10, 2003 5:16 am |
|
|
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 |
Posted: Thu Jul 10, 2003 8:01 am |
|
|
:=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 |
|
|
|
|
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
|