0% found this document useful (0 votes)
53 views5 pages

Bachelor's of Electrical Engineering: Microprocessor & Microcontroller (Assignment # 03)

The document is an assignment for a microprocessor and microcontroller course. It contains two tasks: 1. Write a C program for a PIC18F452 microcontroller to get analog data from channel 2 every 500ms, convert it to digital, display the lower 8-bits on Port C and highest 2-bits on Port E. Calculations show a step size of 4.88mV and a clock source of 2.67us is suitable. 2. Write an assembly program for an AT89C51 microcontroller to sound a buzzer on P1.0 for 400us whenever an interrupt on INT0 is detected. Using a 12MHz crystal, calculations show timer values of TH0=
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views5 pages

Bachelor's of Electrical Engineering: Microprocessor & Microcontroller (Assignment # 03)

The document is an assignment for a microprocessor and microcontroller course. It contains two tasks: 1. Write a C program for a PIC18F452 microcontroller to get analog data from channel 2 every 500ms, convert it to digital, display the lower 8-bits on Port C and highest 2-bits on Port E. Calculations show a step size of 4.88mV and a clock source of 2.67us is suitable. 2. Write an assembly program for an AT89C51 microcontroller to sound a buzzer on P1.0 for 400us whenever an interrupt on INT0 is detected. Using a 12MHz crystal, calculations show timer values of TH0=
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

MPMC ASSIGNMENT 03 January 10, 2021

Microprocessor & Microcontroller

(ASSIGNMENT # 03)

Name: Jawad Ul
Hassan Shah
Reg. ID:
180527

Bachelor’s of Electrical
Engineering
Session 2018-2022

Teacher’s Name: Sir. Waqar Ahmed

Department of Electrical Engineering


Air University, Islamabad

TASK#1
Write a C language program for PIC18F452 microcontroller operating at 12 MHz crystal.
The program should get analog data from analog channel 2 every 500msec, convert it to
digital data. Display the lower 8-bits of the result on Port C and highest 2-bits on Port E.
Don’t forget to select an appropriate configuration of ADC such that the pins of Port E are
digital pins.

1|Page
MPMC ASSIGNMENT 03 January 10, 2021

Let VREF+ = VDD = 5 V and VREF– = VSS = 0 V.

Also show your calculations for step size and suitable clock source selection.

Step Size Calculations:


Step Size=Voltage Range/2 Resolution
Voltage Range= Vref+ - Vref-
= 5-0
=5V
Resolution=10 bits
Step size=5/210
Step size=4.88 mV

Clock Source:

As we know TAD ≥ 1.6µsec and crystal frequency is 12 MHz. We can find clock source by
using the following calculation.
Clock source ≥ 1.6 usec
Clock source= 1/12MHz/16sec
Clock source=1.33usec
We will use 1 more lesser than this, hence;
Clock source=1/12MHz/32sec
Clock source= 2.67usec
So, our ADCS2:ADCS1=010b with ref. to said calculations.

Syntax:

2|Page
MPMC ASSIGNMENT 03 January 10, 2021

TASK#2

3|Page
MPMC ASSIGNMENT 03 January 10, 2021

AT89C51: Write an assembly language program to sound a buzzer connected to P1.0 for 400
μsec whenever a falling edge is detected on INT0. XTAL = 12 MHz Use 8051 timer to
generate the delay and configure the external interrupt as edge triggered interrupt.

Syntax:

Calculating The Value For TH0 & TL0


4|Page
MPMC ASSIGNMENT 03 January 10, 2021

Crystal oscillator = 12MHz

Tinc= 12/12MHz

Tinc= 1usec

Ninc= 400usec/1usec

Ninc= 400(requires 16- bit timer)

TV= 65535-400+1

= 65136

= FE70H

TH0= 0xFE

TL0= 0x70

5|Page

You might also like