summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2013-08-04 17:09:14 (GMT)
committerChristian Pointner <equinox@spreadspace.org>2013-08-04 17:09:14 (GMT)
commit1233898b3bcc6e8fc2ac0c2eafc7743aff0f7ee2 (patch)
tree2ffad6e7d75557bf2a430a6ce8de6bd4322f8a8f
parentef92f5673d1694d5a2a4920973c927ca0c8c9bf3 (diff)
improved spi send byte
git-svn-id: https://svn.spreadspace.org/pic/trunk@99 a09c6847-51d9-44de-8ef2-e725cf50f3c7
-rw-r--r--bootloader/bootloader-887.asm30
-rw-r--r--bootloader/bootloader-947.asm14
-rw-r--r--bootloader/com-16f1847-spi.inc10
-rw-r--r--bootloader/com-16f887-spi.inc10
4 files changed, 34 insertions, 30 deletions
diff --git a/bootloader/bootloader-887.asm b/bootloader/bootloader-887.asm
index e29136b..1ab7501 100644
--- a/bootloader/bootloader-887.asm
+++ b/bootloader/bootloader-887.asm
@@ -29,9 +29,9 @@
;; -------------------------------------
;; DEFINES (chip/com specific)
-#define BOOTPIN PORTC,7 ; use this for com-uart
-;; #define BOOTPIN PORTA,5 ; use this for com-spi
-;; #define INTPIN PORTA,4 ; use this for com-spi
+;; #define BOOTPIN PORTC,7 ; use this for com-uart
+#define BOOTPIN PORTA,5 ; use this for com-spi
+#define INTPIN PORTA,4 ; use this for com-spi
USERVECT EQU H'100'
ISRVECT EQU USERVECT + H'4'
FLASH_BOUNDARY EQU b'00001111' ; flash write boundary is at 16 bytes boundaries
@@ -67,19 +67,19 @@ flags EQU H'007D'
cnt EQU H'007F'
;; Boot Macro
-bootmacro macro ; use this for com-uart
- btfsc BOOTPIN
- goto USERVECT
- goto com_init
- endm
-
-;; bootmacro macro ; use this for com-spi
-;; bsf STATUS,RP0
-;; bsf STATUS,RP1
-;; bcf ANSEL,ANS4 ; RA5/SS as digital input -> BOOTPIN
+;; bootmacro macro ; use this for com-uart
+;; btfsc BOOTPIN
+;; goto USERVECT
;; goto com_init
;; endm
+bootmacro macro ; use this for com-spi
+ bsf STATUS,RP0
+ bsf STATUS,RP1
+ bcf ANSEL,ANS4 ; RA5/SS as digital input -> BOOTPIN
+ goto com_init
+ endm
+
;; -------------------------------------
;; DEFINES (defines)
#include "generic-defines.inc"
@@ -90,8 +90,8 @@ bootmacro macro ; use this for com-uart
;; -------------------------------------
;; Bootloader (com specific subroutines and init)
-#include "com-16f887-uart.inc"
-;; #include "com-16f887-spi.inc"
+;; #include "com-16f887-uart.inc"
+#include "com-16f887-spi.inc"
;; -------------------------------------
;; Bootloader (generic init/body)
diff --git a/bootloader/bootloader-947.asm b/bootloader/bootloader-947.asm
index ce7862b..3df9530 100644
--- a/bootloader/bootloader-947.asm
+++ b/bootloader/bootloader-947.asm
@@ -29,7 +29,7 @@
;; -------------------------------------
;; DEFINES (chip/com specific)
-;; #define INTPIN PORTB,3 ; use this for com-spi
+#define INTPIN PORTB,3 ; use this for com-spi
USERVECT EQU H'200'
ISRVECT EQU USERVECT + H'4'
FLASH_BOUNDARY EQU b'00011111' ; flash write boundary is at 32 bytes boundaries
@@ -84,17 +84,17 @@ bootmacro macro
preinit
movlb .3
- bcf ANSELB,ANSB1 ; use this for com-uart
- ;; bcf ANSELB,ANSB5 ; use this for com-spi
+ ;; bcf ANSELB,ANSB1 ; use this for com-uart
+ bcf ANSELB,ANSB5 ; use this for com-spi
movlb .0
- btfsc PORTB,1 ; use this for com-uart
- ;; btfsc PORTB,5 ; use this for com-spi
+ ;; btfsc PORTB,1 ; use this for com-uart
+ btfsc PORTB,5 ; use this for com-spi
goto USERVECT
goto com_init
;; -------------------------------------
;; Bootloader (com specific subroutines and init)
-#include "com-16f1847-uart.inc"
-;; #include "com-16f1847-spi.inc"
+;; #include "com-16f1847-uart.inc"
+#include "com-16f1847-spi.inc"
;; -------------------------------------
;; Bootloader (generic init/body)
diff --git a/bootloader/com-16f1847-spi.inc b/bootloader/com-16f1847-spi.inc
index c8c3f1d..e7ae182 100644
--- a/bootloader/com-16f1847-spi.inc
+++ b/bootloader/com-16f1847-spi.inc
@@ -27,12 +27,14 @@ com_tx_byte
movlb .0
bcf INTPIN
xorwf csum,f
+ movlb .4
com_tx_byte_wait1
- btfsc PORTB,5
+ btfss SSPSTAT,BF
goto com_tx_byte_wait1
-com_tx_byte_wait2
- btfss PORTB,5
- goto com_tx_byte_wait2
+ movlb .0
+com_tx_byte_wait2 ; also wait for SS to go up again
+ btfss PORTB,5 ; this lowers the risk for raise conditions
+ goto com_tx_byte_wait2 ; with next byte (INT pin)
movlb .4
movf SSP1BUF,w
movlb .0
diff --git a/bootloader/com-16f887-spi.inc b/bootloader/com-16f887-spi.inc
index 4fb41c8..800b1da 100644
--- a/bootloader/com-16f887-spi.inc
+++ b/bootloader/com-16f887-spi.inc
@@ -25,12 +25,14 @@ com_tx_byte
movwf SSPBUF
bcf INTPIN
xorwf csum,f
+ bsf STATUS,RP0
com_tx_byte_wait1
- btfsc PORTA,5
+ btfss SSPSTAT,BF
goto com_tx_byte_wait1
-com_tx_byte_wait2
- btfss PORTA,5
- goto com_tx_byte_wait2
+ bcf STATUS,RP0
+com_tx_byte_wait2 ; also wait for SS to go up again
+ btfss PORTA,5 ; this lowers the risk for raise conditions
+ goto com_tx_byte_wait2 ; with next byte (INT pin)
movf SSPBUF,w
bsf INTPIN
return