0% found this document useful (0 votes)
40 views23 pages

MCL Exp 9

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)
40 views23 pages

MCL Exp 9

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/ 23

K. J.

Somaiya College of Engineering, Mumbai-77


(A Constituent College of Somaiya Vidyavihar University)
Department of Electronics Engineering

Experiment No: 9
Title: Interfacing of LED with PIC
Course Name: Microcontrollers and Application Semester: IV
Date of
26/4/23 Batch No: A2
Performance:
Faculty Name: Prof. Kiran Thale Roll No: 16010221031
Faculty Sign & Date: Grade/Marks: --/25

Aim and Objective of the Experiment:


Aim: Write a C Program to Interface LED with PIC microcontroller
Objectives:
o Study of Ports of PIC
o Study of TRIS SFRs

COs to be achieved:
CO 3. Understand architectural features of PIC18F452 microcontroller
CO 5. Write Embedded-C programs to interface different on-chip as well as off-chip
peripherals with 8051/PIC18F452 microcontroller and explain different types of serial
communication protocols of PIC18F452 microcontroller

Theory:
PIC is an abbreviation used for Peripheral Interface Controller. PIC microcontroller is the
smallest microcontroller in the world and is programmed to execute large number of operations.
These were initially designed to support PDP (programmed data processor) computers, for
controlling the peripheral devices. It is based on RISC architecture.
PIC microcontrollers hold the ability of faster execution of programs than microcontrollers.

Microcontroller is nothing but a combination of processor, memory and peripherals in a single


chip. In a similar way PIC microcontroller consists of data RAM with some hundred bytes of ROM
for storing the desired program, some I/O ports, one timer on a single chip having 8 pins.

As it was designed to perform simple control applications thus called peripheral interface

Microcontrollers and Application Semester: IV Academic Year: 2022-23


K. J. Somaiya College of Engineering, Mumbai-77
(A Constituent College of Somaiya Vidyavihar University)
Department of Electronics Engineering

controller. But now-a-days it is commonly known as programmable intelligent computer.

TRISX Register
Before accessing the PORTX register, we should declare that port whether input or output. So this
register is used to select that direction. If you set 0 that IO port will act as the output port. If you set
1 that IO port will act as an input port.

PORTX Register
This register is used to read/write the data from/to port pins. Writing 1’s to PORTx will make the
corresponding PORTx pins as HIGH. Similarly writing 0’s to PORTx will make the corresponding
PORTx pins as LOW. PORTX registers and their alternate functions are shown in the below table.

PORT Number of Pins Alternative Function


PORTA 6 (PA0-PA5) ADC
PORTB 8 (PB0-PB7) Interrupts
PORTC 8 (PC0-PC7) UART,I2C,PWM
PORTD 8 (PD0-PD7) Parallel Slave Port
PORTE 3 (PE0-PB2) ADC
Circuit Diagram/ Block Diagram:

Microcontrollers and Application Semester: IV Academic Year: 2022-23


K. J. Somaiya College of Engineering, Mumbai-77
(A Constituent College of Somaiya Vidyavihar University)
Department of Electronics Engineering

Stepwise-Procedure:
1. Design circuit and connect it using Proteus simulator.
2. Write an assembly program to achieve the aim.
3. Compile the program and generate HEX file using MPLAB IDE.
4. Run the hardware and take screen shot of it to attach in the output.

Assembly program:
Program: Attach list file with appropriate comments and snapshot of result

BLINK LED
***************************************************************************************

MPASM 5.51 BLINKLED.ASM 4-26-2023 12:06:25 PAGE 1

LOC OBJECT CODE LINE SOURCE TEXT

Microcontrollers and Application Semester: IV Academic Year: 2022-23


K. J. Somaiya College of Engineering, Mumbai-77
(A Constituent College of Somaiya Vidyavihar University)
Department of Electronics Engineering

VALUE

00001 #include P18F452.INC


00001 LIST
00002
00003 ;===============================================================
===========
00004 ; MPASM PIC18F452 processor include
00005 ;
00006 ; (c) Copyright 1999-2013 Microchip Technology, All rights reserved
00007 ;===============================================================
===========
00008
01254 LIST
00000010 00002 COUNT EQU 0x10 //count=10
00003 org 0
000000 EF?? F??? 00004 GOTO start
00005 org 100
000100 0E00 00006 start: MOVLW 0x00 //make port d as output
000102 6E95 00007 MOVWF TRISD
000104 0E55 00008 MOVLW 0x55
000106 6E83 00009 MOVWF PORTD
000108 EC?? F??? 00010 REPEAT: CALL delay
00010C 1E83 00011 COMF PORTD,1
00010E D??? 00012 BRA REPEAT
000110 0EFF 00013 delay: MOVLW 0xFF //adding
000112 6E10 00014 MOVWF COUNT
000114 0610 00015 BACK:DECF COUNT,1
000116 E1?? 00016 BNZ BACK
000118 0012 00017 RETURN
00011A 0003 00018 SLEEP
00019 END
MPASM 5.51 BLINKLED.ASM 4-26-2023 12:06:23 PAGE 2

SYMBOL TABLE
LABEL VALUE

A 00000000
ACCESS 00000000
ACKDT 00000005
ACKEN 00000004
ACKSTAT 00000006
ADCON0 00000FC2
ADCON1 00000FC1

Microcontrollers and Application Semester: IV Academic Year: 2022-23


K. J. Somaiya College of Engineering, Mumbai-77
(A Constituent College of Somaiya Vidyavihar University)
Department of Electronics Engineering

ADCS0 00000006
ADCS1 00000007
ADCS2 00000006
ADDEN 00000003
ADFM 00000007
ADIE 00000006
ADIF 00000006
ADIP 00000006
ADON 00000000
ADRES 00000FC3
ADRESH 00000FC4
ADRESL 00000FC3
AN0 00000000
AN1 00000001
AN2 00000002
AN3 00000003
AN4 00000005
AN5 00000000
AN6 00000001
AN7 00000002
BACK 00000114
BANKED 00000001
BCLIE 00000003
BCLIF 00000003
BCLIP 00000003
BF 00000000
BOR 00000000
BRGH 00000002
BSR 00000FE0
C 00000000
CCP1 00000002
CCP1CON 00000FBD
CCP1IE 00000002
CCP1IF 00000002
CCP1IP 00000002
CCP1M0 00000000
CCP1M1 00000001
CCP1M2 00000002
CCP1M3 00000003
CCP1X 00000005
CCP1Y 00000004
CCP2A 00000003
CCP2CON 00000FBA
CCP2IE 00000000
CCP2IF 00000000

Microcontrollers and Application Semester: IV Academic Year: 2022-23


K. J. Somaiya College of Engineering, Mumbai-77
(A Constituent College of Somaiya Vidyavihar University)
Department of Electronics Engineering

CCP2IP 00000000
MPASM 5.51 BLINKLED.ASM 4-26-2023 12:06:23 PAGE 3

SYMBOL TABLE
LABEL VALUE

CCP2M0 00000000
CCP2M1 00000001
CCP2M2 00000002
CCP2M3 00000003
CCP2X 00000005
CCP2Y 00000004
CCP2_DDRB 00000003
CCP2_DDRC 00000001
CCP2_PORTB 00000003
CCP2_PORTC 00000001
CCP2_TRISB 00000003
CCP2_TRISC 00000001
CCPR1 00000FBE
CCPR1H 00000FBF
CCPR1L 00000FBE
CCPR2 00000FBB
CCPR2H 00000FBC
CCPR2L 00000FBB
CFGS 00000006
CHS0 00000003
CHS1 00000004
CHS2 00000005
CK 00000006
CKE 00000006
CKP 00000004
CLKO 00000006
COUNT 00000010
CREN 00000004
CS 00000002
CSRC 00000007
D 00000005
DATA_ADDRESS 00000005
DC 00000001
DC1B0 00000004
DC1B1 00000005
DC2B0 00000004
DC2B1 00000005
DCCPX 00000005

Microcontrollers and Application Semester: IV Academic Year: 2022-23


K. J. Somaiya College of Engineering, Mumbai-77
(A Constituent College of Somaiya Vidyavihar University)
Department of Electronics Engineering

DDRA TRISA
DDRB TRISB
DDRC TRISC
DDRD TRISD
DDRE TRISE
DONE 00000002
D_A 00000005
D_NOT_A 00000005
EEADR 00000FA9
EECON1 00000FA6
EECON2 00000FA7
EEDATA 00000FA8
EEIE 00000004
EEIF 00000004
EEIP 00000004
MPASM 5.51 BLINKLED.ASM 4-26-2023 12:06:23 PAGE 4

SYMBOL TABLE
LABEL VALUE

EEPGD 00000007
FAST 00000001
FERR 00000002
FREE 00000004
FSR0 00000000
FSR0H 00000FEA
FSR0L 00000FE9
FSR1 00000001
FSR1H 00000FE2
FSR1L 00000FE1
FSR2 00000002
FSR2H 00000FDA
FSR2L 00000FD9
GCEN 00000007
GIE 00000007
GIEH 00000007
GIEL 00000006
GIE_GIEH 00000007
GO 00000002
GO_DONE 00000002
GO_NOT_DONE 00000002
I2C_DAT 00000005
I2C_DATA 00000005
I2C_READ 00000002

Microcontrollers and Application Semester: IV Academic Year: 2022-23


K. J. Somaiya College of Engineering, Mumbai-77
(A Constituent College of Somaiya Vidyavihar University)
Department of Electronics Engineering

I2C_START 00000003
I2C_STOP 00000004
IBF 00000007
IBOV 00000005
INDF0 00000FEF
INDF1 00000FE7
INDF2 00000FDF
INT0 00000000
INT0E 00000004
INT0F 00000001
INT0IE 00000004
INT0IF 00000001
INT1 00000001
INT1E 00000003
INT1F 00000000
INT1IE 00000003
INT1IF 00000000
INT1IP 00000006
INT1P 00000006
INT2 00000002
INT2E 00000004
INT2F 00000001
INT2IE 00000004
INT2IF 00000001
INT2IP 00000007
INT2P 00000007
INTCON 00000FF2
INTCON1 00000FF2
INTCON2 00000FF1
MPASM 5.51 BLINKLED.ASM 4-26-2023 12:06:23 PAGE 5

SYMBOL TABLE
LABEL VALUE

INTCON3 00000FF0
INTEDG0 00000006
INTEDG1 00000005
INTEDG2 00000004
IPEN 00000007
IPR1 00000F9F
IPR2 00000FA2
IRVST 00000005
LATA 00000F89
LATA0 00000000

Microcontrollers and Application Semester: IV Academic Year: 2022-23


K. J. Somaiya College of Engineering, Mumbai-77
(A Constituent College of Somaiya Vidyavihar University)
Department of Electronics Engineering

LATA1 00000001
LATA2 00000002
LATA3 00000003
LATA4 00000004
LATA5 00000005
LATA6 00000006
LATB 00000F8A
LATB0 00000000
LATB1 00000001
LATB2 00000002
LATB3 00000003
LATB4 00000004
LATB5 00000005
LATB6 00000006
LATB7 00000007
LATC 00000F8B
LATC0 00000000
LATC1 00000001
LATC2 00000002
LATC3 00000003
LATC4 00000004
LATC5 00000005
LATC6 00000006
LATC7 00000007
LATD 00000F8C
LATD0 00000000
LATD1 00000001
LATD2 00000002
LATD3 00000003
LATD4 00000004
LATD5 00000005
LATD6 00000006
LATD7 00000007
LATE 00000F8D
LATE0 00000000
LATE1 00000001
LATE2 00000002
LVDCON 00000FD2
LVDEN 00000004
LVDIE 00000002
LVDIF 00000002
LVDIN 00000005
LVDIP 00000002
MPASM 5.51 BLINKLED.ASM 4-26-2023 12:06:23 PAGE 6

Microcontrollers and Application Semester: IV Academic Year: 2022-23


K. J. Somaiya College of Engineering, Mumbai-77
(A Constituent College of Somaiya Vidyavihar University)
Department of Electronics Engineering

SYMBOL TABLE
LABEL VALUE

LVDL0 00000000
LVDL1 00000001
LVDL2 00000002
LVDL3 00000003
N 00000004
NOT_A 00000005
NOT_ADDRESS 00000005
NOT_BOR 00000000
NOT_DONE 00000002
NOT_IPEN 00000007
NOT_PD 00000002
NOT_POR 00000001
NOT_RBPU 00000007
NOT_RC8 00000006
NOT_RI 00000004
NOT_T1SYNC 00000002
NOT_T3SYNC 00000002
NOT_TO 00000003
NOT_TX8 00000006
NOT_W 00000002
NOT_WRITE 00000002
OBF 00000006
OERR 00000001
OSC2 00000006
OSCCON 00000FD3
OV 00000003
P 00000004
PC 00000FF9
PCFG0 00000000
PCFG1 00000001
PCFG2 00000002
PCFG3 00000003
PCL 00000FF9
PCLATH 00000FFA
PCLATU 00000FFB
PD 00000002
PEIE 00000006
PEIE_GIEL 00000006
PEN 00000002
PGC 00000006
PGD 00000007

Microcontrollers and Application Semester: IV Academic Year: 2022-23


K. J. Somaiya College of Engineering, Mumbai-77
(A Constituent College of Somaiya Vidyavihar University)
Department of Electronics Engineering

PGM 00000005
PIE1 00000F9D
PIE2 00000FA0
PIR1 00000F9E
PIR2 00000FA1
PLUSW0 00000FEB
PLUSW1 00000FE3
PLUSW2 00000FDB
POR 00000001
PORTA 00000F80
PORTB 00000F81
PORTC 00000F82
MPASM 5.51 BLINKLED.ASM 4-26-2023 12:06:23 PAGE 7

SYMBOL TABLE
LABEL VALUE

PORTD 00000F83
PORTE 00000F84
POSTDEC0 00000FED
POSTDEC1 00000FE5
POSTDEC2 00000FDD
POSTINC0 00000FEE
POSTINC1 00000FE6
POSTINC2 00000FDE
PR2 00000FCB
PREINC0 00000FEC
PREINC1 00000FE4
PREINC2 00000FDC
PROD 00000FF3
PRODH 00000FF4
PRODL 00000FF3
PSA 00000003
PSP0 00000000
PSP1 00000001
PSP2 00000002
PSP3 00000003
PSP4 00000004
PSP5 00000005
PSP6 00000006
PSP7 00000007
PSPIE 00000007
PSPIF 00000007
PSPIP 00000007

Microcontrollers and Application Semester: IV Academic Year: 2022-23


K. J. Somaiya College of Engineering, Mumbai-77
(A Constituent College of Somaiya Vidyavihar University)
Department of Electronics Engineering

PSPMODE 00000004
R 00000002
RA0 00000000
RA1 00000001
RA2 00000002
RA3 00000003
RA4 00000004
RA5 00000005
RA6 00000006
RB0 00000000
RB1 00000001
RB2 00000002
RB3 00000003
RB4 00000004
RB5 00000005
RB6 00000006
RB7 00000007
RBIE 00000003
RBIF 00000000
RBIP 00000000
RBPU 00000007
RC0 00000000
RC1 00000001
RC2 00000002
RC3 00000003
RC4 00000004
MPASM 5.51 BLINKLED.ASM 4-26-2023 12:06:23 PAGE 8

SYMBOL TABLE
LABEL VALUE

RC5 00000005
RC6 00000006
RC7 00000007
RC8_9 00000006
RC9 00000006
RCD8 00000000
RCEN 00000003
RCIE 00000005
RCIF 00000005
RCIP 00000005
RCON 00000FD0
RCREG 00000FAE
RCSTA 00000FAB

Microcontrollers and Application Semester: IV Academic Year: 2022-23


K. J. Somaiya College of Engineering, Mumbai-77
(A Constituent College of Somaiya Vidyavihar University)
Department of Electronics Engineering

RD 00000000
RD0 00000000
RD1 00000001
RD16 00000007
RD2 00000002
RD3 00000003
RD4 00000004
RD5 00000005
RD6 00000006
RD7 00000007
RE0 00000000
RE1 00000001
RE2 00000002
READ_WRITE 00000002
REPEAT 00000108
RI 00000004
RSEN 00000001
RX 00000007
RX9 00000006
RX9D 00000000
R_NOT_W 00000002
R_W 00000002
S 00000003
SCK 00000003
SCL 00000003
SCS 00000000
SDA 00000004
SDI 00000004
SDO 00000005
SEN 00000000
SMP 00000007
SP0 00000000
SP1 00000001
SP2 00000002
SP3 00000003
SP4 00000004
SPBRG 00000FAF
SPEN 00000007
SREN 00000005
SS 00000005
MPASM 5.51 BLINKLED.ASM 4-26-2023 12:06:23 PAGE 9

SYMBOL TABLE
LABEL VALUE

Microcontrollers and Application Semester: IV Academic Year: 2022-23


K. J. Somaiya College of Engineering, Mumbai-77
(A Constituent College of Somaiya Vidyavihar University)
Department of Electronics Engineering

SSPADD 00000FC8
SSPBUF 00000FC9
SSPCON1 00000FC6
SSPCON2 00000FC5
SSPEN 00000005
SSPIE 00000003
SSPIF 00000003
SSPIP 00000003
SSPM0 00000000
SSPM1 00000001
SSPM2 00000002
SSPM3 00000003
SSPOV 00000006
SSPSTAT 00000FC7
STATUS 00000FD8
STKFUL 00000007
STKOVF 00000007
STKPTR 00000FFC
STKPTR0 00000000
STKPTR1 00000001
STKPTR2 00000002
STKPTR3 00000003
STKPTR4 00000004
STKUNF 00000006
SWDTE 00000000
SWDTEN 00000000
SYNC 00000004
T08BIT 00000006
T0CKI 00000004
T0CON 00000FD5
T0CS 00000005
T0IE 00000005
T0IF 00000002
T0IP 00000002
T0PS0 00000000
T0PS1 00000001
T0PS2 00000002
T0SE 00000004
T1CKI 00000000
T1CKPS0 00000004
T1CKPS1 00000005
T1CON 00000FCD
T1INSYNC 00000002
T1OSCEN 00000003

Microcontrollers and Application Semester: IV Academic Year: 2022-23


K. J. Somaiya College of Engineering, Mumbai-77
(A Constituent College of Somaiya Vidyavihar University)
Department of Electronics Engineering

T1OSI 00000001
T1OSO 00000000
T1SYNC 00000002
T2CKPS0 00000000
T2CKPS1 00000001
T2CON 00000FCA
T3CCP1 00000003
T3CCP2 00000006
T3CKPS0 00000004
MPASM 5.51 BLINKLED.ASM 4-26-2023 12:06:23 PAGE 10

SYMBOL TABLE
LABEL VALUE

T3CKPS1 00000005
T3CON 00000FB1
T3INSYNC 00000002
T3SYNC 00000002
TABLAT 00000FF5
TBLPTR 00000FF6
TBLPTRH 00000FF7
TBLPTRL 00000FF6
TBLPTRU 00000FF8
TMR0 00000FD6
TMR0H 00000FD7
TMR0IE 00000005
TMR0IF 00000002
TMR0IP 00000002
TMR0L 00000FD6
TMR0ON 00000007
TMR1 00000FCE
TMR1CS 00000001
TMR1H 00000FCF
TMR1IE 00000000
TMR1IF 00000000
TMR1IP 00000000
TMR1L 00000FCE
TMR1ON 00000000
TMR2 00000FCC
TMR2IE 00000001
TMR2IF 00000001
TMR2IP 00000001
TMR2ON 00000002
TMR3 00000FB2

Microcontrollers and Application Semester: IV Academic Year: 2022-23


K. J. Somaiya College of Engineering, Mumbai-77
(A Constituent College of Somaiya Vidyavihar University)
Department of Electronics Engineering

TMR3CS 00000001
TMR3H 00000FB3
TMR3IE 00000001
TMR3IF 00000001
TMR3IP 00000001
TMR3L 00000FB2
TMR3ON 00000000
TO 00000003
TOS 00000FFD
TOSH 00000FFE
TOSL 00000FFD
TOSU 00000FFF
TOUTPS0 00000003
TOUTPS1 00000004
TOUTPS2 00000005
TOUTPS3 00000006
TRISA 00000F92
TRISA0 00000000
TRISA1 00000001
TRISA2 00000002
TRISA3 00000003
TRISA4 00000004
TRISA5 00000005
MPASM 5.51 BLINKLED.ASM 4-26-2023 12:06:23 PAGE 11

SYMBOL TABLE
LABEL VALUE

TRISA6 00000006
TRISB 00000F93
TRISB0 00000000
TRISB1 00000001
TRISB2 00000002
TRISB3 00000003
TRISB4 00000004
TRISB5 00000005
TRISB6 00000006
TRISB7 00000007
TRISC 00000F94
TRISC0 00000000
TRISC1 00000001
TRISC2 00000002
TRISC3 00000003
TRISC4 00000004

Microcontrollers and Application Semester: IV Academic Year: 2022-23


K. J. Somaiya College of Engineering, Mumbai-77
(A Constituent College of Somaiya Vidyavihar University)
Department of Electronics Engineering

TRISC5 00000005
TRISC6 00000006
TRISC7 00000007
TRISD 00000F95
TRISD0 00000000
TRISD1 00000001
TRISD2 00000002
TRISD3 00000003
TRISD4 00000004
TRISD5 00000005
TRISD6 00000006
TRISD7 00000007
TRISE 00000F96
TRISE0 00000000
TRISE1 00000001
TRISE2 00000002
TRMT 00000001
TX 00000006
TX8_9 00000006
TX9 00000006
TX9D 00000000
TXD8 00000000
TXEN 00000005
TXIE 00000004
TXIF 00000004
TXIP 00000004
TXREG 00000FAD
TXSTA 00000FAC
UA 00000001
VREFM 00000002
VREFP 00000003
W 00000000
WCOL 00000007
WDTCON 00000FD1
WR 00000001
WREG 00000FE8
WREN 00000002
MPASM 5.51 BLINKLED.ASM 4-26-2023 12:06:23 PAGE 12

SYMBOL TABLE
LABEL VALUE

WRERR 00000003
Z 00000002

Microcontrollers and Application Semester: IV Academic Year: 2022-23


K. J. Somaiya College of Engineering, Mumbai-77
(A Constituent College of Somaiya Vidyavihar University)
Department of Electronics Engineering

_BORV_20 000000FF
_BORV_20_2L 000000FF
_BORV_27_2L 000000FB
_BORV_42_2L 000000F7
_BORV_45_2L 000000F3
_BOR_OFF_2L 000000FD
_BOR_ON_2L 000000FF
_CCP2MX_OFF 000000FE
_CCP2MX_OFF_3H 000000FE
_CCP2MX_ON 000000FF
_CCP2MX_ON_3H 000000FF
_CONFIG1H 00300001
_CONFIG2H 00300003
_CONFIG2L 00300002
_CONFIG3H 00300005
_CONFIG4L 00300006
_CONFIG5H 00300009
_CONFIG5L 00300008
_CONFIG6H 0030000B
_CONFIG6L 0030000A
_CONFIG7H 0030000D
_CONFIG7L 0030000C
_CP0_OFF_5L 000000FF
_CP0_ON_5L 000000FE
_CP1_OFF_5L 000000FF
_CP1_ON_5L 000000FD
_CP2_OFF_5L 000000FF
_CP2_ON_5L 000000FB
_CP3_OFF_5L 000000FF
_CP3_ON_5L 000000F7
_CPB_OFF_5H 000000FF
_CPB_ON_5H 000000BF
_CPD_OFF_5H 000000FF
_CPD_ON_5H 0000007F
_DEBUG_OFF_4L 000000FF
_DEBUG_ON_4L 0000007F
_DEVID1 003FFFFE
_DEVID2 003FFFFF
_EBTR0_OFF_7L 000000FF
_EBTR0_ON_7L 000000FE
_EBTR1_OFF_7L 000000FF
_EBTR1_ON_7L 000000FD
_EBTR2_OFF_7L 000000FF
_EBTR2_ON_7L 000000FB
_EBTR3_OFF_7L 000000FF

Microcontrollers and Application Semester: IV Academic Year: 2022-23


K. J. Somaiya College of Engineering, Mumbai-77
(A Constituent College of Somaiya Vidyavihar University)
Department of Electronics Engineering

_EBTR3_ON_7L 000000F7
_EBTRB_OFF_7H 000000FF
_EBTRB_ON_7H 000000BF
_ECIO_OSC 000000FD
_ECIO_OSC_1H 000000FD
_EC_OSC 000000FC
MPASM 5.51 BLINKLED.ASM 4-26-2023 12:06:23 PAGE 13

SYMBOL TABLE
LABEL VALUE

_EC_OSC_1H 000000FC
_HSPLL_OSC 000000FE
_HSPLL_OSC_1H 000000FE
_HS_OSC 000000FA
_HS_OSC_1H 000000FA
_IDLOC0 00200000
_IDLOC1 00200001
_IDLOC2 00200002
_IDLOC3 00200003
_IDLOC4 00200004
_IDLOC5 00200005
_IDLOC6 00200006
_IDLOC7 00200007
_LP_OSC 000000F8
_LP_OSC_1H 000000F8
_LVP_OFF_4L 000000FB
_LVP_ON_4L 000000FF
_OSCS_OFF_1H 000000FF
_OSCS_ON_1H 000000DF
_PWRT_OFF_2L 000000FF
_PWRT_ON_2L 000000FE
_RCIO_OSC 000000FF
_RCIO_OSC_1H 000000FF
_RC_OSC 000000FB
_RC_OSC_1H 000000FB
_STVR_OFF_4L 000000FE
_STVR_ON_4L 000000FF
_WDTPS_128_2H 000000FF
_WDTPS_16_2H 000000F9
_WDTPS_1_2H 000000F1
_WDTPS_2_2H 000000F3
_WDTPS_32_2H 000000FB
_WDTPS_4_2H 000000F5

Microcontrollers and Application Semester: IV Academic Year: 2022-23


K. J. Somaiya College of Engineering, Mumbai-77
(A Constituent College of Somaiya Vidyavihar University)
Department of Electronics Engineering

_WDTPS_64_2H 000000FD
_WDTPS_8_2H 000000F7
_WDT_OFF_2H 000000FE
_WDT_ON_2H 000000FF
_WRT0_OFF_6L 000000FF
_WRT0_ON_6L 000000FE
_WRT1_OFF_6L 000000FF
_WRT1_ON_6L 000000FD
_WRT2_OFF_6L 000000FF
_WRT2_ON_6L 000000FB
_WRT3_OFF_6L 000000FF
_WRT3_ON_6L 000000F7
_WRTB_OFF_6H 000000FF
_WRTB_ON_6H 000000BF
_WRTC_OFF_6H 000000FF
_WRTC_ON_6H 000000DF
_WRTD_OFF_6H 000000FF
_WRTD_ON_6H 0000007F
_XT_OSC 000000F9
_XT_OSC_1H 000000F9
MPASM 5.51 BLINKLED.ASM 4-26-2023 12:06:23 PAGE 14

SYMBOL TABLE
LABEL VALUE

__18F452 00000001
__DEBUG 1
delay 00000110
start 00000100

Errors : 0
Warnings : 0 reported, 0 suppressed
Messages : 0 reported, 0 suppressed

Observation Table/Output of program:


Upload screenshots of output of proteus simulation and MPLAB simulation

Microcontrollers and Application Semester: IV Academic Year: 2022-23


K. J. Somaiya College of Engineering, Mumbai-77
(A Constituent College of Somaiya Vidyavihar University)
Department of Electronics Engineering

Post Lab Subjective/Objective type Questions:


Q. Write a C Program to interface ADC of PIC. (Attach C file along with snapshot of result)

Ans. #include <pic18f452.h>

// Function to initialize ADC


void ADC_Init() {
ADCON0 = 0b00000001; // Turn on ADC, select channel 0
ADCON1 = 0b00000000; // Set reference voltage and result format
}

// Function to read analog input from ADC


unsigned int ADC_Read(unsigned char channel) {
ADCON0 &= 0xC7; // Clear the channel selection bits
ADCON0 |= (channel << 3); // Select the desired channel

__delay_us(5); // Delay for ADC acquisition time

Microcontrollers and Application Semester: IV Academic Year: 2022-23


K. J. Somaiya College of Engineering, Mumbai-77
(A Constituent College of Somaiya Vidyavihar University)
Department of Electronics Engineering

ADCON0bits.GO = 1; // Start the conversion

while (ADCON0bits.GO); // Wait for the conversion to finish

return ((ADRESH << 8) + ADRESL); // Return the result as a 16-bit value


}

void main() {
unsigned int result;

TRISA = 0xFF; // Set PORTA as input

ADC_Init(); // Initialize ADC

while (1) {
result = ADC_Read(0); // Read analog input from channel 0

// Further processing with the ADC result


// ...

// You can use printf or other methods to display the result


// ...

// Add appropriate delay between ADC readings


__delay_ms(1000); // Delay for 1 second
}
}

Conclusion:
This experiment provided proteus simulation in interfacing an LED with a PIC microcontroller using C
language. By studying the ports and TRIS SFRs, we learned how to configure the microcontroller's pins and
control the LED's state. This knowledge can be applied to a wide range of applications, from simple LED
control to more complex projects involving multiple peripherals. Overall, the experiment enhanced our
understanding of the PIC microcontroller's capabilities and expanded our knowledge of working with ports

Microcontrollers and Application Semester: IV Academic Year: 2022-23


K. J. Somaiya College of Engineering, Mumbai-77
(A Constituent College of Somaiya Vidyavihar University)
Department of Electronics Engineering

and SFRs.

Signature of faculty in-charge with Date:

Microcontrollers and Application Semester: IV Academic Year: 2022-23

You might also like