Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
d23fd4b
Creating Table_read branch
pptman Sep 11, 2018
c8c2b72
Created UART_Hello_World branch
pptman Sep 19, 2018
f2d6dee
Updated README.md
pptman Sep 19, 2018
679b49c
Updated README.md
pptman Sep 19, 2018
9df0e71
Updated for MPLAB IDE V5.05
Sep 24, 2018
cedb2ee
Compiles for V5.4 - memory not correct yet
pptman Oct 20, 2020
81fb230
Updates for compatibility with pic-as
pptman Oct 21, 2020
724f6ce
use position definition for register bit access
pptman Oct 21, 2020
897b471
Created LCD_Hello_World_V5.4 branch
pptman Oct 22, 2020
de016dd
Don't send carriage return to LCD
pptman Oct 26, 2020
d10c58c
Changed extension to .s , added xc.inc everywhere
pptman Feb 3, 2021
173b6cb
Added Keypad_Read code
alyssamgel Mar 5, 2024
5235463
Added Keypad Decode code
alyssamgel Mar 6, 2024
b8fcaa7
Sends character to LCD
alyssamgel Mar 6, 2024
c8c1d07
made LCD_Send_Byte_D global
alyssamgel Mar 6, 2024
30e11c4
Update configurations.xml
alyssamgel Mar 8, 2024
1678c3d
Altered decode
alyssamgel Mar 8, 2024
c26d72e
IT WORKS
Mar 8, 2024
ff3bdcc
added message set up
Mar 12, 2024
8e78d2a
added messages.s
Mar 12, 2024
82c5f75
contains messages to input onto LCD
Mar 12, 2024
98dd79a
added LCD_Clear function
Mar 12, 2024
a47e5cc
Mar 12, 2024
4e3a7d3
Mar 12, 2024
e723469
Added code to read single digit
Mar 12, 2024
1a8f720
Added ':'
Mar 14, 2024
259ad35
Added function to write to second line of screen
Mar 14, 2024
1d320d4
Commented out general decode
Mar 14, 2024
d66fd1c
Added input code
Mar 14, 2024
5fa7400
Module for inputting with keypad
Mar 14, 2024
b32eeda
added new module
Mar 14, 2024
318879c
added comments
Mar 14, 2024
ebdc13a
added comments
Mar 14, 2024
2f5402a
added comments
Mar 14, 2024
79d14e8
added comments
Mar 14, 2024
fdaf9f1
Added function to shift cursor to left
Mar 15, 2024
b1c1d09
Cleaned up
Mar 15, 2024
27c6213
Added backspace (in progress)
Mar 15, 2024
4e13da9
Added backspace (in progress)
Mar 15, 2024
2828759
Added routine to return cursor to first line of LCD
Mar 19, 2024
d447d97
Added output routine
Mar 19, 2024
cc93c56
Fixed backspace and added clear and enter buttons
Mar 19, 2024
4ee944a
Added sine and cosine messages
Mar 19, 2024
c20b432
Reformatted
Mar 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
368 changes: 368 additions & 0 deletions Digit_Input.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,368 @@
#include <xc.inc>

global User_Input_Setup, Press_Clear
extrn Keypad_Read
extrn LCD_Write_Message, LCD_Clear, Second_Line, Shift_Left
extrn input_address_1, input_address_2, delay_ms, start
;extrn cordic_loop

psect udata_acs ; reserve data space in access ram
digit_counter: ds 1
d1: ds 1
d2: ds 1
input_1: ds 1
input_2: ds 1
before_dec: ds 1
enter: ds 1
clear: ds 1


psect udata_bank4 ; reserve data anywhere in RAM
myArray: ds 0x80

psect input_code, class=CODE

User_Input_Setup:
Input_1:
call User_Input_1 ; Input first digit

Input_2:
call User_Input_2 ; Input second digit

Add_Input:
movff input_1, WREG ; adding together the two digits to
; create one 8 bit number
addwf input_2, W
movwf before_dec

call delay_ms
call delay_ms
call delay_ms

Press_Enter: ; Checks to see if E button pressed
call Keypad_Read
call Decode_Enter
movwf enter

movlw 0xFF
call delay_ms

movlw 0xFF
cpfslt enter
bra Press_Enter

call LCD_Clear ; Clear screen
;call cordic_loop ; Calculate cosine and sine values

return

Press_Clear: ; Checks to see if C button pressed
call Keypad_Read
call Decode_Clear
movwf clear

movlw 0xFF
call delay_ms

movlw 0xFF
cpfslt clear
bra Press_Clear

call LCD_Clear ; Clear Screen

return

User_Input_1:
movlw input_address_1 ; address to store first digit
movwf FSR0

call Keypad_Read ; finds button pressed and stores in WREG
call Decode_Input_1 ; Decodes digit
movwf input_1

movlw 0xFF
call delay_ms

movlw 0xFF
cpfslt input_1 ; Checks for valid input
bra User_Input_1 ; repeat if valid button not pressed

movlw input_address_1
movwf FSR2
movlw 1
call LCD_Write_Message

return

User_Input_2:
movlw input_address_2 ; address to store second digit
movwf FSR0

call Keypad_Read ; finds button pressed and stores in WREG
call Decode_Input_2 ; Decodes digit
movwf input_2

movlw 0xFF
call delay_ms

movlw 0x7B
cpfseq input_2
bra No_Backspace
goto Backspace

No_Backspace:
movlw 0xFF
cpfslt input_2 ; Checks for valid input
bra User_Input_2 ; repeat if valid button not pressed

movlw input_address_2
movwf FSR2
movlw 1
call LCD_Write_Message

return

Backspace:
call Shift_Left ; backspace = shift cursor left and
; print a space
movlw 'N'

movwf FSR2
movlw 1
call LCD_Write_Message
goto Input_1

Decode_Input_1:
movwf d1, A

Error_Check_1:
movlw 0xFF
cpfseq d1, A
bra Decode_0_1
retlw 0xFF

Decode_0_1:
movlw 0x7D
cpfseq d1, A
bra Decode_1_1
movlw '0'
movwf INDF0
incf FSR0
retlw 0

Decode_1_1:
movlw 0xEE
cpfseq d1, A
bra Decode_2_1
movlw '1'
movwf INDF0
incf FSR0
retlw 10 ; stores first digit as tens

Decode_2_1:
movlw 0xED
cpfseq d1, A
bra Decode_3_1
movlw '2'
movwf INDF0
incf FSR0
retlw 20

Decode_3_1:
movlw 0xEB
cpfseq d1, A
bra Decode_4_1
movlw '3'
movwf INDF0
incf FSR0
retlw 30

Decode_4_1:
movlw 0xDE
cpfseq d1, A
bra Decode_5_1
movlw '4'
movwf INDF0
incf FSR0
retlw 40

Decode_5_1:
movlw 0xDD
cpfseq d1, A
bra Decode_6_1
movlw '5'
movwf INDF0
incf FSR0
retlw 50

Decode_6_1:
movlw 0xDB
cpfseq d1, A
bra Decode_7_1
movlw '6'
movwf INDF0
incf FSR0
retlw 60

Decode_7_1:
movlw 0xBE
cpfseq d1, A
bra Decode_8_1
movlw '7'
movwf INDF0
incf FSR0
retlw 70

Decode_8_1:
movlw 0xBD
cpfseq d1, A
bra Decode_9_1
movlw '8'
movwf INDF0
incf FSR0
retlw 80

Decode_9_1:
movlw 0xBB
cpfseq d1, A
retlw 0xFF
movlw '9'
movwf INDF0
incf FSR0
retlw 90

Decode_Input_2:
movwf d2, A

Error_Check_2:
movlw 0xFF
cpfseq d2, A
bra Decode_0_2
retlw 0xFF

Decode_0_2:
movlw 0x7D
cpfseq d2, A
bra Decode_1_2
movlw '0'
movwf INDF0
incf FSR0
retlw 0

Decode_1_2:
movlw 0xEE
cpfseq d2, A
bra Decode_2_2
movlw '1'
movwf INDF0
incf FSR0
retlw 1 ; stores second digit as units

Decode_2_2:
movlw 0xED
cpfseq d2, A
bra Decode_3_2
movlw '2'
movwf INDF0
incf FSR0
retlw 2

Decode_3_2:
movlw 0xEB
cpfseq d2, A
bra Decode_4_2
movlw '3'
movwf INDF0
incf FSR0
retlw 3

Decode_4_2:
movlw 0xDE
cpfseq d2, A
bra Decode_5_2
movlw '4'
movwf INDF0
incf FSR0
retlw 4

Decode_5_2:
movlw 0xDD
cpfseq d2, A
bra Decode_6_2
movlw '5'
movwf INDF0
incf FSR0
retlw 5

Decode_6_2:
movlw 0xDB
cpfseq d2, A
bra Decode_7_2
movlw '6'
movwf INDF0
incf FSR0
retlw 6

Decode_7_2:
movlw 0xBE
cpfseq d2, A
bra Decode_8_2
movlw '7'
movwf INDF0
incf FSR0
retlw 7

Decode_8_2:
movlw 0xBD
cpfseq d2, A
bra Decode_B_2
movlw '8'
movwf INDF0
incf FSR0
retlw 8

Decode_B_2:
movlw 0x7B
cpfseq d2, A
bra Decode_9_2
retlw 0x7B

Decode_9_2:
movlw 0xBB
cpfseq d2, A
retlw 0xFF
movlw '9'
movwf INDF0
incf FSR0
retlw 9


Decode_Enter:
movwf enter, A

Error_Check_E:
movlw 0xFF
cpfseq enter, A
bra Decode_E
retlw 0xFF

Decode_E:
movlw 0xD7
cpfseq enter, A
retlw 0xFF
return

Decode_Clear:
movwf clear, A

Error_Check_C:
movlw 0xFF
cpfseq clear, A
bra Decode_C
retlw 0xFF

Decode_C:
movlw 0x77
cpfseq clear, A
retlw 0xFF
return
Loading