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

C515C + PWM

Hi every body, and happy new year to all keil users ;)
I am using the C515C with keil v2.39,
I want to generate a PWM signal using one of the pins 1.0,1.1,1.2 or 1.3,
I read the manual, put I found it difficult, because I have to configure different things.
Like the following parameters:

T2CON |= 0x10; ET2=1; EXEN2=0; CRCL = 0x22; CRCH = 0xFF; EX3=0; CCL1 = 0xFF; CCH1 = 0x22; EX4=0; CCL2 = 0x00; CCH2 = 0x00; EX5=0; CCL3 = 0x000; CCH3 = 0x000; EX6=0; CCEN = 0xAA;

What I know, is that we have to use compare mode 0.

But how can I set T2 to be ready for all things, and how I change the duty cycle while from the program results...

Is there any ready function that has one input which is the duty cycle?

And thank you for your time.

Parents
  • Now it is working "get out of main()", I made a function called pwm() out of the main and I call it when I need to change the duty cycle..

    read the whole thing!!!!!

    get out of main() use the T2 interrupt ISR

    you will lose all precision etc the moment you start going beyond your simple "test code"

    Erik

Reply
  • Now it is working "get out of main()", I made a function called pwm() out of the main and I call it when I need to change the duty cycle..

    read the whole thing!!!!!

    get out of main() use the T2 interrupt ISR

    you will lose all precision etc the moment you start going beyond your simple "test code"

    Erik

Children