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

printf: possible bug!?

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



Joined: 04 Jan 2005
Posts: 224

View user's profile Send private message

printf: possible bug!?
PostPosted: Fri Sep 19, 2008 2:30 am     Reply with quote

Hi,

I've been using USB-CDC. My current compiler version is 4.078 & 4.079
When running the code, the hyper terminal stalls on the following code section:
Code:

printf(usb_cdc_putc, "bla bla bla...\n\r");


Please note that usb_cdc_putc(char c) works fine. That's why I guess the problem is in the printf(...)

When compiled under previous version (4.057), everything works perfect. I'm not sure up to what version the code still works fine!!!

Any thoughts?


Last edited by PICoHolic on Fri Sep 19, 2008 4:03 am; edited 1 time in total
_Gerhard
Guest







PostPosted: Fri Sep 19, 2008 3:36 am     Reply with quote

I'm not a hot shot pic programmer but as far as i can see your problem lies in the %bla part. This is not a valid format in ccs. %u or %f is valid but the character folowing % needs to be a valid one that ccs recognise.
Wayne_



Joined: 10 Oct 2007
Posts: 681

View user's profile Send private message

PostPosted: Fri Sep 19, 2008 3:57 am     Reply with quote

% symbol when used in the C printf function is a special character. It denotes the type/format of the parameter it is displaying, e.g.

int a = 10;
printf("The value a = %u", a);

%u in this case tells the printf function that it is to display an unsigned int which is the first parameter passed, as it is the firs occurance of the % symbol.

To display an actual % symbol use %%.

So

int a = 1;
float b = 2.5;
char c = 'D';

printf("a = %u, b = %2f, c = %c, %%100 correct", a, b, c);

will show
a = 1, b = 2.5, c = D, %100 correct

See printf in the CCS help for more info.
PICoHolic



Joined: 04 Jan 2005
Posts: 224

View user's profile Send private message

PostPosted: Fri Sep 19, 2008 4:06 am     Reply with quote

Sorry, my mistake.
There's no % in the actual statement, just:
Code:

printf(usb_cdc_putc, "bla bla bla...\n\r");


It still fails...

Laughing
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

reversal of your fortune maybe
PostPosted: Tue Sep 30, 2008 9:14 pm     Reply with quote

try this:

reverse the \n\r to be \r\n
in your code, you are sending LF,CR , while standard usage is CR,LF and some versions of hyperterm are quite fussy about that order.
PICoHolic



Joined: 04 Jan 2005
Posts: 224

View user's profile Send private message

PostPosted: Wed Oct 01, 2008 1:02 am     Reply with quote

asmboy,

I dont think so. When compiled under previous version (4.057), everything works perfect!

Thanks
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Wed Oct 01, 2008 3:22 am     Reply with quote

Hello,

did you check, if it's a particular problem with printf() or just when sending several characters through USB without a delay? I guess, it's the latter.

I had a problem with V4.079 and CDC driver, where I got global interrupts disabled inadvertently after calls to usb_cdc_putc(). See
http://www.ccsinfo.com/forum/viewtopic.php?t=36100&highlight=cdc

To check, if it's possibly the same issue, just place an enable_interrupts(GLOBAL) after the printf statement.

Regards,
Frank
PICoHolic



Joined: 04 Jan 2005
Posts: 224

View user's profile Send private message

PostPosted: Wed Oct 01, 2008 3:44 am     Reply with quote

Hi FvM

It might be the case.
As I already mentioned, when compiled under previous version (4.057), everything works perfect.

Playing with workarounds is not a solution!

Thanks Smile
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Wed Oct 01, 2008 5:32 am     Reply with quote

Hello,
Quote:
Playing with workarounds is not a solution!


This view may be justified, on principle, but less helpful anyway, to my opinion. Playing with workarounds at least can help you in further clarifying the issue.

On the other hand, you are utilizing a CSC supplied library, that has been written prior to compiler V4. If you find issues, you may have revealed a problem of the driver as well as of the compiler. I wouldn't expect the issue to be handled by CCS quickly. Thus the answer depends also on the amount of time you are able to wait.

Regards,
Frank
PICoHolic



Joined: 04 Jan 2005
Posts: 224

View user's profile Send private message

PostPosted: Wed Oct 01, 2008 5:38 am     Reply with quote

Very Happy

I have already sent an email to support@ccsinfo.com

I can wait, no problem!

Thanks anyway Smile
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