Maker Pro
Maker Pro

PIC12LF1571 PWM Issues

cl10Greg

Mar 20, 2014
25
Joined
Mar 20, 2014
Messages
25
Hello,

I am working on a very basic program to map a potentiometer to a PWM output. I am designing this in stages so right now I am just trying to make sure the PWM output works but I am running into a weird problem. I use the MCC to generate the basic code for the PWM3 pin. I have the micro and the MCLR pull up populated and I am powering the circuit with a PICKIT 3. My while loop is literally on doing this
Code:
PWM3_DutyCycleSet(pwmDuty);
PWM3_LoadBufferSet();

pwmDuty is a unit16_t and this code works fine as long as pwmDuty is <= 0x000F but once I go over that number the signal is always high and there is no PWM. I am watching it with my scope at home and its the weirdest thing. I am guessing its just a basic setting but I can't seem to put my finger on what one. Here are some other settings:
  • INTOSC
  • WDT - OFF, PWRTE - OFF, BOREN - ON,
  • PWM3
    • Enabled, enable output pin
    • Active hi, standard pwm
    • CLK - INTOSC, Prescalar - 16
    • Independent run mode
    • No load buffer on trigger
    • Period - 250us, Phase - 0, offset - 250uS
    • No interrupts enabled

Thoughts?
 

BobK

Jan 5, 2010
7,682
Joined
Jan 5, 2010
Messages
7,682
What have you put in the PR2 register? This register determines how high to count before the counter is reset. The duty cycle can be no higher than the value in the PR2 register, so it sounds like you have put 0x10 in there, which means the highest meaningful duty cycle is 0xF.

Bob
 
Top