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!
i found out something, when i try to run the blink code that keil provide, I found that the parallel port 1(one) pins dosent have the tick jumping around. Is that the reason why the LED on the board does not blink? if thats the reason, what should i do to make it work?
a blink is often seen as 'lit'. if the blinking frequency is more than 50-120 Hz (depending on your eyes) you will not see a blink, but a lit LED
Erik
so so i slow down the blinking timing? or what can i do to see the led blinking?
the coding: #include <REG8252.H>
void wait (void) { ; }
void main (void) { unsigned int i; unsigned char j;
while (1) { for (j=0x01; j< 0x80; j<<=1) { P0= j;
for (i = 0; i < 1000; i++) { wait (); } }
for (j=0x80; j> 0x01; j>>=1) { P0= j;
for (i = 0; i < 1000; i++) { wait (); } } } }
sorry typo error, i mean so should i slow down the timing*
I think i better say what i do so that you guys can get a better picture. Firstly, I dl uVision3 and use one of its example, which is blinky project. I open taht project, compile it and run it. But nothing happen to my board LED which is integrated with the development board itself. Off course i have connect the board to the CPU already
I think it is better if you start by teaching your delay function to actually perform any delay.
And it may be a _very_ good idea to also read the instructions just above the text input box and make sure that you post your source code according to the instructions. Then we may be able to read your code.
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!
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.
oo ok i get wat u mean! kk thx veri much
i try using for loop for delay, but it still cant work.
But if you had followed my advice and used the little search field in the upper right corner of this page, you would have known that you should not use a for loop to count time.
And you would also have found code that did implement delays without using a dumb for loop.
unsigned char j; /* LED var */ . . . for (j=0x01; j< 0x80; j<<=1) { . . . }
Because j is an unsigned char, the test for j<0x80 will always be true and you will never exit the loop.
Pass#1 j = 0x01 Pass#2 j = 0x02 Pass#3 j = 0x04 Pass#4 j = 0x08 Pass#5 j = 0x10 Pass#6 j = 0x20 Pass#7 j = 0x40 Pass#8 j = 0x80 Pass#9 j = 0x00 ... Pass#n j = 0x00
Whoops - Sorry - My mistake, I didn't read the code closely enough
hi
O ok because i have search some of the thread that says that using loop will do the job. But after that I try to search again and found out that having loop wont do as well as timer.
I am now using AT89S8252, product code is EQ-8051-ST1 which come with the development board and a programmer board. at the development board there are 8 LED, can these LED be control by the coding that I have done. Or is there other way other than blinking, can test out whether the board is working fine. I would prefer with C code.
Thanks You