Log in

View Full Version : printf causes programs to not run


jasonpeinko
16-01-2008, 18:26
I was trying to setup a printf command in user routines fast, but when i upload it to the robot it gets stuck in program mode,

I used Jifi to upload it,

i also use mplab running under wine to compile.

psy_wombats
16-01-2008, 18:54
The fast loop, I believe, can't support the printf function, simply because it is a very fast loop. The printf takes a lot of time (relaying info through your serial) so the print is being called way too fast for it to finish, and causes the program error.

Should be able to fix by calling only by a timer interrupt, or when a loop count is divisible by fifty, (to call every fiftieth loop or something), or maybe use the slow loop?

kaszeta
16-01-2008, 19:02
The fast loop, I believe, can't support the printf function, simply because it is a very fast loop. The printf takes a lot of time (relaying info through your serial) so the print is being called way too fast for it to finish, and causes the program error.

I've done this successfully (when debugging shaft encoders), but wouldn't recommend it. It's very easy to crash things this way.


Should be able to fix by calling only by a timer interrupt, or when a loop count is divisible by fifty, (to call every fiftieth loop or something), or maybe use the slow loop?

This is of course a much better solution.

gizzlyMIKE000
16-01-2008, 19:03
how do i post a forum?

TubaMorg
16-01-2008, 19:13
how do i post a forum?

Do you mean how do you post a reply? Well you just did, obviously. If you mean that you would like to start a new thread, then look for the appropriate topic and look for "start a new thread"

jasonpeinko
17-01-2008, 17:40
i am confused on how to get this to work,

i have to it only is supost to show every 1000000 times the code runs.

jasonpeinko
17-01-2008, 18:54
tomorrow i will try using the default prgoram with the controller to see if it work with printf, could the problem be that my computer is not being able to handle the printf when it recieves it back?