CART
  • Cart is empty.

    ItemQuantityPrice

    Total: $0

Square wave generation using 8051 ports


Precise square waves of various duty cycles and pulses of varying widths can be generated on MINI-MAX/51 boards using the delay() function of Micro C and port setbit() and clrbit() functions. This example demonstrates a square wave ( equal on and off times ) with 100 millisecond period on port P1.3 of 8051.

Toolkit:Micro C 8051 Development System

Location:\bipom\devtools\MicroC\Examples\8051\medium\bit

Code Example


void main()
{
	serinit(19200>>1);
	
	printf ("Toggling P1.3");
	
	// Loop forever, generating a square wave on P1.3 of 8051

	for(;;)
	{
		clrbit(P1.3);
		
		delay(100);
		
		setbit(P1.3);
		
		delay(100);
	}			
}