We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hello
In the User Manual of C164CI is shown a way to use CAPCOM2 in MODE 1 to create PWM like signal (at P1H.4). (Two timer - Register(CC24) matches per period).
Therefore the value in register CC24 had to be updated while the timer(T7) runs upwards.
This means, when the first match(Interrupt) is recognized, CC24 had do be reloaded quickly with a new value, witch should be bigger then the old one. Then the timer runs upwards and the next match with the new value in CC24 occurs. And by this Interrupt(match) the value is set to the old value. And then the timer overflows and starts from 0x0000h.
How is it possible to program the interrupt to do this CC24 updates(switch of CC24 and an other register) ?
(use PEC?)
thanks.
Using CAPCOM2 in MODE 1 can create a PWM signal that has a 50% duty cycle with the half period based on the value of the CC24 and the timer period of T7 (or T8). Compare mode 1 allows several compare events within a single timer period (T7 or T8). An overflow of the allocated timer does not affect the associated output pin, nor does it disable or enable further compare events.
You can't use the PEC because you actually need to add the period to the existing CC24 value. You also need enough time to respond to the interrupt so how fast you can go depends on your system performance. T7 is free running with a reload of 0 so T7 provides the prescaler for CC24.
void CC2_viCC24(void) interrupt 0x38 { CC24 += myPeriod; }
The disassembly would look like
ADD CC24,DPP2:0x2200 ; myPeriod is a near variable accessed by DPP2
How this helps. -Chris
OK. I use C164CI, is 0x38 the CC24 interrupt adress ? I dont understand how to read this entry of datasheet. ( CC24IO, CC24IE ...)
And the Vector table is generated automatically ? (in your sample)
But i use a Operating System, and so i think i had to change the vector table by my owne. How is this possible in a function call to a C routine ?
And O.K in first cycle i can add a value to CC24, but i think i had to reset or sub. a value bevore the timer runns over.
thank you.
0x38 is the interrupt number and is located at 0x0000E0. Using the interrupt frame the Keil compiler recognizes that you want to create an entry in the vector table at this location and basically jump to this routine. By default the linker will generate a vector table (and if you add them to your code) unless you specify otherwise (NOVT).
CC24IO is the actual pin name CC24IE is the interrupt enable bit in the interrupt control register (CC24IC).
Depending on the operating system you are using it may require all interrupts to be dispatched via the OS. If this is your case you should have documentation on how to chain your function call to this.
You need to know when to change the CC24 register and realize you are relying on the interrupt latency to perform the update. You need to know your system behavior to know if you can do this or not.
I am not sure of your question, to add the first time but not after that? This makes me think you didn't understand (or I didn't make it clear) on how you are generating the PWM on the CC24 pin in the first place. As long as you have the timer that is linked to CC24 (in your case T7) with a reload of zero. You only have to add half of the period to the previous CC24 value since every compare event on CC24 will toggle the output pin. You don't care what the actual value of the CC24 register is as you are always adding an offset every time you get an interrupt. This also assumes the PWM period is less than the T7 period.