View Single Post
Old 08-17-2013, 11:30 AM   #11 (permalink)
t vago
MPGuino Supporter
 
t vago's Avatar
 
Join Date: Oct 2010
Location: Cedar Rapids, IA
Posts: 1,766

The Karen-Mobile - '05 Dodge Magnum SXT
Team Dodge
90 day: 26.72 mpg (US)

Fiat Dakota - '00 Dodge Dakota SLT RWD Quad Cab
90 day: 16.67 mpg (US)

The Red Sled - '01 Dodge Durango SLT 4WD
90 day: 16.96 mpg (US)
Thanks: 799
Thanked 681 Times in 437 Posts
Quote:
Originally Posted by nickdigger View Post
Mine uses delay_us (20 bytes) and delay_ms (48 bytes), which calls milliseconds (48 bytes). Now that i look at it, i will probably merge milliseconds() into delay_ms(), since it basically just returns the timer count, and it is only ever called by delay_ms. (Edit: so far, no good. It's "so efficient" that the compiler wants to inline the new delay_ticks everywhere, costing me 300 extra bytes)
I suspect this is what happened to me the other night. The delay routines themselves were pretty small, but they added too much to the code. Oh, well...

Quote:
Originally Posted by nickdigger View Post
I had assumed you were already doing something like that. It might be trivial to add another "event" chain to the handler, for each output.
Yah, it actually is fairly trivial. My main reason for not doing so was because the overflow timer already has a lot on its plate. It does fuel injector timeout tracking, program delay tracking, loop tracking, loop CPU utilization tracking, VSS debouncing, button debouncing (and long-press detection), inactivity tracking, and wake-up tracking.

In the end, I decided to use the ADC interrupt, instead. In ADC freewheeling mode at a divider value of 128, the ADC interrupt runs about every 82 microseconds, instead of every 819.2 microseconds for the timer overflow (102 microseconds and 1024 microseconds for a 16 MHz AtMega). The LCD buffer will clear out that much faster, and the main overflow timer will not get bogged down as much. It also splits up the interrupt latency, as compared to having the timer overflow handle both its existing duties and handling the LCD buffer, so that VSS and injector pulses will be captured more reliably.

I ran some tests using the overflow timer, and CPU loading went down to 2.95%. Using the ADC freewheeling interrupt, I got that down to 2.46%. The other screens also showed improvement - the most heavily processor-intensive screens, oddly enough, were the big FE screens. Their utilization was at 9.51% with the overflow timer, and they went down to 2.95% with the ADC freewheeling interrupt.

The code now stands at 20230 bytes, and there are 1079 bytes of free RAM. I can live with that.

__________________
The Fiat Dakota


The Karen-mobile


The Red Sled
  Reply With Quote