0% found this document useful (0 votes)
2 views7 pages

Sheet 1 Embedded Timer

The document contains a series of programming tasks for the 8051 microcontroller using C language, focusing on generating square waves with varying duty cycles and frequencies, sending values to ports, and implementing countdowns based on timer interrupts. Each task includes calculations and code snippets, with specific parameters like crystal frequency provided. The tasks are attributed to Eng. Hager Rabea and Eng. Nour Mandour.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views7 pages

Sheet 1 Embedded Timer

The document contains a series of programming tasks for the 8051 microcontroller using C language, focusing on generating square waves with varying duty cycles and frequencies, sending values to ports, and implementing countdowns based on timer interrupts. Each task includes calculations and code snippets, with specific parameters like crystal frequency provided. The tasks are attributed to Eng. Hager Rabea and Eng. Nour Mandour.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Sheet 1

Embedded C & Timer

1- Write an 8051 c program to send values 00-FF to port P1?

2-Write a 8051 c program to send values pf ASCII characters


0,1,2,3,4,5,A,B,C and D on port1 ?

Mad By : Eng:Hager Rabea & Eng:Nour Mandour


3-Assume that XTAL = 11.0592 MHz, write a program to
generate a square wave of 2 kHz frequency on pin P1.5.

Calculations:

Code:

Mad By : Eng:Hager Rabea & Eng:Nour Mandour


4-Write a 8051 C program to generate square wave with 75% duty
cycle on p2.7 with delay 100ms , use timer 0 mode 1 , Given that
XTAL =12MHZ?
Calculations:
75% means that on delay =75% from the total time and off delay=25% …
1- 12MHZ/12=1MHZ
2- T(for 1cycle)=1/1MHZ=1MicroSecond
3- T=100ms/4=25ms
4- No.of.cycles=25ms/1MicroS=25000
5- No.of.cycles=65536-25000=40536
6- (40536)To Hexa(9E58)
7- TL=58 &TH=9E
8- TMOD=0X01

Code :

Mad By : Eng:Hager Rabea & Eng:Nour Mandour


5-Write a 8051 C program to generate square wave with 60% duty
cycle on p3.5 with delay 100ms , use timer 0 mode 1 , Given that
XTAL =12MHZ?using loop …
Try By Yourself Please ….
Calculations :

Code :

Mad By : Eng:Hager Rabea & Eng:Nour Mandour


6-Write a 8051 C program to generate square wave with 55% duty
cycle on p3.5 with delay 100ms , use timer 0 mode 1 , Given that
XTAL =12MHZ?using loop …
Try By Yourself Please ….
Calculations :

Code :

Mad By : Eng:Hager Rabea & Eng:Nour Mandour


7-Write a C program in 8051 micro controller to count down from
10 to 1
 If p1.0 is on display the count every 10ms using timer0,
 If p1.0 is off display the count every 20ms using timer0,
(Crystal Frequency=12MHZ)
Try By Yourself Please ….
Calculations:

Code:

Mad By : Eng:Hager Rabea & Eng:Nour Mandour


8- Assume that a 1-Hz external clock is being fed into pin T0
(P3.4). Write a C program for counter 0 in mode 1 (16-bit) to
count the pulses and display the state of the TH0 and TL0
registers on P2 and P1, respectively.

Code:

Mad By : Eng:Hager Rabea & Eng:Nour Mandour

You might also like