2005-01-13 10:17 PM
2005-01-12 08:47 AM
I use the 16bit-timer (ST72C215G) in output-compare-mode to generate different frequencies. For a wide range it is necessary to change the timer clock (CCbits in CR1) . Sometimes it works but sometimes the counter hangs ??, because after changing the CC bits no interrupts are generated.
Is a special sequence necessary ? i tried loading the whole CR1register and bset/bres the CCbits. I make the change between reading the current OC1Rvalue and writing the new OC1Rvalue(=current + fvalue). Is this correct ? Is it a fault of my programming or is it not allowed to change the CCbits after enabling interrupt ?2005-01-12 10:21 PM
Hi,
the only trap I know is the order you read or write timer registers. Please pay attention to the note 1. on page 46 of your datasheet. 1. After reading the ICiHR register, the transfer ofinput capture data is inhibited and ICFi will
never be set until the ICiLR register is also
read.See also Note 1 at page 53. It depends on the compiler if reading/writing the 2 registers is done in the right order. Cosmic does it all right. With Metrowerks (HiWare) you have to force reading first IC1HR and then IC1LR. Writing analogic. Never use int_value = IC1R; nor OC1R = int_value; if you are using the HiWare compiler to read/write the (2 bytes) integer value of a timer register. Hope it helps WoRo
2005-01-13 10:17 PM
Hi,
Thanks woro for your hints. I am programming in assembler and my program is similar to AN974. After further testing i must see, that the hang happens also after loading a new value to OC1R without changing the CCbits. After switching the unit off and on it works. After a few minutes switching on it works or not ?! Are there forbidden values for the OC registers ? Which register is better OC1R or OC2R ? What to do with the unused register ? Can the counter overflow disturb ?