

That also restricts the maximum resolution of the duty cycle to a single timer count. This means that the maximum resolution of the the timer is a single count. If your timer 2 prescalar is set to 1 then the timer is running as fast as possible. Nothing in the processor can happen any faster then the provided clock. With some trickery timer 2 (the timer for PWM) and the duty cycle supports up to 10 bits. You can only set a duty cycle between 0-65. The duty cycle your trying to set is 255.

The duty cycle is a fraction of the period. Only use xc.hĪlso your overloading your duty cycle. Unsigned int voltage = ADRESL | (ADRESH start a new PWM cycleĭon't use #include and #include at the same time. #define CHECK_BIT(var,pos) ((var) & (1> 2

What could the problem be?ĮDIT: I am following this procedure which is written in the PIC12F683 datasheet, but I am either not doing it right or there's something else I need to do. Instead I get a 5kHz "weird" PWM signal such that when I set the duty to be 255, which should be maximum, I get this 5kHz wave. According to my calculations I should get an 8 bit 20kHz PWM at GPIO2, but that does not happen. I'm trying to make PWM to work on the PIC12F683.
