Connect with us

PIC12LF1571 PWM Issues

Discussion in 'Microcontrollers, Programming and IoT' started by cl10Greg, Sep 26, 2016.

Scroll to continue with content
  1. cl10Greg

    cl10Greg

    25
    3
    Mar 20, 2014
    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?
     
  2. BobK

    BobK

    7,682
    1,688
    Jan 5, 2010
    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
     
    Harald Kapp likes this.
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-