In Timer A, I just use CCR0, so I have not faced this problem before. To make
things clear I want to generate both frequencies (1Hz and 1KHz) from Timer B
only.
Clearing CCIFG as you said, did not work. I did some other test but I have not
concluded anything. Can you give me a light? ** i changed the values to make
better to understand
For CCR02000 and CCR1 = 4000
FIRST CYCLE:
- CCR0 working (goes to 32000)
- CCR1 working (goes to 36000)
SECOND CYCLE AND SO ON:
- CCRO = working (continue going to 32000)
- CCR1 = NOT working (stopped)
CODE:
Timer B question
Started by ●April 20, 2011
Reply by ●April 22, 20112011-04-22
Reply by ●April 22, 20112011-04-22
yOU OBVIOUSLY DIDN'T READ THE ENTIRE THING. each TIME THE 1KhZ Interrupt
occurs you must add 32 (or whatever number of clock ticks is equal to
1kHz) to the CCRx register. then you must account for the fact that the
timer is being limited in its range to 32768 (when you use the 'count
to' mode, this is what the mask is for. then you must clear the
interrupt flag, except for CCRx0 which auto clears the flag. There are
so many simple ways to do this. My code should be very clear, there is
nothing complicated about it.
Al
occurs you must add 32 (or whatever number of clock ticks is equal to
1kHz) to the CCRx register. then you must account for the fact that the
timer is being limited in its range to 32768 (when you use the 'count
to' mode, this is what the mask is for. then you must clear the
interrupt flag, except for CCRx0 which auto clears the flag. There are
so many simple ways to do this. My code should be very clear, there is
nothing complicated about it.
Al