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

printf only works with 2 blanks

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







printf only works with 2 blanks
PostPosted: Tue Jan 17, 2006 4:58 am     Reply with quote

Hello,
I work with MPLAB 7.22 and CCS-Compiler PCB/PCM 3.180. With the printf-comand I want to send some data with RS232 to the PC where I use a hyperterminal.
First my sourcecode:

#include <16F876.h>

#FUSES HS,NOWDT,NOLVP
#use delay(clock=4000000)
#USE RS232 (BAUD=9600, XMIT=PIN_C6, RCV=PIN_C7)

int i;

void main (void)
{
printf("HelloWorld");
}

In the terminalprogramm (either from Microsoft or HTerm) I don't receive the last two letters. There's only "HealloWor"

If I want to send an Integer, I also have to add two blanks so that it works:

printf("%d ",i) works...
printf("%d",i) doesnt't work at all...

Do you know this kind of problem?
carlosma



Joined: 24 Mar 2004
Posts: 53
Location: Portugal

View user's profile Send private message Send e-mail MSN Messenger

PostPosted: Tue Jan 17, 2006 5:19 am     Reply with quote

Hello

Do this:

Code:

void main (void)
{
printf("\r\nHelloWorld\r\n");
}

TIMT



Joined: 02 Sep 2005
Posts: 49
Location: Nottingham, UK

View user's profile Send private message

PostPosted: Tue Jan 17, 2006 5:50 am     Reply with quote

This might be of some help, it helped me. I had a similar problem :-


http://www.ccsinfo.com/forum/viewtopic.php?t=24313&highlight=
_________________
Tim
Jens
Guest







PostPosted: Tue Jan 17, 2006 6:16 am     Reply with quote

Thanks a lot, that is very interesting, and it works know!!
You just have to keep the controller busy until everything is send.

I use a "delay" for example know.
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Tue Jan 17, 2006 7:58 am     Reply with quote

I'll bet you are using a hardware UART with a 2 character buffer. Once the last two characters are loaded into the buffer the program "falls off the end of the code" and processing stops. Those last two characters are forever marooned in the buffer.
Try:
Code:

void main (void)
{
printf("HelloWorld");
while(1);
}

This will keep the processor running so the UART can crank out thoses last 2 characters.
_________________
The search for better is endless. Instead simply find very good and get the job done.
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