Hi all,
I thought I would post here, as this is related to uni stuff, rather than my own projects.
This is an exercise I have spent several hours trying to figure out what to do. None of my classmates can figure it out either. Any guidance would be really appreciated.
We were tasked to program a PIC 18F4520 in assembly on Proteus. Using just port D, we had to have two toggle switches which would light up a respective output LED. If both switches were closed, both LEDs would illuminate and a buzzer would also sound.
Here is the schematic I drew up:
I started by drawing out a logic table, from the schematic above, a closed switch would make a low and an open a high. From there I sketched out a rough flowchart, which is below:
Here is my program. I assume it boils down to a misunderstanding about a function.
Any pointers, or helpful hints would be much appreciated. I've tried not to waffle, but may have missed out some information. If you need any clarification or extra information, just ask. 
Regards,
Sparky
I thought I would post here, as this is related to uni stuff, rather than my own projects.
This is an exercise I have spent several hours trying to figure out what to do. None of my classmates can figure it out either. Any guidance would be really appreciated.
We were tasked to program a PIC 18F4520 in assembly on Proteus. Using just port D, we had to have two toggle switches which would light up a respective output LED. If both switches were closed, both LEDs would illuminate and a buzzer would also sound.
Here is the schematic I drew up:
I started by drawing out a logic table, from the schematic above, a closed switch would make a low and an open a high. From there I sketched out a rough flowchart, which is below:
Here is my program. I assume it boils down to a misunderstanding about a function.
Rich (BB code):
;====================================================================
; Main.asm file generated by New Project wizard
;
; Created: Thu Feb 6 2014
; Processor: PIC18F4520
; Compiler: MPASM (MPLAB)
;====================================================================
;====================================================================
; DEFINITIONS
;====================================================================
LIST P=18F4520
#include <P18f4520.INC> ; Include register definition file
;====================================================================
; VARIABLES
;====================================================================
;====================================================================
; RESET and INTERRUPT VECTORS
;====================================================================
ORG 0X0000 ;ORG
GOTO MAIN
MAIN
MOVLW 0x0F
MOVWF TRISD
LOOP BTFSC PORTD,0
GOTO DEC2
GOTO DEC1
DEC1
BTFSC PORTD,1
GOTO LEDAO
GOTO NOTO
DEC2 BTFSC PORTD,1
GOTO BUZO
GOTO LEDBO
LEDAO BCF PORTD,5
BCF PORTD,7
BSF PORTD,4
GOTO LOOP
LEDBO BCF PORTD,4
BCF PORTD,7
BSF PORTD,5
GOTO LOOP
BUZO BSF PORTD,4
BSF PORTD,5
BSF PORTD,7
GOTO LOOP
NOTO BCF PORTD,4
BCF PORTD,5
BCF PORTD,7
GOTO LOOP
;====================================================================
END
Regards,
Sparky
Attachments
-
15.2 KB Views: 133
-
50.3 KB Views: 161
Last edited by a moderator: