Bazia17embd Ass2
Bazia17embd Ass2
ASSIGNMENT: 02
Class: BSCE-V
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?
All available features of a given device are accessible interactively, and can be set and modified by the
MPLAB IDE interface.
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.
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