Toggles all the 8051 ports ( P0, P1, P2 and P3 ) on/off and generates a square wave with a period of 2 milliseconds ( 500 Hertz ).
Toolkit:SDCC 8051 Development System
Location:/bipom/devtools/SDCC/examples/io/
main()
{
serinit(19200);
/* Infinite Loop */
for( ;; )
{
/* Reset all the ports */
P0 = 0;
P1 = 0;
P2 = 0;
P3 = 0;
/* Delay 1 millisecond */
delay(1);
/* Set all the ports */
P0 = 0xFF;
P1 = 0xFF;
P2 = 0xFF;
P3 = 0xFF;
/* Delay 1 millisecond */
delay(1);
}
}