From 43ec5c5d9f5cb2ce698dc6f6591cde81a059bcef Mon Sep 17 00:00:00 2001 From: Tobias Date: Mon, 28 Sep 2015 11:02:58 +0200 Subject: [PATCH] Config Bytes Part II Programmer: clear OWID in dual mode. Remove 0xCC --- DS18B20_BMP280/DS18B20_BMP280.c | 8 +++---- DS18B20_DS2438/DS18B20_DS2438.c | 6 ++--- DS18B20_MAX44009/DS18B20_MAX44009.c | 2 +- common/OWRomFunctions.s | 1 + common/OWRomFunctionsDual.s | 23 ++++++++++++++++++ programmer/programmer/programmer.asm | 35 +++++++++++++++++----------- 6 files changed, 53 insertions(+), 22 deletions(-) diff --git a/DS18B20_BMP280/DS18B20_BMP280.c b/DS18B20_BMP280/DS18B20_BMP280.c index ca6333b..313a368 100644 --- a/DS18B20_BMP280/DS18B20_BMP280.c +++ b/DS18B20_BMP280/DS18B20_BMP280.c @@ -47,8 +47,8 @@ extern void OWINIT(); -uint8_t owid[8]={0x28, 0xA2, 0xD9, 0x84, 0x00, 0x16, 0x77, 0x6B};/**/ -uint8_t config_info[16]={0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x10,0x11,0x12,0x13,0x14,0x15,0x16}; +uint8_t owid[8]={0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x40};/**/ +uint8_t config_info[16]={0x02,0x03, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; #if (owid>128) #error "Variable not correct" @@ -111,8 +111,8 @@ int main(void){ uint32_t P; int32_t t; bmp280ConvertInt(&t,&P,1); - P=P*16; - P=P/1000; + P=P-70000; + P=P/20; uint16_t w=P; uint8_t t8=w>>4; uint8_t af=0; diff --git a/DS18B20_DS2438/DS18B20_DS2438.c b/DS18B20_DS2438/DS18B20_DS2438.c index 4bef0d2..e995108 100644 --- a/DS18B20_DS2438/DS18B20_DS2438.c +++ b/DS18B20_DS2438/DS18B20_DS2438.c @@ -48,9 +48,9 @@ extern void OWINIT(); uint8_t owid1[8]={0x28, 0xA3, 0xD9, 0x84, 0x00, 0x16, 0x05, 0x18};/**/ -uint8_t owid2[8]={0x26, 0xA2, 0xD9, 0x84, 0x00, 0x00, 0x01, 0x77};/**/ -uint8_t config_info1[16]={0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; -uint8_t config_info2[16]={0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; +uint8_t owid2[8]={0x26, 0xA3, 0xD9, 0x84, 0x00, 0x16, 0x05, 0x67};/**/ +uint8_t config_info1[16]={0x03,0x04, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; +uint8_t config_info2[16]={0x01,0x06, 0x05,0x00, 0x04,0x07, 0x00,0x00, 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; #if (owid>128) #error "Variable not correct" diff --git a/DS18B20_MAX44009/DS18B20_MAX44009.c b/DS18B20_MAX44009/DS18B20_MAX44009.c index 359d95e..3bd4e66 100644 --- a/DS18B20_MAX44009/DS18B20_MAX44009.c +++ b/DS18B20_MAX44009/DS18B20_MAX44009.c @@ -48,7 +48,7 @@ extern void OWINIT(); uint8_t owid[8]={0x28, 0xA2, 0xD9, 0x84, 0x00, 0x16, 0x77, 0x6B};/**/ -uint8_t config_info[16]={0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; +uint8_t config_info[16]={0x03,0x04, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; #if (owid>128) #error "Variable not correct" diff --git a/common/OWRomFunctions.s b/common/OWRomFunctions.s index 41a952f..aa7891d 100644 --- a/common/OWRomFunctions.s +++ b/common/OWRomFunctions.s @@ -202,6 +202,7 @@ hrc_set_alarm_search: hrc_fw_configinfo: ldi r_mode,OW_FWCONFIGINFO ldi r_sendflag,1 + CRCInit2 rjmp h_fwconfiginfo diff --git a/common/OWRomFunctionsDual.s b/common/OWRomFunctionsDual.s index f9ffb2f..09ed5be 100644 --- a/common/OWRomFunctionsDual.s +++ b/common/OWRomFunctionsDual.s @@ -229,11 +229,13 @@ hrc_set_alarm_search: hrc_fw_configinfo1: ldi r_mode,OW_FWCONFIGINFO1 ldi r_sendflag,1 + CRCInit2 rjmp h_fwconfiginfo1 hrc_fw_configinfo2: ldi r_mode,OW_FWCONFIGINFO2 ldi r_sendflag,1 + CRCInit2 rjmp h_fwconfiginfo2 @@ -610,6 +612,27 @@ owinit_odgen2: brne owinit_odgen2 dec r_bytep brne owinit_odgen1 + ;copy ids in config bytes + ldi xl,lo8(owid1) + ldi xh,hi8(owid1) + ldi yl,lo8(config_info2+9) + ldi yh,hi8(config_info2+9) + ldi r_temp,7 +owinit_cpconfig1: + ld r_rwbyte,X+ + st Y+,r_rwbyte + dec r_temp + brne owinit_cpconfig1 + ldi xl,lo8(owid2) + ldi xh,hi8(owid2) + ldi yl,lo8(config_info1+9) + ldi yh,hi8(config_info1+9) + ldi r_temp,7 +owinit_cpconfig2: + ld r_rwbyte,X+ + st Y+,r_rwbyte + dec r_temp + brne owinit_cpconfig2 ldi r_temp,0 diff --git a/programmer/programmer/programmer.asm b/programmer/programmer/programmer.asm index 718eeea..4bd530a 100644 --- a/programmer/programmer/programmer.asm +++ b/programmer/programmer/programmer.asm @@ -219,12 +219,12 @@ pro_stable: pro_read_rom_command: ldi mode,OWM_SLEEP - cpi rwbyte,0xCC - brne pro_rcc_1 - ldi mode,OWM_READ_COMMAND - rjmp pro_out_bitp1 + //cpi rwbyte,0xCC + //brne pro_rcc_1 + //ldi mode,OWM_READ_COMMAND + //rjmp pro_out_bitp1 pro_rcc_1: - cpi rwbyte,0xF0 + cpi rwbyte,0xF0 ;Searchrom brne pro_rcc_2 ldi XL,low(sowid) ;init sram pointer ldi XH,high(sowid) @@ -232,7 +232,7 @@ pro_rcc_1: ldi bytep,0 rjmp pro_serchrom_next_bit pro_rcc_2: - cpi rwbyte,0x55 + cpi rwbyte,0x55 ;Matchrom brne pro_rcc_3 // rcall pro_owidinit ldi XL,low(sowid) ;init sram pointer @@ -259,7 +259,7 @@ pro_match_rom_found: pro_read_command: ldi mode,OWM_SLEEP - cpi rwbyte,0x0F + cpi rwbyte,0x0F ;; Write to Scratchpad brne pro_rc_1 ldi mode,OWM_WRITE_SCRATCHPAD ldi XL,low(scratchpad) ;init sram pointer @@ -268,7 +268,7 @@ pro_read_command: pro_rc_1: cpi rwbyte,0xAA brne pro_rc_2 - ldi mode,OWM_READ_SCRATCHPAD + ldi mode,OWM_READ_SCRATCHPAD ;;Read from Scratchpad ldi XL,low(scratchpad) ;init sram pointer ldi XH,high(scratchpad) inc smode @@ -278,26 +278,28 @@ pro_rc_1: pro_rc_2: cpi rwbyte,0xB8 brne pro_rc_3 - ldi mode,OWM_RECALL_FLASH + ldi mode,OWM_RECALL_FLASH ;; copy Flash page in Scratchpad ldi XL,low(scratchpad) ;init sram pointer ldi XH,high(scratchpad) rjmp pro_out_bytep0 pro_rc_3: - cpi rwbyte,0x55 + cpi rwbyte,0x55 ; copy Scratchpad to Flash brne pro_rc_4 ldi mode,OWM_SLEEP rjmp pro_programm_page pro_rc_4: - cpi rwbyte,0x89 + cpi rwbyte,0x89 ; Reset Device /Boot (new) Firmware brne pro_rc_5 rjmp jreset pro_rc_5: - cpi rwbyte,0x8B + cpi rwbyte,0x8B ; Clear the OWID saved in EEPROM / one ID1 brne pro_rc_6 + ldi temp,7 +pro_rc_5a: ldi XL,low(E2END) ldi XH,high(E2END) - subi XL,7 + sub XL,temp out EEARH,XH out EEARL,XL ldi temp, (0<