Hello, I wrote a bootloader that works just fine in doing IAP, jumping to application etc. I do have one big problem though: the bootloader uses timer 1 to drive a LED. unless I disable that timer, the application usage of timer 1 is incorrect, namely: the IR flag is set only very long after the program is started by the bootloader. the processor clock settings are identical, and the bootloader only starts the timer, without any changes to its configuration. what can be going on here?
Maybe the application is reinitializing the clock just when the timer passes its "exact match", resulting in the match to be lost.
Then, you maybe have to wait for a full 2^32 ticks until the timer once more reaches the match condition until the application sees the first match interrupt.
Interrupt handover of a enabled device between a boot loader and an application is really problematic and very much chip-specific.
thanks Per; I thought it might something like that. executing
T1TCR = 2 ;
(holding the timer in reset until the application reconfigures it) seems to solve the problem. this pqrticular timer is free running, no interrupts involved (but they are remapped, of course).
I have to get used to 32 bit counters; the STR9's counters are 16 bit!