Quote:
Originally Posted by MPaulHolmes
I could use a different timer (say timer2) with a different prescaler so that its interrupt would be called with a frequency of let's say 2kHz, but I would perhaps lose the measurement of the current at the exact same point on the pwm waveform. However, since 16kHz is a multiple of 2kHz, maybe it would be at about the same point on every 8th pwm waveform??? I'm not sure though. That would be really really nice later if I needed to do other stuff that took longer too, like sending data through the usart while driving. The nice thing is, if I try it out, go take a drive, and everything feels perfect, then it doesn't really matter too much I guess.
|
Now, remember Paul, you only want to put real-time critical processing in the ISRs. Functions like reading and writing through the UART should be done in the main loop. Data can be accumulated within the ISR (counters, fault codes, etc) but it is not critical to send and receive serial data, so let the main loop perform those kind of tasks.
When serial I/O is implemented, then you will be able to adjust those constants on the fly to further tune your response times without having to recompile/reinstall/re-feedthebaby thus shortening that development cycle big time.
Your code is looking snappin' turtle good.
Eric