forked from dtorrenp/MicroprocessorsLAB_Project
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimple1.asm
More file actions
97 lines (77 loc) · 3.06 KB
/
Copy pathSimple1.asm
File metadata and controls
97 lines (77 loc) · 3.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#include p18f87k22.inc
extern LCD_Write_Hex, ADC_Setup, ADC_Read, add_check_setup, eight_bit_by_sixteen,sixteen_bit_by_sixteen,eight_bit_by_twentyfour, ADC_convert ; external ADC routines
extern UART_Setup, UART_Transmit_Message ; external UART subroutines
extern LCD_Setup, LCD_Write_Message, LCD_clear, LCD_move,LCD_delay_ms,LCD_Send_Byte_D,LCD_shiftright, LCD_delay_x4us ; external LCD subroutines
extern Pad_Setup, Pad_Read, Pad_Check
extern Input_store, Store_Input_Setup
extern Serial_Output_Setup, MIC_straight_output
acs0 udata_acs ; reserve data space in access ram
counter res 1 ; reserve one byte for a counter variable
delay_count res 1 ; reserve one byte for counter in the delay routine
tables udata 0x400 ; reserve data anywhere in RAM (here at 0x400)
myArray res 0x80 ; reserve 128 bytes for message data
rst code 0 ; reset vector
goto setup
pdata code ; a section of programme memory for storing data
; ******* myTable, data in programme memory, and its length *****
myTable data "" ; message, plus carriage return
constant myTable_l=.11 ; length of data
main code
; ******* Programme FLASH read Setup Code ***********************
setup bcf EECON1, CFGS ; point to Flash program memory
bsf EECON1, EEPGD ; access Flash program memory
call UART_Setup ; setup UART
call LCD_Setup ; setup LCD
call ADC_Setup ; setup ADC
call LCD_move ; moves LCD if wanted, not set currently
call Pad_Setup ; setup keypad entry
call Serial_Output_Setup ; setup the serial data tranfer for DAC
call Store_Input_Setup;setup code to store mic input
goto start
; ******* Main programme ****************************************
start ;call MIC_straight_output
call Pad_Check
bra start
call ADC_Read ;read ADC
call ADC_convert ;convert ADC to decimal and output to LCD
call LCD_clear ;clears the LCD
call Pad_Read
movwf PORTH
call LCD_Send_Byte_D
movlw .255
call LCD_delay_ms
movlw .255
call LCD_delay_ms
bra start
;lfsr FSR0, myArray ; Load FSR0 with address in RAM
;movlw upper(myTable) ; address of data in PM
movwf TBLPTRU ; load upper bits to TBLPTRU
movlw high(myTable) ; address of data in PM
movwf TBLPTRH ; load high byte to TBLPTRH
movlw low(myTable) ; address of data in PM
movwf TBLPTRL ; load low byte to TBLPTRL
movlw myTable_l ; bytes to read
movwf counter ; our counter register
loop tblrd*+ ; one byte from PM to TABLAT, increment TBLPRT
movff TABLAT, POSTINC0; move data from TABLAT to (FSR0), inc FSR0
decfsz counter ; count down to zero
bra loop ; keep going until finished
movlw myTable_l-1 ; output message to LCD (leave out "\n")
lfsr FSR2, myArray
call LCD_Write_Message
;call LCD_clear
movlw myTable_l ; output message to UART
lfsr FSR2, myArray
call UART_Transmit_Message
measure_loop
call ADC_Read
movf ADRESH,W
call LCD_Write_Hex
movf ADRESL,W
call LCD_Write_Hex
goto measure_loop ; goto current line in code
; a delay subroutine if you need one, times around loop in delay_count
delay decfsz delay_count ; decrement until zero
bra delay
return
end