We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
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
Don't you find "not working" a very, very, very, short description of the behavior of your program?
Next thing. It is quite common to describe what you _think_ the PWM module should do. We see what register values you play with but how can we say if you get what you should when we don't know what _you_ thought the register values does?
WELL that is the best way i cld put it really. While running the debugger All the registers take the value as per the program. Even the output on the logic analyzer of keil shows the expected result. Proper timings and everything. But the same program refuses to work on the hardware.All the PWM pins r held high with no change while the keil example program works just fine with a proper PWM output. As i do not have a JTAG i cant really tell what is happening in the hardware. So i wanted to know if there is something i've overlooked in the program.
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!!!