View previous topic :: View next topic |
Author |
Message |
PICoHolic
Joined: 04 Jan 2005 Posts: 224
|
printf: possible bug!? |
Posted: Fri Sep 19, 2008 2:30 am |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
_Gerhard Guest
|
|
Posted: Fri Sep 19, 2008 3:36 am |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
Wayne_
Joined: 10 Oct 2007 Posts: 681
|
|
Posted: Fri Sep 19, 2008 3:57 am |
|
|
% 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. |
|
![](templates/subSilver/images/spacer.gif) |
PICoHolic
Joined: 04 Jan 2005 Posts: 224
|
|
Posted: Fri Sep 19, 2008 4:06 am |
|
|
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](images/smiles/icon_lol.gif) |
|
![](templates/subSilver/images/spacer.gif) |
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
reversal of your fortune maybe |
Posted: Tue Sep 30, 2008 9:14 pm |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
PICoHolic
Joined: 04 Jan 2005 Posts: 224
|
|
Posted: Wed Oct 01, 2008 1:02 am |
|
|
asmboy,
I dont think so. When compiled under previous version (4.057), everything works perfect!
Thanks |
|
![](templates/subSilver/images/spacer.gif) |
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Wed Oct 01, 2008 3:22 am |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
PICoHolic
Joined: 04 Jan 2005 Posts: 224
|
|
Posted: Wed Oct 01, 2008 3:44 am |
|
|
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](images/smiles/icon_smile.gif) |
|
![](templates/subSilver/images/spacer.gif) |
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Wed Oct 01, 2008 5:32 am |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
PICoHolic
Joined: 04 Jan 2005 Posts: 224
|
|
Posted: Wed Oct 01, 2008 5:38 am |
|
|
I have already sent an email to support@ccsinfo.com
I can wait, no problem!
Thanks anyway ![Smile](images/smiles/icon_smile.gif) |
|
![](templates/subSilver/images/spacer.gif) |
|