PA3040
Advanced Member level 3
- Joined
- Aug 1, 2011
- Messages
- 883
- Helped
- 43
- Reputation
- 88
- Reaction score
- 43
- Trophy points
- 1,308
- Activity points
- 6,936
char_loader equ 0x20
char_reciver equ 0x21
LIST P=P16F877
#include <p16f877a.inc>
__config 3f39
org 0x000
start goto main
main call sys_init
loop call load_char
goto loop
load_char movlw 'T'
movwf char_loader
call send_char
movlw 'E'
movwf char_loader
call send_char
movlw 'S'
movwf char_loader
call send_char
movlw 'T'
movwf char_loader
call send_char
movlw '1'
movwf char_loader
call send_char
movlw '2'
movwf char_loader
call send_char
return
send_char btfss PIR1,TXIF ;Check the USART transmit buffer is empty
goto $-1
movf char_loader,w
movwf TXREG
return
sys_init clrf PORTB
bsf STATUS,5
movlw b'10000000'
movwf TRISC
movlw 0x19
movwf SPBRG ; Set Baud rate 9600bps
movlw b'10100100' ; 8-bit transmit, transmitter enabled,
movwf TXSTA ; asynchronous mode, low speed mode
clrf TRISB
bcf STATUS,5
bsf RCSTA,SPEN ;Serial port enabled
;(configures RC7/RX/DT and
;RC6/TX/CK pins as serial port pins)
movlw b'10010000'
movwf RCSTA
return
end
char_loader equ 0x20
char_reciver equ 0x21
LIST P=16F877a
#include <p16f877a.inc>
__config 3f39
org 0x000
start goto main
main call sys_init
loop call load_char
goto loop
load_char movlw 'T'
; movwf char_loader
call send_char
movlw 'E'
; movwf char_loader
call send_char
movlw 'S'
; movwf char_loader
call send_char
movlw 'T'
; movwf char_loader
call send_char
movlw '1'
; movwf char_loader
call send_char
movlw '2'
; movwf char_loader
call send_char
; call delay500ms ; add in a little delay to slow the messages down a bit
return
send_char btfss PIR1,TXIF ;Check the USART transmit buffer is empty
goto $-1
; movf char_loader,w
movwf TXREG
return
sys_init clrf PORTB
bsf STATUS,5
movlw b'10000000'
movwf TRISC
; movlw 0x19
; movwf SPBRG ; Set Baud rate 9600bps
; movlw b'10100100' ; 8-bit transmit, transmitter enabled,
; movwf TXSTA ; asynchronous mode, low speed mode
; clrf TRISB
; bcf STATUS,5
; bsf RCSTA,SPEN ;Serial port enabled
;(configures RC7/RX/DT and
;RC6/TX/CK pins as serial port pins)
; movlw b'10010000'
; movwf RCSTA
movlw d'25' ; 9600 baud @ 4 Mhz Fosc 8 bit Async
banksel SPBRG
movwf SPBRG ; BRGH=1
movlw b'00100100'
movwf TXSTA ;enable Async Transmission, set brgh
banksel 0
movlw b'10010000'
movwf RCSTA ;enable Async Reception
return
end
Yes. You can use USB to Serial Adapter (Breakout Board). You can get it from SparkFun.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?