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

Loop Problem

Hello All,

I have connected 3 LED's to P2_5, P2_6 and P2_7 ports of 89C52 uC and have the following code in Keil.

#include <stdio.h>
#include <at89x52.h>

void nothing();

void main()
{
     int i;
     P0 = 0x00;
     P1 = 0x00;
     P2 = 0x00;
     P3 = 0x00;

     for(i = 0; i < 200; i++){
          P2_6 = 1;
          nothing();
          P2_6 = 0;
          nothing();
     }

     for(i = 0; i < 200; i++){
          P2_7 = 1;
          nothing();
          P2_7 = 0;
          nothing();
     }

     while(1){
          P2_5 = 1;
          nothing();
          P2_5 = 0;
          nothing();
     }
}

void nothing()
{
     int i;
     for(i = 0; i < 0x5000; i++)
}

As per the code LED connected to P2_6 toggles, but after sometime toggling stops and it continues to remain on. What could be the problem, why is it looping.


Thanks & Regards
Rajmathi

0