Ravindrakant Jha
Junior Member level 2
I am trying to blink an LED on p0.1 on LPC2138 using PWM,its T-on 20 % but led is not even work.
The code is not showing output.
The code is not showing output.
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 #include <LPC213X.H> #define PRESCALE 2999 void initPWM() { PINSEL0|=(1<<10);//pin select PWMPCR=0x00;//by default sigle edge output PWMPR=PRESCALE-1;//pre scaler PWMMR0=20000;//20ms PWMMR1=1000; //10ms PWMMCR|=(1<<1);//RESET PWMTC PWMLER|=(1<<1);//latch enable PWMPCR|=(1<<9);//PWM1 output enabled PWMTCR|=(1<<1);//reset pwm PWMTCR|=(1<<0)|(1<<3); } int main() { initPWM(); while(1) { if( !((IO0PIN) & (1<<1)) ) { PWMMR1=2000; PWMLER|=(1<<1); } } }
Last edited: