0% found this document useful (0 votes)
73 views4 pages

Simulation Set 2

This document contains instructions for an input/output programming experiment using a PIC18 microcontroller. It lists 6 programming questions/tasks involving toggling pins on ports B and C, reading the status of a switch to control an LED, and other I/O operations. The questions are meant to be programmed in C18 and simulated using MPLAB and Proteus software. Reference materials on PIC microcontrollers and embedded systems are also provided.

Uploaded by

Harsh Thakur
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)
73 views4 pages

Simulation Set 2

This document contains instructions for an input/output programming experiment using a PIC18 microcontroller. It lists 6 programming questions/tasks involving toggling pins on ports B and C, reading the status of a switch to control an LED, and other I/O operations. The questions are meant to be programmed in C18 and simulated using MPLAB and Proteus software. Reference materials on PIC microcontrollers and embedded systems are also provided.

Uploaded by

Harsh Thakur
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/ 4

ADVANCED MICROCONTROLLER AND EMBEDDED SYSTEM (EE 425T)

Semester-VII ELECTRICAL ENGINEERING

Experiment No:- 02
Input Output Programming in C (continued)

Requirements:-
MPLAB and Proteus software

Department of Electrical Engineering , SOT, PDPU


ADVANCED MICROCONTROLLER AND EMBEDDED SYSTEM (EE 425T)
Semester-VII ELECTRICAL ENGINEERING

SIMULATION SET- 2
INPUT/OUTPUT PROGRAMMING IN C

1) Write a C18 program to toggle bit RB4 continuously without disturbing the rest of the

bits of port B.

2) Write a C18 program to read the status of switch attached to pin RB4 on port B and

thereby turn on/off the LED on pin RC4. Pull-up resistor configuration has been used for

connecting the switch to pin RB4 of port B. LED on pin RC4 must glow without disturbing

other pins on port C.

3) Write a C18 program to get the status of bit RB0 and send it to RC7 continuously.

4) Rewrite the above C18 program to get the bit RB0 and send it to RC7 after inverting it.

5) Write a C18 program to toggle all the bits of port B and port C continuously using the

inverting operator. Introduce time delay in between each state for better visibility.

6) Introduce a switch with a pull up resistor configuration to the PIC18 on pin RB0 of port

B. After five operations of the switch, the LED connected to pin RB7 must glow for a

certain time period and then should turn off. Write a C18 program for the same and

observe the output.

Reference:

i. M. A. Mazidi, R. Mckinlay and D. Causey, “PIC Microcontroller and Embedded Systems”,


Pearson Publications, 1999.

Department of Electrical Engineering , SOT, PDPU


ADVANCED MICROCONTROLLER AND EMBEDDED SYSTEM (EE 425T)
Semester-VII ELECTRICAL ENGINEERING

Question 1.

#include <xc.h>

#include <stdio.h>

#include <math.h>

#include <stdlib.h>

#include "probe1.h"

void time_delay(void);

void main(void)

TRISBbits.RB4 =0;

while(1)

LATBbits.LATB4=0;

time_delay();

LATBbits.LATB4=1;

time_delay();

void time_delay(void)

unsigned int i;

unsigned int j;

for(i=0;i<20;i++)

for(j=0;j<20;j++);

Department of Electrical Engineering , SOT, PDPU


ADVANCED MICROCONTROLLER AND EMBEDDED SYSTEM (EE 425T)
Semester-VII ELECTRICAL ENGINEERING

Question 2.

Department of Electrical Engineering , SOT, PDPU

You might also like