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++) }
Not quite. The original post had an infinite loop that was processed after the first two loops. So - once they had finished, the code would enter the final infinite loop and just stay there...
You have forgotton that these Micros are need to run in infinite loop. So under main loop open a another loop with main() { while (1) { . . ;place your code here...... } } This will work forever. Venkatesh K.
View all questions in Keil forum