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 error not working in Application

HI,
I've been using the PWM module to generate a timing signal for my project using the LPC 2129 the problem is that while the simualtion for the same circuit is flawless it refuses to work in the hardware.
Example codes on the other hand work fine but my timing code refuses to work.
I've put up the code as well pls help

#include <LPC21XX.H>




//void delay(void);
//int del;
int main(void)

{
//unsigned int delay;

PINSEL0 = 0x000A8002;   //Enable pins PWM2

PWMPR    = 0x00000000;  //Load prescaler

PWMPCR = 0x00005650;            //PWM channel 4&6 double edge control, 1,2 single, output enabled
    PWMMCR = 0x00010000;        //On match with timer 5 reset the counter

    PWMMR0 = 0x0000004B;
    PWMMR1 = 0x000000E1;
    PWMMR2 = 0x00000195;
    PWMMR3 = 0x000000C3;
    PWMMR4 = 0x000000E1;
    PWMMR5 = 0X000003FF;
    PWMMR6 = 0x0000004C;
    PWMEMR = 0x00000280;//copied this from the example removing it doesnt make a difference

    PWMLER = 0x0000007F;
    PWMTCR = 0x00000002;
    PWMTCR = 0x00000009;// enable timer n pwm



while(1)                                // main loop
{
;

}



}

Thanks in advance

Parents
  • FYI. I believe the probem was with the MR0 register holding a much smaller value than the single edge registers.
    I've managed to solve the problem by defining the total cycle duration in the MR0 register as opposed to the definition in the program where the MR0 had a much smaller value.
    The problem is that the cycle has to run once before all the signals get a chance to initialise which was acceptable for the application.
    The funny thing is on the debugger both the programs result in the same output while only one works on the hardware!!!

Reply
  • FYI. I believe the probem was with the MR0 register holding a much smaller value than the single edge registers.
    I've managed to solve the problem by defining the total cycle duration in the MR0 register as opposed to the definition in the program where the MR0 had a much smaller value.
    The problem is that the cycle has to run once before all the signals get a chance to initialise which was acceptable for the application.
    The funny thing is on the debugger both the programs result in the same output while only one works on the hardware!!!

Children
No data