Bachelor's of Electrical Engineering: Microprocessor & Microcontroller (Assignment # 03)
Bachelor's of Electrical Engineering: Microprocessor & Microcontroller (Assignment # 03)
(ASSIGNMENT # 03)
Name: Jawad Ul
Hassan Shah
Reg. ID:
180527
Bachelor’s of Electrical
Engineering
Session 2018-2022
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
Also show your calculations for step size and suitable clock source selection.
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:
Tinc= 12/12MHz
Tinc= 1usec
Ninc= 400usec/1usec
TV= 65535-400+1
= 65136
= FE70H
TH0= 0xFE
TL0= 0x70
5|Page