Home Forums Microcontrollers PIC Microcontroller Delay in PWM

Tagged: ,

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #11584
    Shubham
    Participant

    Hi,

    I wanted to generate two PWM waves using PIC16f877A. the second wave should have a delay of 10uS from the first one. can you tell me how to do this. Also can we generate 4 waves simultaneously using PIC 16f877A?

    #11585
    Ligo George
    Keymaster

    You can do it by using interrupts. The following Microchip application note will give you the idea.

    http://ww1.microchip.com/downloads/en/AppNotes/00843a.pdf

     

    #11613
    Shubham
    Participant

    Hi Ligo,
    I have generated these two waves having different duty cycle.. but i want to general a delay of 10us between the start time of the two waves. i have tried to do it by delay function but it is not working. can you suggest me a method. the link you provided was not useful as it was difficult to interpret. can you help me by looking out this code?

    void main(void)
    {
      TRISC2_bit=0;
      PORTC=0;
      PWM1_Init(8000);
      PWM2_Init(8000);
      while(1)
      {
        PWM1_Start();
        PWM1_Set_Duty(2.04);
        Delay_us(10);
        PWM2_Start();
        PWM2_Set_Duty(32.64);
      }
    }
    
    #11625
    Ligo George
    Keymaster

    The link that I provided you is what you need. You need to enable interrupts to generate Software PWM. That microchip application note clearly describes how to generate software pwm. You can easily insert delay in software pwm.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.
>