PWM Generation with CAPCOM2 in Mode1

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.

Parents
  • 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

Reply
  • 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

Children
More questions in this forum