Quantcast
Channel: Microcontrollers
Viewing all articles
Browse latest Browse all 4923

Pic PWM programming in C, cant figure out how to change the duty cycle

$
0
0
I feel really stupid not being able to make this work.
I am using XC8 compiler, inside MPLAB.
I am using the Microchip Code Configurator.

My problem is, that i can get the PWM to start, and i can change its initial value by modifying the registers in the initialization file pwm.c
Code (Text):
  1.  
  2. //PWM1DCH 0;
  3.     PWM1DCH = 0x00;
  4.  
  5.      //PWM1DCL 200;
  6.     PWM1DCL = 200;
  7.  
  8.      //PWM1PRH 0;
  9.     PWM1PRH = 0x00;
  10.  
  11.      //PWM1PRL 255;
  12.     PWM1PRL = 0xFF;
  13.  
But, when I put the following into my while...

Pic PWM programming in C, cant figure out how to change the duty cycle

Viewing all articles
Browse latest Browse all 4923

Trending Articles