summaryrefslogtreecommitdiff
path: root/software/ihu
diff options
context:
space:
mode:
authorChristian Pointner <equinox@mur.at>2011-08-04 23:37:25 +0000
committerChristian Pointner <equinox@mur.at>2011-08-04 23:37:25 +0000
commited86861a1662c98a3267281e9f29cbed057ca2e5 (patch)
treeb06eb6bcdc00ae549af756bf0a96b592572d1471 /software/ihu
parentminor cleanup (diff)
added multiplication code
git-svn-id: https://svn.spreadspace.org/mur.sat@102 7de4ea59-55d0-425e-a1af-a3118ea81d4c
Diffstat (limited to 'software/ihu')
-rw-r--r--software/ihu/ihu.asm72
-rw-r--r--software/ihu/math.inc240
-rw-r--r--software/ihu/rtc.inc26
-rw-r--r--software/ihu/tables.inc32
4 files changed, 367 insertions, 3 deletions
diff --git a/software/ihu/ihu.asm b/software/ihu/ihu.asm
index 1c2f891..55d79a7 100644
--- a/software/ihu/ihu.asm
+++ b/software/ihu/ihu.asm
@@ -93,6 +93,18 @@ WAIT_CNT EQU H'0030'
BUF EQU H'0040'
BUF_END EQU H'004F'
+
+ ;; variables
+ ;; page 2 only
+CALC_ACC0 EQU H'0110'
+CALC_ACC1 EQU H'0111'
+CALC_ACC2 EQU H'0112'
+CALC_ACC3 EQU H'0113'
+CALC_TEMP0 EQU H'0114'
+CALC_TEMP1 EQU H'0115'
+CALC_TEMP2 EQU H'0116'
+CALC_TEMP3 EQU H'0117'
+
;; all pages
RTC_BYTE EQU H'0070'
@@ -241,6 +253,9 @@ uart_rx_fe
return
;; -------------------------------------
+ include "math.inc"
+
+ ;; -------------------------------------
include "ttx.inc"
;; -------------------------------------
@@ -260,6 +275,63 @@ main
movwf FSR
call rtc_get_time
+ swapf BUF+4,w
+ andlw b'00000011'
+ call digit
+ movwf TXREG
+ movlw .1
+ call wait_ms
+
+ movf BUF+4,w
+ andlw b'00001111'
+ call digit
+ movwf TXREG
+ movlw .1
+ call wait_ms
+
+ movlw '.'
+ movwf TXREG
+ movlw .1
+ call wait_ms
+
+ swapf BUF+5,w
+ andlw b'00000001'
+ call digit
+ movwf TXREG
+ movlw .1
+ call wait_ms
+
+ movf BUF+5,w
+ andlw b'00001111'
+ call digit
+ movwf TXREG
+ movlw .1
+ call wait_ms
+
+ movlw '.'
+ movwf TXREG
+ movlw .1
+ call wait_ms
+
+ swapf BUF+6,w
+ andlw b'00001111'
+ call digit
+ movwf TXREG
+ movlw .1
+ call wait_ms
+
+ movf BUF+6,w
+ andlw b'00001111'
+ call digit
+ movwf TXREG
+ movlw .1
+ call wait_ms
+
+ movlw ' '
+ movwf TXREG
+ movlw .1
+ call wait_ms
+
swapf BUF+2,w
andlw b'00000011'
call digit
diff --git a/software/ihu/math.inc b/software/ihu/math.inc
new file mode 100644
index 0000000..4efd391
--- /dev/null
+++ b/software/ihu/math.inc
@@ -0,0 +1,240 @@
+ ;;
+ ;; mur.sat
+ ;;
+ ;; Somewhen in the year 2011, 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/>.
+ ;;
+
+ ;; -------------------------------------
+ ;; code generated by http://www.piclist.com/cgi-bin/constdivmul.exe
+mul60
+ bsf STATUS,RP1
+ movwf CALC_ACC0
+
+ bcf STATUS,C
+ rlf CALC_ACC0,f
+ clrf CALC_ACC1
+ rlf CALC_ACC1,f
+ rlf CALC_ACC0,f
+ rlf CALC_ACC1,f
+
+ movf CALC_ACC1,w
+ movwf CALC_TEMP1
+ movf CALC_ACC0,w
+ movwf CALC_TEMP0
+
+ comf CALC_ACC0,f
+ comf CALC_ACC1,f
+ incf CALC_ACC0,f
+ skpnz
+ incf CALC_ACC1,f
+
+ swapf CALC_TEMP1,f
+ swapf CALC_TEMP0,f
+ movf CALC_TEMP0,w
+ andlw b'00001111'
+ xorwf CALC_TEMP0,f
+ iorwf CALC_TEMP1,f
+
+ movf CALC_TEMP0,w
+ addwf CALC_ACC0,f
+ movf CALC_TEMP1,w
+ btfsc STATUS,C
+ incfsz CALC_TEMP1,w
+ addwf CALC_ACC1,f
+
+ bcf STATUS,RP1
+ return
+
+ ;; ----------------------
+mul3600
+ bsf STATUS,RP1
+ movwf CALC_ACC0
+
+ swapf CALC_ACC0,f
+ movf CALC_ACC0,w
+ andlw b'00001111'
+ xorwf CALC_ACC0,f
+ movwf CALC_ACC1
+
+ movf CALC_ACC1,w
+ movwf CALC_TEMP1
+ movf CALC_ACC0,w
+ movwf CALC_TEMP0
+
+ swapf CALC_TEMP1,f
+ swapf CALC_TEMP0,f
+ movf CALC_TEMP0,w
+ andlw b'00001111'
+ xorwf CALC_TEMP0,f
+ iorwf CALC_TEMP1,f
+ bcf STATUS,C
+ rlf CALC_TEMP0,f
+ rlf CALC_TEMP1,f
+ clrf CALC_TEMP2
+ rlf CALC_TEMP2,f
+
+ clrf CALC_ACC2
+ movf CALC_TEMP0,w
+ subwf CALC_ACC0,f
+ movf CALC_TEMP1,w
+ skpc
+ incfsz CALC_TEMP1,w
+ subwf CALC_ACC1,f
+ movf CALC_TEMP2,w
+ skpc
+ incfsz CALC_TEMP2,w
+ subwf CALC_ACC2,f
+
+ bcf STATUS,C
+ rlf CALC_TEMP0,f
+ rlf CALC_TEMP1,f
+ rlf CALC_TEMP2,f
+ rlf CALC_TEMP0,f
+ rlf CALC_TEMP1,f
+ rlf CALC_TEMP2,f
+ rlf CALC_TEMP0,f
+ rlf CALC_TEMP1,f
+ rlf CALC_TEMP2,f
+
+ movf CALC_TEMP0,w
+ addwf CALC_ACC0,f
+ movf CALC_TEMP1,w
+ btfsc STATUS,C
+ incfsz CALC_TEMP1,w
+ addwf CALC_ACC1,f
+ movf CALC_TEMP2,w
+ btfsc STATUS,C
+ incfsz CALC_TEMP2,w
+ addwf CALC_ACC2,f
+
+ bcf STATUS,RP1
+ return
+
+ ;; ----------------------
+mul86400
+ bsf STATUS,RP1
+
+ rrf CALC_ACC1,f
+ rrf CALC_ACC0,w
+ movwf CALC_ACC1
+ clrf CALC_ACC0
+ rrf CALC_ACC0,f
+
+ movf CALC_ACC1,w
+ movwf CALC_TEMP1
+ movf CALC_ACC0,w
+ movwf CALC_TEMP0
+
+ bcf STATUS,C
+ rlf CALC_TEMP0,f
+ rlf CALC_TEMP1,f
+ clrf CALC_TEMP2
+ rlf CALC_TEMP2,f
+
+ clrf CALC_ACC2
+ movf CALC_TEMP0,w
+ addwf CALC_ACC0,f
+ movf CALC_TEMP1,w
+ btfsc STATUS,C
+ incfsz CALC_TEMP1,w
+ addwf CALC_ACC1,f
+ movf CALC_TEMP2,w
+ btfsc STATUS,C
+ incfsz CALC_TEMP2,w
+ addwf CALC_ACC2,f
+
+ swapf CALC_TEMP2,f
+ swapf CALC_TEMP1,f
+ movf CALC_TEMP1,w
+ andlw b'00001111'
+ xorwf CALC_TEMP1,f
+ iorwf CALC_TEMP2,f
+ swapf CALC_TEMP0,f
+ movf CALC_TEMP0,w
+ andlw b'00001111'
+ xorwf CALC_TEMP0,f
+ iorwf CALC_TEMP1,f
+
+ movf CALC_TEMP0,w
+ addwf CALC_ACC0,f
+ movf CALC_TEMP1,w
+ btfsc STATUS,C
+ incfsz CALC_TEMP1,w
+ addwf CALC_ACC1,f
+ movf CALC_TEMP2,w
+ btfsc STATUS,C
+ incfsz CALC_TEMP2,w
+ addwf CALC_ACC2,f
+
+ bcf STATUS,C
+ rlf CALC_TEMP0,f
+ rlf CALC_TEMP1,f
+ rlf CALC_TEMP2,f
+ rlf CALC_TEMP0,f
+ rlf CALC_TEMP1,f
+ rlf CALC_TEMP2,f
+
+ movf CALC_TEMP0,w
+ addwf CALC_ACC0,f
+ movf CALC_TEMP1,w
+ btfsc STATUS,C
+ incfsz CALC_TEMP1,w
+ addwf CALC_ACC1,f
+ movf CALC_TEMP2,w
+ btfsc STATUS,C
+ incfsz CALC_TEMP2,w
+ addwf CALC_ACC2,f
+
+ bcf STATUS,C
+ rlf CALC_TEMP0,f
+ rlf CALC_TEMP1,f
+ rlf CALC_TEMP2,f
+ rlf CALC_TEMP0,f
+ rlf CALC_TEMP1,f
+ rlf CALC_TEMP2,f
+ clrf CALC_TEMP3
+ rlf CALC_TEMP3,f
+
+ clrf CALC_ACC3
+ movf CALC_TEMP0,w
+ addwf CALC_ACC0,f
+ movf CALC_TEMP1,w
+ btfsc STATUS,C
+ incfsz CALC_TEMP1,w
+ addwf CALC_ACC1,f
+ movf CALC_TEMP2,w
+ btfsc STATUS,C
+ incfsz CALC_TEMP2,w
+ addwf CALC_ACC2,f
+ movf CALC_TEMP3,w
+ btfsc STATUS,C
+ incfsz CALC_TEMP3,w
+ addwf CALC_ACC3,f
+
+ bcf STATUS,RP1
+ return
+ ;; -------------------------------------
diff --git a/software/ihu/rtc.inc b/software/ihu/rtc.inc
index ba76bdb..79b4bdc 100644
--- a/software/ihu/rtc.inc
+++ b/software/ihu/rtc.inc
@@ -209,15 +209,35 @@ rtc_init_after_clock_fail
btfsc RTC_BYTE,0
goto rtc_error_ack
- movlw .16
+ movlw .4
movwf RTC_BYTE_CNT
-rtc_init_clear
+rtc_init_clear1
clrw
call i2c_send_byte
btfsc RTC_BYTE,0
goto rtc_error_ack
decfsz RTC_BYTE_CNT,f
- goto rtc_init_clear
+ goto rtc_init_clear1
+
+ movlw .2
+ movwf RTC_BYTE_CNT
+rtc_init_clear2
+ movlw .1
+ call i2c_send_byte
+ btfsc RTC_BYTE,0
+ goto rtc_error_ack
+ decfsz RTC_BYTE_CNT,f
+ goto rtc_init_clear2
+
+ movlw .10
+ movwf RTC_BYTE_CNT
+rtc_init_clear3
+ clrw
+ call i2c_send_byte
+ btfsc RTC_BYTE,0
+ goto rtc_error_ack
+ decfsz RTC_BYTE_CNT,f
+ goto rtc_init_clear3
call i2c_stop
return
diff --git a/software/ihu/tables.inc b/software/ihu/tables.inc
index 1050a5e..5a72504 100644
--- a/software/ihu/tables.inc
+++ b/software/ihu/tables.inc
@@ -68,5 +68,37 @@ mul10
retlw .140
retlw .150
retlw .160
+
+daysL
+ addwf PCL,f
+ retlw .0
+ retlw .0
+ retlw .31
+ retlw .60
+ retlw .91
+ retlw .121
+ retlw .152
+ retlw .182
+ retlw .213
+ retlw .244
+ retlw .18
+ retlw .49
+ retlw .79
+daysH
+ addwf PCL,f
+ retlw .0
+ retlw .0
+ retlw .0
+ retlw .0
+ retlw .0
+ retlw .0
+ retlw .0
+ retlw .0
+ retlw .0
+ retlw .0
+ retlw .1
+ retlw .1
+ retlw .1
+
;; -------------------------------------