|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Printf acting flaky
I'm having a few issues with calling printf - it sometimes leaves the format string (like %d) in the output. Something like this:
joyx = 127 joyx = 127 joyx = 127 joyx = %d joyx = 127 etc... It seems to be random. Also, it doesn't seem to like to have information pushed at it multiple times through the main loop. Even though I push a \r\n at it (although the same thing happens with either \r or \n) it overwrites the last bit of output. Is there a buffer or something that can hold a limited amount of data? I never experienced any problems like this last year - did something change? I'm sorry if this seems like a trivial problem - but it's driving me absolutely insane. |
|
#2
|
|||||
|
|||||
|
Re: Printf acting flaky
I had similar problems last year with printf outputs (using printf_lib). This began after I started using Kevin Watson's tracker code.
The problem was solved by modifying a #pragma statement to cause the compiler to save more processor context prior to servicing an interrupt (the trackers used interrupts to process the IR beacons). Are you using interrupts? Like wheel encoders? -norm |
|
#3
|
||||
|
||||
|
Re: Printf acting flaky
What additional contexts? Right now I'm saving PROD, MATH_DATA, and .tmpdata .
|
|
#4
|
|||
|
|||
|
Re: Printf acting flaky
I'm using a few timer interrupts currently (although not TMR0) and will be using digital input interrupts too.
What else should I save? |
|
#5
|
||||||
|
||||||
|
Re: Printf acting flaky
Also, how often are you printing stuff, and how many characters. What is your interrupt rate? What serial drivers are you using?
|
|
#6
|
|||
|
|||
|
Re: Printf acting flaky
I'm printing stuff once every 15 data packets (26.2*15=393 so about every .4 seconds) and it's about twenty-ish characters long. The only interrupt firing right now is the timer 1 overflow interrupt. I'm not using the TTL serial port, and I haven't fiddled with whatever code comes as default for printf.
|
|
#7
|
|||||
|
|||||
|
Re: Printf acting flaky
Quote:
Is this from a single printf statement or do you have two identical printf statements printing results in separate spots? The simplest explaination would be two similar printf's, but one with a typo like: printf("joyx = %d\r"); |
|
#8
|
|||
|
|||
|
Re: Printf acting flaky
Same printf.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Printf symbol undefined? Help | schenkin | Programming | 3 | 08-02-2005 16:14 |
| printf problem | miketwalker | Programming | 7 | 31-01-2005 13:19 |
| Default Code and printf | WilsonDJ00 | Programming | 2 | 22-01-2005 16:39 |
| Anyone with a replacement Printf? | Larry Barello | Programming | 5 | 19-03-2004 02:20 |
| Printf warning during compile? | actorindp | Programming | 4 | 20-02-2004 17:02 |