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.
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
T0 and T2 are running from interrupts
fine, but that is not the issue
if the change of state of a PWM output is handled in the main erratic performance WILL (eventually) happen.
'eventually' because it may not happen in a small 'demo' that does nothing but PWM, but such a 'demo' will not be the final code.