Writing to match register while the timer is running
2004-07-13 by johnthomasedwardtimm
I have created a frequency generator using timer1. I have had
problems loading the match register on the fly. Sometimes I start
losing interrupts. I have tried simply disabling the timer when I do
a reload, but it doesn't seem to help. What does work is something
like this:
DWORD dwMatch;
dwMatch = ...; // calculate new match value
if (dwMatch != T1MR0) {
T1TCR = 2; // disable/reset timer1
T1MR0 = dwMatch; // reload the match register
}
T1TCR = 1; // enable timer1
The key is the "reset" of timer1 before the reload. Does anybody
know why this is the case? Is there a better way to accomplish this?
Thanks,
JT