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
  • Mr.Erik,

    SetDC(dc); is the function that sets the amount of the duty cycle in % and Mr.Chris explained that before..
    I am not looking for the accuracy of my PWM signal.. (Thanks to this forum) I already generated the PWM signal and its accuracy is accepted for me..

    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..
    The program is the same as of Mr. Chris Wunderlich , but with making a call outside the main()

    This happens with me,, and I wrote this to help others "if they are beginner as much as me"

    Thank you all..thanks alot

    your student,Ashraf

Reply
  • Mr.Erik,

    SetDC(dc); is the function that sets the amount of the duty cycle in % and Mr.Chris explained that before..
    I am not looking for the accuracy of my PWM signal.. (Thanks to this forum) I already generated the PWM signal and its accuracy is accepted for me..

    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..
    The program is the same as of Mr. Chris Wunderlich , but with making a call outside the main()

    This happens with me,, and I wrote this to help others "if they are beginner as much as me"

    Thank you all..thanks alot

    your student,Ashraf

Children