Mercurial > public > mk2
changeset 469:f53aa96ff2f4
SPI for sensor in 32MHz
author | heinrichsweikamp |
---|---|
date | Thu, 06 Oct 2011 23:30:47 +0200 |
parents | 8d69c040b9fc |
children | 42acd9316f7a |
files | code_part1/OSTC_code_asm_part1/alt_wait.asm code_part1/OSTC_code_asm_part1/ms5535.asm code_part1/OSTC_code_asm_part1/start.asm code_part1/OSTC_code_asm_part1/surfmode.asm |
diffstat | 4 files changed, 33 insertions(+), 422 deletions(-) [+] |
line wrap: on
line diff
--- a/code_part1/OSTC_code_asm_part1/alt_wait.asm Mon Oct 03 09:38:20 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,399 +0,0 @@ -; OSTC - diving computer code -; Copyright (C) 2008 HeinrichsWeikamp GbR -; This program 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 -; (at your option) any later version. -; This program 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 this program. If not, see <http://www.gnu.org/licenses/>. -; Wait routines -; written by: chsw, info@heinrichsweikamp.com -; written: 01/31/04 -; last updated: 11/05/07 -; known bugs: -; ToDo: - IFDEF Clk_4_MHZ - MESSG "wait_v2i: switched to 4 MHZ operation" - ELSE - IFDEF Clk_8_MHZ - MESSG "wait_v2i: switched to 8 MHZ operation" - ELSE - IFDEF Clk_16_MHZ - MESSG "wait_v2i: switched to 16 MHZ operation" - ELSE - IFDEF Clk_20_MHZ - MESSG "wait_v2i: switched to 20 MHZ operation" - ELSE - ERROR "wait_v2i: Operating Frequency has to be specified by #DEFINE Clk_4_MHZ or Clk_8_MHZ" - ENDIF - ENDIF - ENDIF - IFDEF Clk_16_MHZ -; ========================================================== -; WAIT 10 MICROSECONDS - 16 MHZ -; ========================================================== -WAIT10US macro wait_temp - movlw wait_temp - IFNDEF DEBUG - call WAIT10USX - ENDIF - endm - -WAIT10USX movwf wait_temp - goto JumpIn10us -WAIT10USX2 nop - nop - nop - nop - nop - nop - nop - nop - nop -JumpIn10us: - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - decfsz wait_temp,1 - goto WAIT10USX2 - return -; ========================================================== -; WAIT 1 MILLISECOND - 16 MHZ -; ========================================================== -WAITMS macro waitms_temp - movlw waitms_temp - IFNDEF DEBUG - call WAITMSX - ENDIF - endm -WAITMSX movwf waitms_temp - goto JumpInMSX -WAITMSX2 nop - nop - nop - nop - nop - nop - nop - nop - nop -JumpInMSX: - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - WAIT10US d'99' - decfsz waitms_temp,1 - goto WAITMSX2 - return - ELSE - IFDEF Clk_8_MHZ -; ========================================================== -; WAIT 10 MICROSECONDS - 8 MHZ -; ========================================================== -WAIT10US macro wait_temp - movlw wait_temp - IFNDEF DEBUG - call WAIT10USX - ENDIF - endm -WAIT10USX movwf wait_temp - goto JumpIn10us -WAIT10USX2 nop - nop - nop - nop - nop - nop - nop -JumpIn10us: - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - decfsz wait_temp,1 - goto WAIT10USX2 - return -; ========================================================== -; WAIT 1 MILLISECOND - 8 MHZ -; ========================================================== -WAITMS macro waitms_temp - movlw waitms_temp - IFNDEF DEBUG - call WAITMSX - ENDIF - endm -WAITMSX movwf waitms_temp - goto JumpInMSX - -WAITMSX2 nop - nop - nop - nop - nop - nop - nop -JumpInMSX: - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - WAIT10US d'99' - decfsz waitms_temp,1 - goto WAITMSX2 - return - ELSE - IFDEF Clk_4_MHZ -; ========================================================== -; WAIT 10 MICROSECONDS - 4 MHZ -; ========================================================== -WAIT10US macro wait_temp - movlw wait_temp - IFNDEF DEBUG - call WAIT10USX - ENDIF - endm -WAIT10USX movwf wait_temp - goto JumpIn10us -WAIT10USX2 nop - nop - nop - nop - nop - nop - nop -JumpIn10us: - decfsz wait_temp,1 - goto WAIT10USX2 - return -; ========================================================== -; WAIT 1 MILLISECOND - 4 MHZ -; ========================================================== -WAITMS macro waitms_temp - movlw waitms_temp - IFNDEF DEBUG - call WAITMSX - ENDIF - endm -WAITMSX movwf waitms_temp - goto JumpInMSX - -WAITMSX2 nop - nop - nop - nop - nop - nop - nop -JumpInMSX: - WAIT10US d'99' - decfsz waitms_temp,1 - goto WAITMSX2 - return - ELSE - IFDEF Clk_20_MHZ - ========================================================== -; WAIT 10 MICROSECONDS - 20 MHZ -; ========================================================== -WAIT10US macro wait_temp - movlw wait_temp - IFNDEF DEBUG - call WAIT10USX - ENDIF - endm -WAIT10USX movwf wait_temp - goto JumpIn10us -WAIT10USX2 nop - nop - nop - nop - nop - nop - nop -JumpIn10us: - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - decfsz wait_temp,1 - goto WAIT10USX2 - return -; ========================================================== -; WAIT 1 MILLISECOND - 20 MHZ -; ========================================================== -WAITMS macro waitms_temp - movlw waitms_temp - IFNDEF DEBUG - call WAITMSX - ENDIF - endm -WAITMSX movwf waitms_temp - goto JumpInMSX - -WAITMSX2 nop - nop - nop - nop - nop - nop - nop -JumpInMSX: - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - WAIT10US d'99' - decfsz waitms_temp,1 - goto WAITMSX2 - return - ENDIF - ENDIF - ENDIF - ENDIF - ENDIF - - -wait_one_second: - WAITMS d'250' - WAITMS d'250' - WAITMS d'250' - WAITMS d'250' - return
--- a/code_part1/OSTC_code_asm_part1/ms5535.asm Mon Oct 03 09:38:20 2011 +0200 +++ b/code_part1/OSTC_code_asm_part1/ms5535.asm Thu Oct 06 23:30:47 2011 +0200 @@ -430,8 +430,8 @@ nop nop nop - nop - nop + btfsc OSCCON,4 ; 32MHz Mode? + rcall MS5535A_extra_wait ; Yes bcf sensor_CLK return @@ -443,11 +443,19 @@ nop nop nop - nop - nop + btfsc OSCCON,4 ; 32MHz Mode? + rcall MS5535A_extra_wait ; Yes bcf sensor_CLK return +MS5535A_extra_wait: + nop + nop + nop + nop + nop + return + reset_MS5535A: rcall reset_MS5535A_one ;0 rcall reset_MS5535A_zero @@ -487,8 +495,8 @@ nop nop nop - nop - nop + btfsc OSCCON,4 ; 32MHz Mode? + rcall MS5535A_extra_wait ; Yes bcf sensor_CLK return @@ -498,8 +506,8 @@ nop nop nop - nop - nop + btfsc OSCCON,4 ; 32MHz Mode? + rcall MS5535A_extra_wait ; Yes bcf sensor_CLK btfss sensor_SDI ;MSB first bcf STATUS,C @@ -521,39 +529,39 @@ nop nop nop - nop - nop + btfsc OSCCON,4 ; 32MHz Mode? + rcall MS5535A_extra_wait ; Yes bcf sensor_CLK nop nop nop nop - nop - nop + btfsc OSCCON,4 ; 32MHz Mode? + rcall MS5535A_extra_wait ; Yes bsf sensor_CLK nop nop nop nop - nop - nop + btfsc OSCCON,4 ; 32MHz Mode? + rcall MS5535A_extra_wait ; Yes bcf sensor_CLK nop nop nop nop - nop - nop + btfsc OSCCON,4 ; 32MHz Mode? + rcall MS5535A_extra_wait ; Yes bsf sensor_CLK nop nop nop nop - nop - nop + btfsc OSCCON,4 ; 32MHz Mode? + rcall MS5535A_extra_wait ; Yes bcf sensor_CLK ; now send 8 bytes from isr_temp1 and fill-up with zeros -datenbits: +databits: btfss isr1_temp,7 ;MSB first bcf sensor_SDO btfsc isr1_temp,7 ;MSB first @@ -566,10 +574,10 @@ nop nop nop - nop - nop + btfsc OSCCON,4 ; 32MHz Mode? + rcall MS5535A_extra_wait ; Yes bcf sensor_CLK decfsz clock_count,F - bra datenbits + bra databits return
--- a/code_part1/OSTC_code_asm_part1/start.asm Mon Oct 03 09:38:20 2011 +0200 +++ b/code_part1/OSTC_code_asm_part1/start.asm Thu Oct 06 23:30:47 2011 +0200 @@ -272,7 +272,7 @@ ; Pre-load modes for OC, GF 90/90 and no Aponoe or Gauge. bcf no_deco_customviews ; Clear no-deco-mode-flag movlw d'0' - movff WREG,char_I_deco_model ; Clear Flagbyte + movff WREG,char_I_deco_model ; ZH-L16 ; Load GF values into RAM movlw d'90' movff WREG,char_I_GF_Low_percentage
--- a/code_part1/OSTC_code_asm_part1/surfmode.asm Mon Oct 03 09:38:20 2011 +0200 +++ b/code_part1/OSTC_code_asm_part1/surfmode.asm Thu Oct 06 23:30:47 2011 +0200 @@ -99,6 +99,8 @@ ; Desaturation time needs: ; int_I_pres_surface ; char_I_desaturation_multiplier + movlw d'0' + movff WREG,char_I_deco_model ; ZH-L16 GETCUSTOM8 d'12' ; Desaturation multiplier % movff WREG,char_I_desaturation_multiplier