This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

PWM LPC2919

First of all i would gratefull your help.
IÂ've to make a PWM on LPC2919 and IÂ've not find anything code example and the datasheet is very confuse.
Please help me,my work depends on it.

Parents
  • Code examples for a PWM will be hard to find, because there is no much code to write for it.
    All you need to do is to setup registers that belong to the PWM. They define the frequency and pulse width.
    I don't think it's so different to the 8051. There you just need to set the corresponding port to PWM mode and start it. You will also need an interrupt routine to serve the PCA interrupt and to reload the capture registers.

    Example setup for 8051:

    void v_PCA_Init(void)
    {
      IPL0 &= ~0x40;
      IPH0 &= ~0x40;            // set prio to 0
      CMOD = PCA_EN_ECF | PCA_SPEED;     // Enable PCA counter interrupt and fast speed fpca/2
      CR = 1; // run PCA
      EC = 1; // enable INT
    }
    

    Example ISR for 8051:

    void ISR_PCA(void) interrupt PCA_vektor using PCA_USING_REG
    {
      if (CF)
      {
        CCAP0H = ucReload;
      }
    }
    


    ucReload contains the reload value for the CCAP0L register and that defines the pulse width.
    This is for 8051, for ARM it should be similiar.

Reply
  • Code examples for a PWM will be hard to find, because there is no much code to write for it.
    All you need to do is to setup registers that belong to the PWM. They define the frequency and pulse width.
    I don't think it's so different to the 8051. There you just need to set the corresponding port to PWM mode and start it. You will also need an interrupt routine to serve the PCA interrupt and to reload the capture registers.

    Example setup for 8051:

    void v_PCA_Init(void)
    {
      IPL0 &= ~0x40;
      IPH0 &= ~0x40;            // set prio to 0
      CMOD = PCA_EN_ECF | PCA_SPEED;     // Enable PCA counter interrupt and fast speed fpca/2
      CR = 1; // run PCA
      EC = 1; // enable INT
    }
    

    Example ISR for 8051:

    void ISR_PCA(void) interrupt PCA_vektor using PCA_USING_REG
    {
      if (CF)
      {
        CCAP0H = ucReload;
      }
    }
    


    ucReload contains the reload value for the CCAP0L register and that defines the pulse width.
    This is for 8051, for ARM it should be similiar.

Children
No data