Question: Question descripted in bold below, I am having a heck of a time compiling this, just can't nut out the indexing and how to access

Question descripted in bold below, I am having a heck of a time compiling this, just can't nut out the indexing and how to access the syudent number in reverse, storing it and referencing gray code table. think i have the delays worked out ok, but really stumped with the code and no matter how many tutorials and reference material I read I jus tdont get it. My Code is written below the question.

To develop a program for the PIC 16F84A using either MPLAB X IDE simulator software.

The PIC 16F84A has 8 LEDs connected to Port B. The program is to convert your student number (10 ASCII characters), taken in reverse order, one character at a time, to Gray code. Each converted character is to be displayed on 4 of the LEDs connected to Port B (B0 to B3) of the microcontroller. Further, each converted character will be displayed for 3 seconds, with the LEDs turned OFF for 1 second between each character. Once all characters have been displayed the program will continue to run with all of the Port B LEDs flashing in a pattern of Odd Numbered LEDs On and Even Numbered LEDS Off for 1 second, and then Odd Numbered LEDs Off and Even Numbered LEDS On for 1 second. This pattern will repeat indefinitely.

; Program description:

; Assembly code to output a 10 digit ASCII coded

; student number, in reverse order, one character at a time,

; as Gray code, to 4 LEDs.

; ...

;************************************************************

;

; Directive sets processor type .............................

list p=16F84A

#include "P16F84A.INC"

; Set configuration fuses ...................................

__CONFIG _CP_OFF & _WDT_OFF &_PWRTE_ON & _RC_OSC

; Code protection off, watchdog timer off, power up timer on, RC Clock

errorlevel -302 ;No warnings about register not in Bank 0

; Register Label Equates ************************************

PORTB EQU 0x06 ;Port B

TRISB EQU 0x86 ;Data direction register B

STATUS EQU 0x03 ;Status register

Z EQU 0x02 ;Status register Z bit

RP0 EQU 0x05 ;Bank select bit

PCL EQU 0x02 ;Program counter register

FSR EQU 0x04 ;File select register (??)

INDF EQU 00 ;Address register contained in FSR (??)

; Variable definitions***************************************

UDATA_SHR

;COUNT_1 res 1

;COUNT_2 res 1

COUNT_1 EQU 0C

COUNT_2 EQU 0D

COUNT_3 EQU 0E

; Set program origin*****************************************

ORG 0x00

goto main

; Subroutines **************************************

???

; Initialise Port B output

bcf STATUS,RP0 ;Bank select 0

clrf PORTB ;Clear Port B data latches

bsf STATUS,RP0 ;Bank select 1

movlw 0x00 ;

movwf TRISB ;Set port B lines to output

bcf STATUS,RP0 ;Bank select 0

; Student number ASCII table ..............................

; Note: Your student number must be given in its correct order

; and accessed in reverse order by your code.

snum addwf PCL,F

dt "0061087137" ; student number

; Gray code table for LED display on Port B ..

binary addwf PCL,F

retlw b'00000000' ;Set display to 0

retlw b'00000001' ;Set display to 1

retlw b'00000011' ;Set display to 2

retlw b'00000110' ;Set display to 3

retlw b'00000111' ;Set display to 4

retlw b'00000101' ;Set display to 5

retlw b'00000101' ;Set display to 6

retlw b'00000100' ;Set display to 7

retlw b'00001100' ;Set display to 8

retlw b'00001101' ;Set display to 9

; Delay timer ......................................

DELAY1 movlw 0XFF ;3sec delay code

movwf COUNT_1

OLOOP movlw 0X49

movwf COUNT_2

ILOOP nop

decfsz COUNT_2, F

goto ILOOP

decfsz COUNT_1, F

goto OLOOP

RETURN

DELAY2 movlw 0XFF ;1sec delay code

movwf COUNT_1

OLOOP movlw 0X18

movwf COUNT_3

ILOOP nop

decfsz COUNT_3, F

goto ILOOP

decfsz COUNT_1, F

goto OLOOP

RETURN

; Main program **********************************************

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!