i have problem with the led blinking. I using the exmaple program given by keil using uVision3. When i run the program, the LED on the development board didnt blink, it just stay on! wat should i do?
thanks!
my code:
/* BLINKY.C - LED Flasher for the Keil MCBx51 Evaluation Board with 80C51 device*/ #include <REG8252.H> // When you have enabled the option Stop Program Execution with Serial // Interrupt, the Monitor-51 uses the serial interrupt of the UART. // It is therefore required to reserve the memory locations for the interrupt // vector. You can do this by adding one of the following code lines: // char code reserve [3] _at_ 0x23; // when using on-chip UART for communication // char code reserve [3] _at_ 0x3; // when using off-chip UART for communication void wait (void) { /* wait function */ ; /* only to delay for LED flashes */ } void main (void) { unsigned int i; /* Delay var */ unsigned char j; /* LED var */ while (1) { /* Loop forever */ for (j=0x01; j< 0x80; j<<=1) { /* Blink LED 0, 1, 2, 3, 4, 5, 6 */ P1 = j; /* Output to LED Port */ for (i = 0; i < 10000; i++) { /* Delay for 10000 Counts */ wait (); /* call wait function */ } } for (j=0x80; j> 0x01; j>>=1) { /* Blink LED 6, 5, 4, 3, 2, 1 */ P1 = j; /* Output to LED Port */ for (i = 0; i < 10000; i++) { /* Delay for 10000 Counts */ wait (); /* call wait function */ } } } }
i not sure whether to use port 0 or 1, but i have tried using both port and it still wont blink. Hope you guys can help me thanks alot!
I think it is better if you start by teaching your delay function to actually perform any delay.
Let's repeat: I think it is better if you start by teaching your delay function to actually perform any delay.
Don't you get it? Your delay function does not implement any delay! It is possible that the compiler will call it and immediately return. But just as possible that you won't even get any function call since your delay function does not have any side effect.
Question: How do you get your LED to flash slower? Answer: You teach your delay function to actually perform a delay. Suggestion how to do that: A huge number of suggestions available by using the search function in the upper right corner of this web page.
View all questions in Keil forum