Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
10/04/09 19:15
Read: times


 
#169399 - Another Problem!
Responding to: ???'s previous message
Thanks a lot for the solution! It worked. And the LED just blinked once.
However I then wrote the same code using a delay function as follows,
-------------------------------------
#include<reg51.h>
#include<stdio.h>
sbit LED=P1^0;
void msdel(unsigned int d);

void main(void)
{
LED=0;
msdel(100);
LED=1;
msdel(100);
for(;;);
}
void msdel(unsigned int d)
{
unsigned char x,y;
for(x=0;x<1275;x++)
for(y=0;y<d;y++);
}
---------------------------------------------

The LED is supposed to blink once like in the last case. But in this case the LED just stays on forever.
What could be the problem in the code.
A similar thing happens when I put the whole main() content in a while(1)loop to make the LED blink infinitely.


List of 13 messages in thread
TopicAuthorDate
A doubt about programming the P89v51RD2.            01/01/70 00:00      
   I'm programming in C for the first time            01/01/70 00:00      
      I take it that you are programming for the first time..            01/01/70 00:00      
         FAQ            01/01/70 00:00      
            Another Problem!            01/01/70 00:00      
               Large number            01/01/70 00:00      
                  How to post legible source code            01/01/70 00:00      
               Delay loops in 'C'...            01/01/70 00:00      
                  Thank you.            01/01/70 00:00      
                     Did you not notice?            01/01/70 00:00      
                        I did notice the indentation.            01/01/70 00:00      
                           skim through the FAQ's (edited)            01/01/70 00:00      
   what your (missing) comments state            01/01/70 00:00      

Back to Subject List