0% found this document useful (0 votes)
32 views

Lab 4: The Flasher Omar Kassar 201503246: Objective

This lab aims to teach students how to create delays in a microcontroller program. The student will write a program to flash left and right LEDs with a 1 second on/off cycle. They will then increase the flash frequency up to the point where the LEDs can no longer be seen flashing individually. The program uses subroutines and the CALL instruction to create the necessary delays. Registers are decremented in a nested loop to generate the time delays.

Uploaded by

Omar F'Kassar
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views

Lab 4: The Flasher Omar Kassar 201503246: Objective

This lab aims to teach students how to create delays in a microcontroller program. The student will write a program to flash left and right LEDs with a 1 second on/off cycle. They will then increase the flash frequency up to the point where the LEDs can no longer be seen flashing individually. The program uses subroutines and the CALL instruction to create the necessary delays. Registers are decremented in a nested loop to generate the time delays.

Uploaded by

Omar F'Kassar
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Lab 4: the Flasher

Omar Kassar 201503246


Objective:
in this lab we will learn the techniques of the delay by :
• Explain the principle of doing a delay = 1s
• Also we will introduce the concept of subroutine and the CALL instruction.
Ex
• Write a program that makes LL ( left LED ) and RL ( right LED ) flash with 1S
ON / 1S OFF
• change to 10pps ( pulse per second ) frequency flashing
• Keep increasing frequency till you can’t see the LEDs flashing anymore.
Solution:
a)
Flow-chart:

Code:
FLASHER BSF PORTB,0
BSF PORTB,7
CALL DELAY1S
BCF PORTB,0
BCF PORTB,7
CALL DELAY1S
GOTO FLASHER

DELAY1S MOVLW D'5'


MOVWF REF3

REFILL2 MOVLW D'255'


MOVLW REF2

REFILL1 MOVLW D'255'


MOVLW REF1

CORE DECFSZ REF1,F


GOTO CORE
DECFSZ REF2,F
GOTO REFILL1
DECFSZ REF3,F
GOTO REFILL2
RETURN

SWITCHTEST BTFSS PORTA,RA0 ;PART C)


GOTO SWITCHTEST

FLASHER10PPS BSF PORTB,0


BSF PORTB,7
CALL DELAY50MS
BCF PORTB,0
BCF PORTB,7
CALL DELAY50MS
GOTO SWITCHTEST
DELAY50MS MOVLW D'1'
MOVWF REF3

REFILL2 MOVLW D'64'


MOVLW REF2

REFILL1 MOVLW D'255'


MOVLW REF1

CORE DECFSZ REF1,F


GOTO CORE
DECFSZ REF2,F
GOTO REFILL1
DECFSZ REF3,F
GOTO REFILL2
RETURN

You might also like