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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
12/02/04 05:40
Read: times


 
#82346 - Loop Problem
Hello All,

I created a hex file with the following code in Keil and downloaded to 89C52 chip.

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

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

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

for(i = 0; i < 200; i++){
P2_5 = 0x80;
nothing();
P2_5 = 0x00;
nothing();
}

while(1){
P2_7 = 0x80;
nothing();
P2_7 = 0x00;
nothing();
}
}

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

Now the problem in the Keil simulator the code works fine, but when loaded onto the chip only the first loop executes. I have connected 3 LED's to P2_5, P2_6, P2_7. So the LED connected to P2_6 blinks for the given count, but after sometime it continues to glow and no other LED Glows as per the code. What could be the problem.

Does it have anything to do with the code optimization level set.

Thanks & Regards
Rajmathi

List of 15 messages in thread
TopicAuthorDate
Loop Problem            01/01/70 00:00      
   Change            01/01/70 00:00      
   loop Problem            01/01/70 00:00      
   Sorry!!! It is P2_6 = 1 and P2_6 = 0            01/01/70 00:00      
   How to post code            01/01/70 00:00      
   please post the actual code            01/01/70 00:00      
   "            01/01/70 00:00      
      Missing Subject.....            01/01/70 00:00      
         Brief, not missing?            01/01/70 00:00      
            missing subject            01/01/70 00:00      
               Lost Posting?            01/01/70 00:00      
               Text in the post            01/01/70 00:00      
                  yes            01/01/70 00:00      
                     Message replies in subject            01/01/70 00:00      
         ditto            01/01/70 00:00      

Back to Subject List