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

Not working

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?!

Parents
  • "sorry in advance. . . I'm just learning to program the microcontroller. . . so forgive if you are not pleased."

    So.
    1) Have you walked through my individual items in my first post? Your response?

    2) Is it relevant if you have just started to learn programming microcontrollers? In how many other areas of the world would "not working" be a good description of a problem? Wouldn't you agree that if you are stuck, you are much more likely to get good answers if you tell where you are stuck, and what you have tried. What you expected to happen, and what really happened? What you have thought could be causing the problem, and how you have tried to check if it is so?

Reply
  • "sorry in advance. . . I'm just learning to program the microcontroller. . . so forgive if you are not pleased."

    So.
    1) Have you walked through my individual items in my first post? Your response?

    2) Is it relevant if you have just started to learn programming microcontrollers? In how many other areas of the world would "not working" be a good description of a problem? Wouldn't you agree that if you are stuck, you are much more likely to get good answers if you tell where you are stuck, and what you have tried. What you expected to happen, and what really happened? What you have thought could be causing the problem, and how you have tried to check if it is so?

Children