forked from dtorrenp/MicroprocessorsLAB_Project
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUART.asm
More file actions
38 lines (29 loc) · 1000 Bytes
/
Copy pathUART.asm
File metadata and controls
38 lines (29 loc) · 1000 Bytes
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
#include p18f87k22.inc
global UART_Setup, UART_Transmit_Message
acs0 udata_acs ; named variables in access ram
UART_counter res 1 ; reserve 1 byte for variable UART_counter
UART code
UART_Setup
bsf RCSTA1, SPEN ; enable
bcf TXSTA1, SYNC ; synchronous
bcf TXSTA1, BRGH ; slow speed
bsf TXSTA1, TXEN ; enable transmit
bcf BAUDCON1, BRG16 ; 8-bit generator only
movlw .103 ; gives 9600 Baud rate (actually 9615)
movwf SPBRG1
bsf TRISC, TX1 ; TX1 pin as output
return
UART_Transmit_Message ; Message stored at FSR2, length stored in W
movwf UART_counter
UART_Loop_message
movf POSTINC2, W
call UART_Transmit_Byte
decfsz UART_counter
bra UART_Loop_message
return
UART_Transmit_Byte ; Transmits byte stored in W
btfss PIR1,TX1IF ; TX1IF is set when TXREG1 is empty
bra UART_Transmit_Byte
movwf TXREG1
return
end