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.
in the simulation program running smoothly, but when the diwnload to the target is not working as it should. .
The following source code
#include <LPC214x.H>
void delay(unsigned int lama) { /* My PCLK of Timer0 is 12Mhz */ unsigned int d; for(d=0;d<lama;d++){ T0PR = 9999; // Prescale Register = 9999 T0MR0 = 1200; // Match Register = 900 T0MCR = 0x00000004; // Stop on MR0: the TC and PC will be stopped // and TCR[0] will be set to 0 if MR0 matches the TC. T0TCR = 0x02; // Counter Reset T0TCR = 0x01; // Counter Enable while(T0TC != T0MR0); T0TC = 0; // TC kembali ke 0 } }
void delay_ms(unsigned int lama_1) { /* My PCLK of Timer0 is 12Mhz */ unsigned int d; for(d=0;d<lama_1;d++){ T0PR = 999; // Prescale Register = 9999 T0MR0 = 12; // Match Register = 900 T0MCR = 0x00000004; // Stop on MR0: the TC and PC will be stopped // and TCR[0] will be set to 0 if MR0 matches the TC. T0TCR = 0x02; // Counter Reset T0TCR = 0x01; // Counter Enable while(T0TC != T0MR0); T0TC = 0; // TC kembali ke 0 }
}
void delay_ns(unsigned int lama_2) { /* My PCLK of Timer0 is 12Mhz */ unsigned int d; for(d=0;d<lama_2;d++){ T0PR = 1; // Prescale Register = 9999 T0MR0 = 12; // Match Register = 900 T0MCR = 0x00000004; // Stop on MR0: the TC and PC will be stopped // and TCR[0] will be set to 0 if MR0 matches the TC. T0TCR = 0x02; // Counter Reset T0TCR = 0x01; // Counter Enable while(T0TC != T0MR0); T0TC = 0; // TC kembali ke 0 }
int main(void) {
unsigned int i; IODIR1 = 0x00FF0000; // set all ports to output
while(1) {
for(i=0;i<4;i++){ IOSET1 = 0x00010000; //set output pins delay_ns(200); IOCLR1 = 0x00010000; //clear output pins delay_ns(200); }
delay_ns(19800);
} }
please enlightenment?!
okeh I apologize in advance. . .
I will not repeat again. . .
So did you understand the problems with your code?