Ex 1 B
Ex 1 B
#include "c8051F340.h"
void Delay();
#define LED3 P4
void main()
{
P4MDOUT = 0xFF; /* All P4 pins configured as Output */
TMOD = 0x01; /* Timer 0 in mode 1 (16-bit) */
CKCON = 0x04; /* Timer 0 uses SYSCLK / 12 */
while(1)
{
LED3 = 0x00; /* LEDs ON */
Delay();
LED3 = 0xFE; /* 11111110 */
Delay();
LED3 = 0xFD; /* 11111101 */
Delay();
LED3 = 0xFB; /* 11111011 */
Delay();
LED3 = 0xF7; /* 11110111 */
Delay();
LED3 = 0xEF; /* 11101111 */
Delay();
LED3 = 0xDF; /* 11011111 */
Delay();
LED3 = 0xBF; /* 10111111 */
Delay();
LED3 = 0x7F; /* 01111111 */
Delay();
}
}
void Delay()
{
TH0 = 0x73; // Load Timer 0 High byte
TL0 = 0x5F; // Load Timer 0 Low byte
TR0 = 1; // Start Timer 0