summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2013-07-03 22:37:15 +0000
committerChristian Pointner <equinox@spreadspace.org>2013-07-03 22:37:15 +0000
commite5894839bbcbb6570b9ea216540f9986c687ea90 (patch)
treecaedfcdbdf69ac0485404fcd28871131033de449
parentimplemented basic commands (diff)
first working uart
git-svn-id: https://svn.spreadspace.org/pic/trunk@27 a09c6847-51d9-44de-8ef2-e725cf50f3c7
-rw-r--r--bootloader/bootloader.asm47
1 files changed, 35 insertions, 12 deletions
diff --git a/bootloader/bootloader.asm b/bootloader/bootloader.asm
index c99f337..e9ba646 100644
--- a/bootloader/bootloader.asm
+++ b/bootloader/bootloader.asm
@@ -24,8 +24,8 @@
LIST p=16F887
include "p16f887.inc"
- ;; __config _CONFIG1, _DEBUG_OFF & _LVP_OFF & _FCMEN_OFF & _IESO_OFF & _BOR_OFF & _CPD_OFF & _CP_OFF & _MCLRE_OFF & _PWRTE_OFF & _WDT_OFF & _XT_OSC
- ;; __config _CONFIG2, _BOR21V & _WRT_256
+ __config _CONFIG1, _DEBUG_OFF & _LVP_OFF & _FCMEN_OFF & _IESO_OFF & _BOR_OFF & _CPD_OFF & _CP_OFF & _MCLRE_OFF & _PWRTE_OFF & _WDT_OFF & _INTOSC
+ __config _CONFIG2, _BOR21V & _WRT_256
;; -------------------------------------
;; DEFINES
@@ -53,11 +53,14 @@ CMD_R_CONFIG EQU 'c'
CMD_W_CONFIG EQU 'C'
+CNT1 EQU H'0020'
+CNT2 EQU H'0021'
+
;; -------------------------------------
;; Boot test
org 0
- btfsc BOOTPIN
- goto USERVECT
+ ;; btfsc BOOTPIN
+ ;; goto USERVECT
goto boot
;; -------------------------------------
@@ -80,12 +83,14 @@ boot
;; bank 3
bsf STATUS,RP0
bsf STATUS,RP1
- ;; movlw b'00001000' ; TX non-inverted, 16bit Baudrate, no auto baud detect
- movlw b'00011000' ; TX inverted, 16bit Baudrate, no auto baud detect
+ movlw b'00001000' ; TX non-inverted, 16bit Baudrate, no auto baud detect
+ ;; movlw b'00011000' ; TX inverted, 16bit Baudrate, no auto baud detect
movwf BAUDCTL
;; bank 1
bcf STATUS,RP1
+ movlw b'01110000' ; set internal OSC to 8MHz
+ movwf OSCCON
movlw b'00100100' ; Baudrate = High Speed, async mode, transmit enabled, 8bit
movwf TXSTA
movlw .34 ; Baudrate = 57600 (@ 8MHz) -> -0,79 % Error
@@ -99,11 +104,10 @@ boot
movlw b'10010000' ; enable Serial Port, 8bit, enable continues receive, disable address detection
movwf RCSTA
-
wait_cmd
btfsc PIR1,RCIF
goto uart_rx_byte
- btfss RCSTA,OERR
+ btfsc RCSTA,OERR
goto uart_rx_oe
goto wait_cmd
@@ -116,10 +120,12 @@ uart_rx_byte
btfsc RCSTA,FERR
goto uart_rx_fe
movf RCREG,w ; TODO: check parity??
- movwf TMP ; TODO: move to input string
+ ; TODO: move to input string
;; TODO: check if command is finished and jump
;; to 'exec_cmd'
- return
+ call uart_tx_byte
+ goto wait_cmd
+ goto exec_cmd
uart_rx_fe
movf RCREG,w
@@ -127,12 +133,29 @@ uart_rx_fe
exec_cmd
;; TODO: execute received command
- goto USERVECT
+ goto wait_cmd
;; -------------------------------------
;; dummy user code
org USERVECT
- goto USERVECT
+ ;; goto USERVECT
+ bsf STATUS,RP0
+ bcf TRISD,0
+ bcf STATUS,RP0
+userloop
+ movlw b'00000001'
+ xorwf TRISD,f
+ movlw .255
+ movwf CNT1
+usercnt1
+ movlw .255
+ movwf CNT2
+usercnt2
+ decfsz CNT2,f
+ goto usercnt2
+ decfsz CNT1,f
+ goto usercnt1
+ goto userloop
;; -------------------------------------
;; END