0% found this document useful (0 votes)
1 views7 pages

en23535862_microcomputers_lab2

Micro
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)
1 views7 pages

en23535862_microcomputers_lab2

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

Sri Lanka Institute of Information Technology

Faculty of Engineering
Department of Electrical and Electronic
Engineering

EC2132: Microcomputers Laboratory


Lab 2: Sequential Display with PIC16F877A and
MAX6952 in Assembly

Name: Siriwardane KAMS


Index Number: EN23535862
Specialization: EEE
Group: 4
Submission Date: 28/10/2024
Proteus Simulation:

1
Code:

; PIC16F877A Configuration Bit Settings


; Assembly source line config statements
; CONFIG
CONFIG FOSC = EXTRC ; Oscillator Selection bits (RC oscillator)
CONFIG WDTE = OFF ; Watchdog Timer Enable bit (WDT disabled)
CONFIG PWRTE = OFF ; Power-up Timer Enable bit (PWRT disabled)
CONFIG BOREN = OFF ; Brown-out Reset Enable bit (BOR disabled)
CONFIG LVP = OFF ; Low-Voltage (Single-Supply) In-Circuit Serial Programming
;Enable bit (RB3 is digital I/O, HV on MCLR must be used for programming)
CONFIG CPD = OFF ; Data EEPROM Memory Code Protection bit (Data EEPROM
;code protection off)
CONFIG WRT = OFF ; Flash Program Memory Write Enable bits (Write protection off;
;all program memory may be written to by EECON control)
CONFIG CP = OFF ; Flash Program Memory Code Protection bit (Code protection
;off)

#include <xc.inc>

;--------initializing-------------
PSECT start, CLASS = CODE, DELTA=2
start:
PAGESEL MAIN
GOTO MAIN

loop1_15 equ 0x32


loop2_8 equ 0x33
use_delay equ 0x34
COUNTER equ 0x35

displayData equ 0x21

PSECT CODE, DELTA=2


;---------end initializing-------------

;RB0 Data
;RB1 CS
;RB2 CLK

BANKSEL TRISB ;select bank 1


CLRF TRISB ;clear TRISB
BANKSEL PORTB ;select bank 0
CLRF PORTB ;clear PORTB

2
movlw 0x04 ;configuration address loaded to WREG
movwf 0x22 ;configuration address moved to file register 0x22
movlw 0x81 ;configuration data loaded to WREG. Does not blink because
the ;MSB is 1
movwf 0x23 ; configuration data moved to file register 0x23

movlw 0x01 ;intensity 10 address loaded to WREG


movwf 0x24 ;intensity 10 address moved to file register 0x24
movlw 0xff ;set to maximum intensity
movwf 0x25

movlw 0x02 ;intensity 32 address loaded to WREG


movwf 0x26 ;intensity 32 address moved to file register 0x26
movlw 0xff ;set to maximum intensity
movwf 0x27

movlw 0x07 ;display test


movwf 0x28
movlw 0x00
movwf 0x29

movlw 0x20 ;display 1 address loaded to WREG


movwf 0x2A ; display 1 address moved to file register 0x2A
movlw 0b00110101 ;binary value represents 5 on the MAX6952
movwf 0x2B ;move the data in WREG to file register 0x2B

movlw 0x21 ;display 2 address loaded to WREG


movwf 0x2c ;display 2 address moved to file register 0x2c
movlw 0b00111000 ;binary value represents 8 on the MAX6952
movwf 0x2d ;move the data in WREG to file register 0x2d

movlw 0x22 ;display 3 address loaded to WREG


movwf 0x2e ;display 3 address moved to file register 0x2e
movlw 0b00110110 ;binary value represents 6 on the MAX6952
movwf 0x2f ;move the data in WREG to file register 0x2f

movlw 0x23 ;display 4 address loaded to WREG


movwf 0x30 ;display 4 address moved to file register 0x30
movlw 0b00110010 ;binary value represents 2 on the MAX6952
movwf 0x31 ;move the data in WREG to file register 0x31

movlw 0x21 ;load hex value 21 to WREG


movwf FSR ;FSR has the address 0x21 stored

movlw 0x0F ;load hex value 0F to WREG


movwf use_delay ;0F is stored in file register use_delay

3
movlw 0x11 ;hex value 11 (17 in denary) is moved to the WREG
movwf COUNTER ;this counts the number of registers handled by the FSR

;RB0 Data (DIN)


;RB1 CS
;RB2 CLK

first8bit_loop1:
bsf PORTB,1 ;set CS to high
CALL DELAY
BCF PORTB,2 ;clear CLK
CALL DELAY
BCF PORTB,1 ;clear CS
CALL DELAY

MOVLW 0X09 ;counter for loop1


MOVWF loop1_15
movlw 0X09 ;counter for loop2
movwf loop2_8

INCF FSR ;increment the FSR


MOVF INDF,W ;move the value pointed to by the address in the FSR to the WREG
movwf displayData ;move the value in the WREG to displayData file register

DECFSZ COUNTER, 1 ;decrement value in COUNTER


GOTO MAIN ;jump to MAIN if the value in COUNTER is not 0
GOTO END_PROGRAM ;jump to END_PROGRAM if all the data in the 16 register
are ;sent (if COUNTER is 0)

MAIN:
DECFSZ loop1_15, f ;decrement loop1 counter
goto first_word_rotation ;jump to first_word_rotation if loop1 counter is not zero
goto second8bit_loop2 ;jump to second8bit_loop2 if loop1 counter is zero

first_word_rotation:
bcf PORTB,2 ;clear CLK
CALL DELAY
BTFSS displayData,7 ;test MSB of value in displayData
goto zero1 ;jumps to zero1 if MSB is 0
bsf PORTB,0 ;set DIN to 1
CALL DELAY
BSF PORTB,2 ;set CLK to 1
CALL DELAY
BCF STATUS,0 ;clear carry flag
RLF displayData, f ;rotate value in displayData by one position to the left
goto MAIN ;repeat MAIN until loop1 counter is 0

4
zero1:
bcf PORTB,2 ;clear CLK
CALL DELAY
BCF PORTB,0 ;clear DIN
CALL DELAY
BSF PORTB,2 ;set CLK to 1
CALL DELAY
BCF STATUS,0 ;clear carry flag
RLF displayData,f ;rotate value in displayData by one position to the left
goto MAIN ;repeat MAIN until loop1 counter is 0

second8bit_loop2:
INCF FSR ;increment the FSR
MOVF INDF,W ;move the value pointed to by the address in the FSR to
the ;WREG
movwf displayData ;move the value in the WREG to displayData file register
DECF COUNTER, 1 ;decrement value in COUNTER

MAIN2:
DECFSZ loop2_8, f ;decrement loop2 counter
goto second_word_rotation ;jump to second_word_rotation if loop2 counter is not zero
goto first8bit_loop1 ;jump to first8bit_loop1 if loop2 counter is zero

second_word_rotation:
bcf PORTB,2 ;clear CLK
CALL DELAY
BTFSS displayData,7 ;test MSB of value in displayData
goto zero2 ;jumps to zero2 if MSB is 0
bsf PORTB,0 ;set DIN to 1
CALL DELAY
BSF PORTB,2 ;set CLK to 1
CALL DELAY
BCF STATUS,0 ;clear carry flag
RLF displayData, f ;rotate value in displayData by one position to the left
goto MAIN2 ;repeat MAIN2 until loop2 counter is 0

zero2:
bcf PORTB,2 ;clear CLK
CALL DELAY
BCF PORTB,0 ;clear DIN
CALL DELAY
BSF PORTB,2 ;set CLK to 1
CALL DELAY
BCF STATUS,0 ;clear carry flag
RLF displayData,f ;rotate value in displayData by one position to the left
goto MAIN ;repeat MAIN2 until loop2 counter is 0
5
END_PROGRAM: ;after all the data is sent, the PIC stops rotating the FSR and
sending ;data to the MAX6952
CALL DELAY
GOTO END_PROGRAM

DELAY:
decfsz use_delay ;decrement the value in use_delay
goto DELAY
movlw 0X0f ;move hex value 0f to WREG
movwf use_delay ;move value in WREG to use_delay
return

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