0% found this document useful (0 votes)
4 views12 pages

Bazia17embd Ass2

This document is a lab report for an Embedded System assignment submitted by Bazia Azmat. It includes questions and answers related to PIC microcontroller components, circuit diagrams, programming methods, and sample code for various tasks. The report also outlines the grading rubric and contains simulation results for the provided programming exercises.

Uploaded by

farrukh khan
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)
4 views12 pages

Bazia17embd Ass2

This document is a lab report for an Embedded System assignment submitted by Bazia Azmat. It includes questions and answers related to PIC microcontroller components, circuit diagrams, programming methods, and sample code for various tasks. The report also outlines the grading rubric and contains simulation results for the provided programming exercises.

Uploaded by

farrukh khan
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/ 12

Embedded System Lab

ASSIGNMENT: 02

SUBMITTED BY: BAZIA AZMAT

SUBMITTED TO: Sir Zia-ur-Rehman

REGISTRATION NO: 202101017

Class: BSCE-V

Lab Report Rubrics:

Turn in on Schematic/ Presentation Coding Outcome Total


time Simulation Marks
4 4 4 4 4 20
Question 1
Write the name of necessary components required to power up a PIC microcontroller?

 Crystal.
 Capacitor (For the clock circuit).
 Vcc (5 volts) and ground connected to pin 11 and 12 respectively.
 Resistor
 Push button. (For reset circuitry).

Question 2
Draw circuit diagram of reset circuit and clock circuit?

Reset Signal
In order for the microcontroller to operate properly, a logic one (VCC) must be applied on the reset pin. A
push button connecting the MCLR reset pin to GND is not necessary, but is almost always provided as it
enables the microcontroller to recover fast if something goes wrong.
Clock Signal
Even though the microcontroller has a built-in oscillator, it cannot operate without external components which
make its operation stable and determine its operating frequency.
Circuit

Question 3
How we program any pic microcontroller using PICkit 3?

 Connect PICkit 3 to the ICSP connector and start the application.


 Select Advance Mode.
 Now from the Device Family tab select the PIC18 and choose the Device from the dropdown menu.
 Press the connect button to get ready to write a program.
 After connecting successfully.
 Load the hex file by going File->Import Hex
 Then Use the Write button to burn the code to the PIC microcontroller

All available features of a given device are accessible interactively, and can be set and modified by the
MPLAB IDE interface.

USB Port Connection:


The Port connection is a USB mini-B connector. It is used to connect the PICKit3 with PC through USB cable.

Programming Connector:
It is a six pin connector and is used to connect the target device with PICKit3. It consists of following pins
with pin 1 starting from marker.

Status LED:
Three LED’s are provided on PICKit3. Different colors indicate different status of PICKit3 as follows:
Power (Green)
Power is supplied to the PICKit3 through USB port.
Active (Blue)
Communication link is active and PICKit3 has connection with PC through USB cable.
Status Busy (Yellow)
Some function is in progress and PICKit3 is busy with it like programming
Error (Red).The PICKit3 encounter some error.
Question 4
How pull up and pull down switch works and why we need to pull up or pull down?

Pull-Down Circuit:

Pull-down resistors work in the same manner as pull-up resistors, except that they pull the pin to a logical low
value. When the switch is open, the pull-down resistor pulls the input voltage down to ground (logical zero
value).

Pull-Up Circuit:

Pull-up resistors are resistors used in logic circuits to ensure a well-defined logical level at a pin under all
condition. Without the pull-up resistor, the MCU’s input would be floating when the switch is open and pulled
down to a logical low only when the switch is closed.
Question 5
How Microcontroller serve several devices? Write methods and explain it.

There are two methods of programming


 Interrupts (it’s an efficient way )( in the case of an interrupt, the system informs the CPU that it
needs attention)
 Polling(less efficient) (the CPU constantly inspects the status of the system to find whether it needs
attention.)

Question 6
Write program to toggle all the bits of port B Continuously?

Micro C Work:

Proteus Simulation:
Question 7
Write program to toggle all the bits of port B, port C and port D Continuously with a 250ms delay by using
the inverting operator?

Micro C Work:

Proteus Simulation:
Question 8
A door sensor is connected to the RB1 pin, and a buzzer is connected to RC7. Write a program to monitor
the door sensor, and when it opens, sound the buzzer. Else buzzer is off?

Micro C Work:

Proteus Simulation:
Question 9
Design a circuit for 8 LED’s connected to port b and a push button with RC0, if push button press first time
only first led connected to RB0 glow, if push button press 2nd time then first two Led’s glows, then so on to
the 8th press and all the 8 Led’s glow. For 9th press all Led’s turned OFF, and repeat the procedure?
Program
void io_function()
{
TRISC.b0=1;
portc.b0=1;
TRISB=0;
portb=0;
}
void main()
{
unsigned char status;
unsigned char count;
io_function();
while(1)
{
count=0;
back:
status = portc.b0;
delay_ms(500);
if(status == 0)
{
count++;
}
switch(count)
{
case 1 :
portb.b0 = 1;
delay_ms(500);
break;
case 2 :
portb.b1 = 1;
portb.b0 = 1;
delay_ms(500);
break;
case 3 :
portb.b2 = 1;
portb.b1 = 1;
portb.b0 = 1;
delay_ms(500);
break;
case 4 :
portb.b3 = 1;
portb.b2 = 1;
portb.b1 = 1;
portb.b0 = 1;
delay_ms(500);
break;
case 5 :
portb.b4 = 1;
portb.b3 = 1;
portb.b2 = 1;
portb.b1 = 1;
portb.b0 = 1;
delay_ms(500);
break;
case 6 :
portb.b5 = 1;
portb.b4 = 1;
portb.b3 = 1;
portb.b2 = 1;
portb.b1 = 1;
portb.b0 = 1;
delay_ms(500);
break;
case 7 :
portb.b6 = 1;
portb.b5 = 1;
portb.b4 = 1;
portb.b3 = 1;
portb.b2 = 1;
portb.b1 = 1;
portb.b0 = 1;
delay_ms(500);
break;
case 8 :
portb.b7 = 1;
portb.b6 = 1;
portb.b5 = 1;
portb.b4 = 1;
portb.b3 = 1;
portb.b2 = 1;
portb.b1 = 1;
portb.b0 = 1;
delay_ms(500);
break;
case 9 :
count = 0;
portb.b7 = 0;
portb.b6 = 0;
portb.b5 = 0;
portb.b4 = 0;
portb.b3 = 0;
portb.b2 = 0;
portb.b1 = 0;
portb.b0 = 0;
delay_ms(500);
break;
}
goto back;
}}

Micro C Work:
Micro C Work:

Proteus Simulation:
Proteus Simulation:

Proteus Simulation:
Proteus Simulation:

Proteus Simulation:
When press for the 9th time

The End

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy