This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

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

    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.

Reply
  • Hello

    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.

Children
  • 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.