summaryrefslogtreecommitdiff
path: root/software
diff options
context:
space:
mode:
authorChristian Pointner <equinox@mur.at>2013-06-30 17:40:35 +0000
committerChristian Pointner <equinox@mur.at>2013-06-30 17:40:35 +0000
commit71f93c3098e14ac5d8eacf47529045d38272a8dc (patch)
tree693028a65288130ae1d521cc8b7d4a85c6cc7e6a /software
parentfixed inverted UART for IHU-MPU Interface (diff)
moved UART code to seperate file
git-svn-id: https://svn.spreadspace.org/mur.sat@798 7de4ea59-55d0-425e-a1af-a3118ea81d4c
Diffstat (limited to 'software')
-rw-r--r--software/ihu/ihu.asm136
-rw-r--r--software/ihu/uart.inc48
2 files changed, 79 insertions, 105 deletions
diff --git a/software/ihu/ihu.asm b/software/ihu/ihu.asm
index 33ca45d..c934137 100644
--- a/software/ihu/ihu.asm
+++ b/software/ihu/ihu.asm
@@ -180,6 +180,7 @@ init
;; bank 3
bsf STATUS,RP0
bsf STATUS,RP1
+ ;; movlw b'00000000' ; TX non-inverted, 8bit Baudrate, no auto baud detect
movlw b'00010000' ; TX inverted, 8bit Baudrate, no auto baud detect
movwf BAUDCTL
movlw b'11101111' ; AN0-AN3,AN5-AN7 as analog
@@ -213,7 +214,8 @@ init
clrf ADCON1
movlw b'00100100' ; Baudrate = High Speed, async mode, transmit enabled, 8bit
movwf TXSTA
- movlw .25 ; Baudrate = 19200 (@ 8MHz)
+ ;; movlw .8 Baudrate = 57600 (@ 8MHz) -> -3,55 % Error
+ movlw .25 ; Baudrate = 19200 (@ 8MHz) -> 0,16 % Error
movwf SPBRG
clrf SPBRGH
movlw b'00100000' ; enable UART RX Interrupt
@@ -257,19 +259,7 @@ wait_loop
return
;; -------------------------------------
-uart_rx_byte
- btfsc RCSTA,FERR
- goto uart_rx_fe
- movf RCREG,w ; TODO: check parity
- movwf TMP ; TODO: move to input string
- return
-
-uart_rx_fe
- movf RCREG,w
- return
-
- ;; -------------------------------------
- ;; include "math.inc"
+ include "uart.inc"
;; -------------------------------------
include "i2c.inc"
@@ -287,6 +277,9 @@ uart_rx_fe
;; include "solar.inc"
;; -------------------------------------
+ ;; include "math.inc"
+
+ ;; -------------------------------------
;; MAINLOOP
main
; sleep
@@ -297,69 +290,26 @@ main
;; call solar_calc_power
;; movlw .255
- ;; movwf TXREG
- ;; movlw .1
- ;; call wait_ms
+ ;; call uart_tx_byte
;; movf ADC_SOLAR_C0,w
- ;; movwf TXREG
- ;; movlw .1
- ;; call wait_ms
-
+ ;; call uart_tx_byte
;; movf ADC_SOLAR_C1,w
- ;; movwf TXREG
- ;; movlw .1
- ;; call wait_ms
-
+ ;; call uart_tx_byte
;; movf ADC_SOLAR_C2,w
- ;; movwf TXREG
- ;; movlw .1
- ;; call wait_ms
-
- ;; movf ADC_SOLAR_C3,w
- ;; movwf TXREG
- ;; movlw .1
- ;; call wait_ms
+ ;; call uart_tx_byte
;; movf ADC_SOLAR_V0,w
- ;; movwf TXREG
- ;; movlw .1
- ;; call wait_ms
-
- ;; movf ADC_SOLAR_C4,w
- ;; movwf TXREG
- ;; movlw .1
- ;; call wait_ms
-
- ;; movf ADC_SOLAR_C5,w
- ;; movwf TXREG
- ;; movlw .1
- ;; call wait_ms
-
- ;; movf ADC_SOLAR_C6,w
- ;; movwf TXREG
- ;; movlw .1
- ;; call wait_ms
-
- ;; movf ADC_SOLAR_C7,w
- ;; movwf TXREG
- ;; movlw .1
- ;; call wait_ms
-
+ ;; call uart_tx_byte
;; movf ADC_SOLAR_V1,w
- ;; movwf TXREG
- ;; movlw .1
- ;; call wait_ms
+ ;; call uart_tx_byte
+ ;; movf ADC_SOLAR_V2,w
+ ;; call uart_tx_byte
;; movf SOL_POWERH,w
- ;; movwf TXREG
- ;; movlw .1
- ;; call wait_ms
-
+ ;; call uart_tx_byte
;; movf SOL_POWERL,w
- ;; movwf TXREG
- ;; movlw .8
- ;; call wait_ms
+ ;; call uart_tx_byte
;; goto main
@@ -373,58 +323,40 @@ main
swapf RTC_TOD3,w
call digit
- movwf TXREG
- movlw .1
- call wait_ms
+ call uart_tx_byte
movf RTC_TOD3,w
call digit
- movwf TXREG
- movlw .1
- call wait_ms
+ call uart_tx_byte
swapf RTC_TOD2,w
call digit
- movwf TXREG
- movlw .1
- call wait_ms
+ call uart_tx_byte
movf RTC_TOD2,w
call digit
- movwf TXREG
- movlw .1
- call wait_ms
+ call uart_tx_byte
swapf RTC_TOD1,w
call digit
- movwf TXREG
- movlw .1
- call wait_ms
+ call uart_tx_byte
movf RTC_TOD1,w
call digit
- movwf TXREG
- movlw .1
- call wait_ms
+ call uart_tx_byte
swapf RTC_TOD0,w
call digit
- movwf TXREG
- movlw .1
- call wait_ms
+ call uart_tx_byte
movf RTC_TOD0,w
call digit
- movwf TXREG
- movlw .1
- call wait_ms
+ call uart_tx_byte
movlw '\r'
- movwf TXREG
- movlw .1
- call wait_ms
+ call uart_tx_byte
movlw '\n'
- movwf TXREG
+ call uart_tx_byte
clrf TMP
goto main
@@ -438,22 +370,16 @@ main
;; call temp_read_value
;; swapf OWIRE_BYTE,w
;; call digit
- ;; movwf TXREG
- ;; movlw .1
- ;; call wait_ms
+ ;; call uart_tx_byte
;; movf OWIRE_BYTE,w
;; call digit
- ;; movwf TXREG
- ;; movlw .1
- ;; call wait_ms
+ ;; call uart_tx_byte
;; movlw '\r'
- ;; movwf TXREG
- ;; movlw .1
- ;; call wait_ms
+ ;; call uart_tx_byte
;; movlw '\n'
- ;; movwf TXREG
+ ;; call uart_tx_byte
;; clrf TMP
;; goto main
diff --git a/software/ihu/uart.inc b/software/ihu/uart.inc
new file mode 100644
index 0000000..196fc80
--- /dev/null
+++ b/software/ihu/uart.inc
@@ -0,0 +1,48 @@
+ ;;
+ ;; mur.sat
+ ;;
+ ;; Somewhen in the year 2012, mur.at will have a nano satellite launched
+ ;; into a low earth orbit (310 km above the surface of our planet). The
+ ;; satellite itself is a TubeSat personal satellite kit, developed and
+ ;; launched by interorbital systems. mur.sat is a joint venture of mur.at,
+ ;; ESC im Labor and realraum.
+ ;;
+ ;; Please visit the project hompage at sat.mur.at for further information.
+ ;;
+ ;;
+ ;; Copyright (C) 2011 Christian Pointner <equinox@mur.at>
+ ;;
+ ;; This file is part of mur.sat.
+ ;;
+ ;; mur.sat is free software: you can redistribute it and/or modify
+ ;; it under the terms of the GNU General Public License as published by
+ ;; the Free Software Foundation, either version 3 of the License, or
+ ;; any later version.
+ ;;
+ ;; mur.sat is distributed in the hope that it will be useful,
+ ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+ ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ ;; GNU General Public License for more details.
+ ;;
+ ;; You should have received a copy of the GNU General Public License
+ ;; along with mur.sat. If not, see <http://www.gnu.org/licenses/>.
+ ;;
+
+ ;; -------------------------------------
+uart_tx_byte
+ btfss PIR1,TXIF
+ goto uart_tx_byte
+ movwf TXREG
+ return
+
+ ;; -------------------------------------
+uart_rx_byte
+ btfsc RCSTA,FERR
+ goto uart_rx_fe
+ movf RCREG,w ; TODO: check parity
+ movwf TMP ; TODO: move to input string
+ return
+
+uart_rx_fe
+ movf RCREG,w
+ return