Generation of PWM wave six - PIC18f4431


Closed Thread
Results 1 to 4 of 4
  1. #1
    Salatiel_lobato's Avatar
    Salatiel_lobato Guest

    Default Generation of PWM wave six - PIC18f4431

    Hello everyone!

    I am faced with a problem with the PWM wave generation using the PIC18F4431.
    I need to generate six PWM signals with fixed frequency and duty cycle.
    I work in C but I hope you can help me, I'm very desperate.
    Below is my code:


    void main ()
    {
    PTCON0 = 0b00000000 / / Postscaler 1:1, 1:1 prescaler, count up
    PWMCON0 = 0b01000000 / / Enable PWM0, 1, 2, 3, 4 and 5 in order complemetar
    PTPERH = 0, / / ​​storing the value 199 in PTPER
    PTPERL = 199 / / that generates a PWM signal of 25 KHz
    PDC0H = 148>> 6 / / Stores the most significant bit of 75 in PDC0H
    PDC0L = 148 <<2 / / Stores the six least significant bits of 75 in PDC0L and adds two more
    / / Bits to the right to enter the first clock cycle, 75% Duty Cycle
    PDC1H = 100>> 6;
    PDC1L = 100 <<2 / / Stores the six least significant bits 50 in PDC0L and adds two more
    / / Bits to the right to enter the first clock cycle, 50% Duty Cycle
    PDC2H = 50>> 6;
    PDC2L = 50 <<2 / / Stores the 6 bits of 25 in PDC0L and adds two more
    / / Bits to the right to enter the first clock cycle, 25% Duty Cycle

    PTCON1.PTEN = 1 / / Starts the generation of signals
    while (1);
    }

    I can not see what's wrong with this code.
    When I simulate this program (Proteus) simulates it with no problem, but when I try to implement it in practice did not yield any signal in the PWM outputs. One thing sure is that my practical design of the circuit has no way to be wrong.
    Well I tried to use 4 PWM signals and it worked. This does not work when I use those 6.
    The PIC18f4431 can generate waves up to 4 PWM and four additional, what I want is 3 plus 3 additional signs!

    PLEASE really need help.

    I hope answers.
    Thanks

  2. #2
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default Re: Generation of PWM wave six - PIC18f4431

    You really should consider posting your question on a forum for the C compiler you're using. This forum is for the Microengineering Labs BASIC compiler.

    If you decide to try PBP, here's a thread that you might find helpful;
    http://www.picbasic.co.uk/forum/showthread.php?t=7095
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  3. #3
    Join Date
    May 2007
    Posts
    604


    Did you find this post helpful? Yes | No

    Default Re: Generation of PWM wave six - PIC18f4431

    Why pay for overpriced toys when you can have
    professional grade tools for FREE!!!

  4. #4
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default Re: Generation of PWM wave six - PIC18f4431

    No. He missed the boat on both posts there as well. One example was done with MikroC, and a second with CCS C, so he's still not getting help from either C compilers forum...;o)
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts