View Single Post
Old 06-04-2009, 07:12 PM   #1539 (permalink)
dcb
needs more cowbell
 
dcb's Avatar
 
Join Date: Feb 2008
Location:
Posts: 5,038

pimp mobile - '81 suzuki gs 250 t
90 day: 96.29 mpg (US)

schnitzel - '01 Volkswagen Golf TDI
90 day: 53.56 mpg (US)
Thanks: 158
Thanked 267 Times in 210 Posts
Matt does have a point, but the solution is complicated enough that I would rather just leave out uart for the moment. Note, there is a program to watch the avr simulator uart: http://www.helmix.at/hapsim/

referenced from here:
http://www.google.com/url?sa=t&sourc...wSsj96RLmjuSNA

I can outline it but cant get into too much detail at the moment:

You need a way to stream characters from the main loop out the uart.

Not only that but you need to possibly offload the processing of a snapshot of the ecu so that it can be pretty printed out the uart and not weigh down the pwm change period too much.

So in main, you check a global flag "printit"
if printit not set then load some globals with the values to print (raw current, throttle,temp,overcurrent, any accumulators) and set printit = true.

in the timer isr, you allocate some time in the distributor (or the distributor calls another distributor) if printit is set to call small enough parts of the conversion to not overrun the timer isr. like functions for each step in the math conversion and for each step in the string conversion and again to send each character out the uart one by one. And finally it resets printit.


Or just bang it out and see how long it takes in execution time

edit: hint: an array of function pointers can be handy thing.
__________________
WINDMILLS DO NOT WORK THAT WAY!!!

Last edited by dcb; 06-04-2009 at 07:41 PM..
  Reply With Quote