From 297ac49867b750bfeeeca3a354619c527468cc41 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Wed, 10 Jul 2013 03:57:48 +0000 Subject: added bootloader for IHU git-svn-id: https://svn.spreadspace.org/mur.sat@807 7de4ea59-55d0-425e-a1af-a3118ea81d4c --- software/ihu/Makefile | 11 +++++++++++ software/ihu/ihu.asm | 23 ++++++++++++++++------- software/ihu/tables.inc | 8 ++++++++ 3 files changed, 35 insertions(+), 7 deletions(-) (limited to 'software/ihu') diff --git a/software/ihu/Makefile b/software/ihu/Makefile index a5184a8..3b4bb1e 100644 --- a/software/ihu/Makefile +++ b/software/ihu/Makefile @@ -32,3 +32,14 @@ PROJECT := ihu PROC_TYPE := 16F887 include ../pic.include.mk + +DOWNLOADER := ../pic.bootloader/downloader.py +BOOT_NAME := IHU +BOOT_BAUD := 57600 + +download: $(HEXFILE) + @$(DOWNLOADER) --name=$(BOOT_NAME) --cmd write $< + @$(DOWNLOADER) --name=$(BOOT_NAME) --cmd verify $< + +boot: + @$(DOWNLOADER) --name=$(BOOT_NAME) --cmd boot dummy diff --git a/software/ihu/ihu.asm b/software/ihu/ihu.asm index a4c53a4..e84eb9a 100644 --- a/software/ihu/ihu.asm +++ b/software/ihu/ihu.asm @@ -32,8 +32,13 @@ LIST p=16F887 include "p16f887.inc" - __config _CONFIG1, _DEBUG_OFF & _LVP_OFF & _FCMEN_OFF & _IESO_OFF & _BOR_NSLEEP & _CPD_OFF & _CP_OFF & _MCLRE_OFF & _PWRTE_ON & _WDT_OFF & _XT_OSC - __config _CONFIG2, _BOR21V & _WRT_OFF + ;; This is specified via bootloader-IHU.asm + ;; __config _CONFIG1, _DEBUG_OFF & _LVP_OFF & _FCMEN_OFF & _IESO_OFF & _BOR_NSLEEP & _CPD_OFF & _CP_OFF & _MCLRE_OFF & _PWRTE_ON & _WDT_OFF & _XT_OSC + ;; __config _CONFIG2, _BOR21V & _WRT_OFF + +BOOTLOADER EQU H'003' +USERVECT EQU H'100' +ISRVECT EQU H'104' ;; ------------------------------------- ;; DEFINES @@ -114,12 +119,12 @@ STATUS_TEMP EQU H'007F' ;; ------------------------------------- ;; Reset Vector - org 0 + org USERVECT ; end of bootloader goto init ;; ------------------------------------- ;; Interrupt Vector - org 4 + org ISRVECT ; replocated ISR vector ;; save context movwf W_TEMP swapf STATUS,W @@ -199,7 +204,8 @@ init clrf PSTRCON ; disable pulse steering movlw b'00010000' ; preselct 125 kHz, clock source as configured by configuration word movwf OSCCON - movlw b'11001111' ; input: RA0-RA3(analog),RA6-RA7(OSC); output: RA4-RA5(1wire) + ;; movlw b'11001111' ; input: RA0-RA3(analog),RA6-RA7(OSC); output: RA4-RA5(1wire) + movlw b'11011111' ; input: RA0-RA3(analog),RA6-RA7(OSC), RA4(BOOTPIN); output: RA5(1wire) movwf TRISA movlw b'11111111' ; input: all (interrupts and stats) movwf TRISB @@ -235,14 +241,17 @@ init call i2c_init clrf TMR0 - bsf INTCON,GIE clrf TMP + bsf INTCON,GIE + + btfsc RTC_RST ; if RTC is already finished, initialize it! + call rtc_init ; this maybe happend already via interrupt but better save than sorry goto main ;; ------------------------------------- ;; TABLES - include "tables.inc" + include "tables.inc" ; this needs to stay inside 0x100 and 0x200 ;; ------------------------------------- ;; SUBROUTINES diff --git a/software/ihu/tables.inc b/software/ihu/tables.inc index 3e42a41..99d104f 100644 --- a/software/ihu/tables.inc +++ b/software/ihu/tables.inc @@ -31,6 +31,8 @@ ;; ------------------------------------- ;; digit digit + clrf PCLATH ; this table is betwenn 0x100 and 0x200 + incf PCLATH,f ; load PCLATH without changing W andlw b'00001111' addwf PCL,f retlw '0' @@ -51,6 +53,8 @@ digit retlw 'F' mul10 + clrf PCLATH ; this table is betwenn 0x100 and 0x200 + incf PCLATH,f ; load PCLATH without changing W addwf PCL,f retlw .0 retlw .10 @@ -71,6 +75,8 @@ mul10 retlw .160 daysL + clrf PCLATH ; this table is betwenn 0x100 and 0x200 + incf PCLATH,f ; load PCLATH without changing W addwf PCL,f retlw .0 retlw .0 @@ -87,6 +93,8 @@ daysL retlw .79 daysH + clrf PCLATH ; this table is betwenn 0x100 and 0x200 + incf PCLATH,f ; load PCLATH without changing W addwf PCL,f retlw .0 retlw .0 -- cgit v1.2.3