VOC Optimation
[owSlave2.git] / common / OWDS2423.S
index 05df87d..0fb23d8 100644 (file)
-
-// Copyright (c) 2015, Tobias Mueller tm(at)tm3d.de
-// All rights reserved. 
-// 
-// Redistribution and use in source and binary forms, with or without 
-// modification, are permitted provided that the following conditions are 
-// met: 
-// 
-//  * Redistributions of source code must retain the above copyright 
-//    notice, this list of conditions and the following disclaimer. 
-//  * Redistributions in binary form must reproduce the above copyright 
-//    notice, this list of conditions and the following disclaimer in the 
-//    documentation and/or other materials provided with the 
-//    distribution. 
-//  * All advertising materials mentioning features or use of this 
-//    software must display the following acknowledgement: This product 
-//    includes software developed by tm3d.de and its contributors. 
-//  * Neither the name of tm3d.de nor the names of its contributors may 
-//    be used to endorse or promote products derived from this software 
-//    without specific prior written permission. 
-// 
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
-
-
-#define _CHANGEABLE_ID_
-#define _ZERO_POLLING_
-#include "../common/OWConfig.s"
-#include "../common/OWCRC16.s"
-
-.extern pack,45
-.extern counters,8
-
-.macro CHIP_INIT       
-.endm
-
-.macro COMMAND_TABLE
-               rjmp h_writescratchpad
-               rjmp h_writescratchpad_crc
-               rjmp h_readscratchpad
-               rjmp h_copyscratchpad
-               rjmp h_readmemory_addr
-               rjmp h_readmemory
-               rjmp h_readmemorycounter_addr
-               rjmp h_readmemorycounter
-               rjmp h_readmemorycounter_ex
-.endm
-
-#include "../common/OWRomFunctions.s"
-#include "../common/OWTimerInterrupt.s"
-
-
-
-; Ab hier Geraeteabhaenging
-#define OW_WRITE_SCRATCHPAD OW_FIRST_COMMAND+0
-#define OW_WRITE_SCRATCHPAD_CRC OW_FIRST_COMMAND+1
-#define OW_READ_SCRATCHPAD OW_FIRST_COMMAND+2
-#define OW_COPY_SCRATCHPAD OW_FIRST_COMMAND+3
-#define OW_READ_MEMORY_ADDR OW_FIRST_COMMAND+4
-#define OW_READ_MEMORY OW_FIRST_COMMAND+5
-#define OW_READ_MEMORYCOUNTER_ADDR OW_FIRST_COMMAND+6
-#define OW_READ_MEMORYCOUNTER OW_FIRST_COMMAND+7
-#define OW_READ_MEMORYCOUNTER_EX OW_FIRST_COMMAND+8
-
-;---------------------------------------------------
-;      READ COMMAND and start operation
-;---------------------------------------------------
-
-
-h_readcommand:
-       clr r_bytep
-#ifndef _DIS_FLASH_
-       FLASH_COMMANDS ; muss zu erst sein....
-#endif
-       cset 0x0F,OW_WRITE_SCRATCHPAD
-       cjmp 0xAA,hrc_set_readscratchpad
-       cset 0x5A,OW_COPY_SCRATCHPAD
-       cset 0xF0,OW_READ_MEMORY_ADDR
-       cset 0xA5,OW_READ_MEMORYCOUNTER_ADDR
-       FW_CONFIG_INFO
-#ifdef _CHANGEABLE_ID_
-       CHANGE_ID_COMMANDS
-#endif
-       ldi r_mode,OW_SLEEP
-       rjmp handle_end
-
-hrc_set_readscratchpad:
-       ldi r_mode,OW_READ_SCRATCHPAD
-       ldi r_sendflag,1
-       rjmp h_readscratchpad
-
-h_writescratchpad:
-       configZ pack,r_bytep
-       inc  r_bytep
-       st   Z,r_rwbyte
-       cpi  r_bytep,2
-       breq h_writescratchpad_block
-       brsh h_writescratchpad_set_eoffset ;;33
-       rjmp handle_end  ;handle_end zu weit entfernt fuer br...
-h_writescratchpad_set_eoffset:
-       cpi  r_bytep,35
-       breq h_writescratchpad_setcrc
-       mov r_temp,r_bytep
-       subi r_temp,4
-       sts pack+2,r_temp ;AA und PF cleared
-       rjmp handle_end
-;Start writeing to 32 Byte Block ; skip status byte    
-h_writescratchpad_block:
-       lds r_temp,pack ; Adresse low byte
-       andi r_temp,0x1F ;32 byte
-       add r_bytep,r_temp ;Zur angegebenen Startadresse springen
-       ;ori r_temp,0x20 ; Set PF flag
-       sts pack+2,r_temp  ;E4:E0 vorher setzen
-       ; Byte 3 ueberspringen
-       rjmp handle_end_inc
-
-h_writescratchpad_setcrc:
-       ;copy crc to pack
-       lds r_temp,crc
-       com r_temp
-       sts pack+43,r_temp
-       lds r_temp,crc+1
-       com r_temp ; invertieren , komischer name.....
-       sts pack+44,r_temp
-       ldi  r_mode,OW_WRITE_SCRATCHPAD_CRC
-       ldi r_sendflag,1
-       ldi r_bytep,43
-h_writescratchpad_crc:
-       cpi r_bytep,45
-       breq h_writescratchpad_crc_end
-       configZ pack,r_bytep
-       ld r_rwbyte,Z
-       rjmp handle_end_inc
-h_writescratchpad_crc_end:
-       rjmp handle_end_sleep
-       
-       
-h_readscratchpad:
-       cpi r_bytep,35
-       breq h_readscratchpad_end
-       cpi r_bytep,3
-       brne h_readscratchpad_read_byte
-h_readscratchpad_set_offset:
-       lds r_temp,pack
-       andi r_temp,0x1F
-       ldi r_temp2,3
-       add r_temp,r_temp2
-       mov r_bytep,r_temp
-h_readscratchpad_read_byte:
-       configZ pack,r_bytep
-       ld r_rwbyte,Z
-       rjmp handle_end_inc
-h_readscratchpad_end:
-       rjmp handle_end_sleep
-
-
-
-h_copyscratchpad:
-       cpi  r_bytep,3
-       brsh h_copyscratchpad_ok
-       configZ pack,r_bytep
-       inc  r_bytep
-       ld   r_temp,Z
-       cp r_temp,r_rwbyte
-       brne h_copyscratchpad_nok
-       cpi  r_bytep,3
-       breq h_copyscratchpad_ok
-       ldi  r_bcount,1 
-       rjmp handle_end
-h_copyscratchpad_ok:
-       ldi r_rwbyte,0xAA
-       ldi r_sendflag,1
-       rjmp handle_end
-h_copyscratchpad_nok:
-       lds r_temp,pack+3
-       andi r_temp,~0x80
-       sts pack+3,r_temp
-       rjmp handle_end_sleep
-
-
-h_readmemory_addr:
-       cpi r_bytep,0
-       brne h_readmrmory_addr_byte1
-       sts pack,r_rwbyte
-       rjmp handle_end_inc
-h_readmrmory_addr_byte1:
-       sts pack+1,r_rwbyte
-       ldi r_mode,OW_READ_MEMORY
-       ldi r_sendflag,1
-       clr r_bytep
-       rjmp h_readmemory2
-h_readmemory:
-       lds r_bytep,pack
-       lds r_temp2,pack+1
-       inc r_bytep
-       clr r_temp
-       adc r_temp2,r_temp
-       sbrc r_temp2,1
-       rjmp h_readmemory_end
-       sts pack+1,r_temp
-       sts pack,r_bytep
-h_readmemory2:
-       lds r_bytep,pack
-       andi r_bytep,0x1F
-       configZ pack+3,r_bytep
-       ld   r_rwbyte,Z
-       rjmp handle_end
-h_readmemory_end:
-       rjmp handle_end_sleep
-
-
-
-
-
-
-
-
-h_readmemorycounter_addr:
-       cpi r_bytep,0
-       brne h_readmrmorycounter_addr_byte1
-       sts pack,r_rwbyte
-       inc r_bytep
-       ;ldi r_bcount,1
-       rjmp handle_end
-h_readmrmorycounter_addr_byte1:
-       sts pack+1,r_rwbyte
-       ldi r_mode,OW_READ_MEMORYCOUNTER
-       ;ldi r_bcount,1 
-       ldi r_sendflag,1
-       clr r_bytep
-       rjmp h_readmemorycounter2
-h_readmemorycounter:
-       lds r_bytep,pack
-       lds r_temp2,pack+1
-       ldi r_temp,1  ;inc leider kein c flag
-       add r_bytep,r_temp
-       clr r_temp
-       adc r_temp2,r_temp
-       mov r_temp,r_bytep
-       andi r_temp,0x1F
-       breq h_readmemorycounter_next
-       sts pack+1,r_temp2
-       sts pack,r_bytep
-h_readmemorycounter2:  ;Lesen von dem worauf die erstenzwei bytes zeigen
-       lds r_bytep,pack
-       andi r_bytep,0x1F
-       configZ pack+3,r_bytep
-       ld   r_rwbyte,Z
-       ;ldi r_bcount,1
-       rjmp handle_end
-//h_readmemorycounter_end:
-//     ldi  r_mode,OW_SLEEP
-//     clr r_sendflag
-//     rjmp handle_end
-h_readmemorycounter_next:  ; rest lesen
-       ldi  r_mode,OW_READ_MEMORYCOUNTER_EX
-       ldi r_bytep,34
-       lds r_temp2,pack
-       lds r_temp,pack+1
-       //lsr r_temp
-       //ror r_temp2
-
-       lsl r_temp2
-       rol r_temp
-       cpi r_temp,3
-       brne h_readmemorycounter_cFF
-       andi r_temp2,0xC0
-       swap r_temp2
-
-       ;cpi r_temp,0xE0
-
-       configZ counters,r_temp2
-       ld r_temp,Z+
-       sts pack+35,r_temp      
-       ld r_temp,Z+
-       sts pack+36,r_temp      
-       ld r_temp,Z+
-       sts pack+37,r_temp      
-       ld r_temp,Z+
-       sts pack+38,r_temp      
-       rjmp h_readmemorycounter_ex
-h_readmemorycounter_cFF:
-       ldi r_temp,0xFF
-       sts pack+35,r_temp      
-       sts pack+36,r_temp      
-       sts pack+37,r_temp      
-       sts pack+38,r_temp      
-
-h_readmemorycounter_ex:
-       inc r_bytep
-       cpi r_bytep,45
-       breq h_readmemorycounter_ex_end
-       cpi r_bytep,43
-       brne h_readmemorycounter_ex2
-       lds r_temp,crc
-       com r_temp
-       sts pack+43,r_temp
-       lds r_temp,crc+1
-       com r_temp
-       sts pack+44,r_temp
-h_readmemorycounter_ex2:
-       ;ldi r_bcount,1
-       configZ pack,r_bytep
-       ld   r_rwbyte,Z
-       rjmp handle_end
-h_readmemorycounter_ex_end:
-       lds r_bytep,pack
-       lds r_temp2,pack+1
-       ldi r_temp,1  ;inc leider kein c flag
-       add r_bytep,r_temp
-       clr r_temp
-       adc r_temp2,r_temp
-       sbrc r_temp2,1 ;am ene von allem 
-       rjmp h_readmemorycounter_ex_sleep
-       CRCInit1
-       ldi  r_mode,OW_READ_MEMORYCOUNTER
-       sts pack+1,r_temp2
-       sts pack,r_bytep
-       rjmp h_readmemorycounter2
-h_readmemorycounter_ex_sleep:
-       ldi r_mode,OW_SLEEP
-       clr r_sendflag
-       rjmp handle_end
-
-
-
-       
-
-#include "../common/OWPinInterrupt.s"
+\r
+// Copyright (c) 2015, Tobias Mueller tm(at)tm3d.de\r
+// All rights reserved. \r
+// \r
+// Redistribution and use in source and binary forms, with or without \r
+// modification, are permitted provided that the following conditions are \r
+// met: \r
+// \r
+//  * Redistributions of source code must retain the above copyright \r
+//    notice, this list of conditions and the following disclaimer. \r
+//  * Redistributions in binary form must reproduce the above copyright \r
+//    notice, this list of conditions and the following disclaimer in the \r
+//    documentation and/or other materials provided with the \r
+//    distribution. \r
+//  * All advertising materials mentioning features or use of this \r
+//    software must display the following acknowledgement: This product \r
+//    includes software developed by tm3d.de and its contributors. \r
+//  * Neither the name of tm3d.de nor the names of its contributors may \r
+//    be used to endorse or promote products derived from this software \r
+//    without specific prior written permission. \r
+// \r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \r
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT \r
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR \r
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT \r
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, \r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT \r
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, \r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY \r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \r
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE \r
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \r
+\r
+\r
+#define _CHANGEABLE_ID_\r
+#define _ZERO_POLLING_\r
+#include "../common/OWConfig.s"\r
+#include "../common/OWCRC16.s"\r
+\r
+.extern pack,45\r
+.extern counters,8\r
+\r
+.macro CHIP_INIT       \r
+.endm\r
+\r
+.macro COMMAND_TABLE\r
+               rjmp h_writescratchpad\r
+               rjmp h_writescratchpad_crc\r
+               rjmp h_readscratchpad\r
+               rjmp h_copyscratchpad\r
+               rjmp h_readmemory_addr\r
+               rjmp h_readmemory\r
+               rjmp h_readmemorycounter_addr\r
+               rjmp h_readmemorycounter\r
+               rjmp h_readmemorycounter_ex\r
+.endm\r
+\r
+#include "../common/OWRomFunctions.s"\r
+#include "../common/OWTimerInterrupt.s"\r
+\r
+\r
+\r
+; Ab hier Geraeteabhaenging\r
+#define OW_WRITE_SCRATCHPAD OW_FIRST_COMMAND+0\r
+#define OW_WRITE_SCRATCHPAD_CRC OW_FIRST_COMMAND+1\r
+#define OW_READ_SCRATCHPAD OW_FIRST_COMMAND+2\r
+#define OW_COPY_SCRATCHPAD OW_FIRST_COMMAND+3\r
+#define OW_READ_MEMORY_ADDR OW_FIRST_COMMAND+4\r
+#define OW_READ_MEMORY OW_FIRST_COMMAND+5\r
+#define OW_READ_MEMORYCOUNTER_ADDR OW_FIRST_COMMAND+6\r
+#define OW_READ_MEMORYCOUNTER OW_FIRST_COMMAND+7\r
+#define OW_READ_MEMORYCOUNTER_EX OW_FIRST_COMMAND+8\r
+\r
+;---------------------------------------------------\r
+;      READ COMMAND and start operation\r
+;---------------------------------------------------\r
+\r
+\r
+h_readcommand:\r
+       clr r_bytep\r
+#ifndef _DIS_FLASH_\r
+       FLASH_COMMANDS ; muss zu erst sein....\r
+#endif\r
+       cset 0x0F,OW_WRITE_SCRATCHPAD\r
+       cjmp 0xAA,hrc_set_readscratchpad\r
+       cset 0x5A,OW_COPY_SCRATCHPAD\r
+       cset 0xF0,OW_READ_MEMORY_ADDR\r
+       cset 0xA5,OW_READ_MEMORYCOUNTER_ADDR\r
+       FW_CONFIG_INFO\r
+#ifdef _CHANGEABLE_ID_\r
+       CHANGE_ID_COMMANDS\r
+#endif\r
+       ldi r_mode,OW_SLEEP\r
+       rjmp handle_end\r
+\r
+hrc_set_readscratchpad:\r
+       ldi r_mode,OW_READ_SCRATCHPAD\r
+       ldi r_sendflag,1\r
+       rjmp h_readscratchpad\r
+\r
+h_writescratchpad:\r
+       configZ pack,r_bytep\r
+       inc  r_bytep\r
+       st   Z,r_rwbyte\r
+       cpi  r_bytep,2\r
+       breq h_writescratchpad_block\r
+       brsh h_writescratchpad_set_eoffset ;;33\r
+       rjmp handle_end  ;handle_end zu weit entfernt fuer br...\r
+h_writescratchpad_set_eoffset:\r
+       cpi  r_bytep,35\r
+       breq h_writescratchpad_setcrc\r
+       mov r_temp,r_bytep\r
+       subi r_temp,4\r
+       sts pack+2,r_temp ;AA und PF cleared\r
+       rjmp handle_end\r
+;Start writeing to 32 Byte Block ; skip status byte    \r
+h_writescratchpad_block:\r
+       lds r_temp,pack ; Adresse low byte\r
+       andi r_temp,0x1F ;32 byte\r
+       add r_bytep,r_temp ;Zur angegebenen Startadresse springen\r
+       ;ori r_temp,0x20 ; Set PF flag\r
+       sts pack+2,r_temp  ;E4:E0 vorher setzen\r
+       ; Byte 3 ueberspringen\r
+       rjmp handle_end_inc\r
+\r
+h_writescratchpad_setcrc:\r
+       ;copy crc to pack\r
+       lds r_temp,crc\r
+       com r_temp\r
+       sts pack+43,r_temp\r
+       lds r_temp,crc+1\r
+       com r_temp ; invertieren , komischer name.....\r
+       sts pack+44,r_temp\r
+       ldi  r_mode,OW_WRITE_SCRATCHPAD_CRC\r
+       ldi r_sendflag,1\r
+       ldi r_bytep,43\r
+h_writescratchpad_crc:\r
+       cpi r_bytep,45\r
+       breq h_writescratchpad_crc_end\r
+       configZ pack,r_bytep\r
+       ld r_rwbyte,Z\r
+       rjmp handle_end_inc\r
+h_writescratchpad_crc_end:\r
+       rjmp handle_end_sleep\r
+       \r
+       \r
+h_readscratchpad:\r
+       cpi r_bytep,35\r
+       breq h_readscratchpad_end\r
+       cpi r_bytep,3\r
+       brne h_readscratchpad_read_byte\r
+h_readscratchpad_set_offset:\r
+       lds r_temp,pack\r
+       andi r_temp,0x1F\r
+       ldi r_temp2,3\r
+       add r_temp,r_temp2\r
+       mov r_bytep,r_temp\r
+h_readscratchpad_read_byte:\r
+       configZ pack,r_bytep\r
+       ld r_rwbyte,Z\r
+       rjmp handle_end_inc\r
+h_readscratchpad_end:\r
+       rjmp handle_end_sleep\r
+\r
+\r
+\r
+h_copyscratchpad:\r
+       cpi  r_bytep,3\r
+       brsh h_copyscratchpad_ok\r
+       configZ pack,r_bytep\r
+       inc  r_bytep\r
+       ld   r_temp,Z\r
+       cp r_temp,r_rwbyte\r
+       brne h_copyscratchpad_nok\r
+       cpi  r_bytep,3\r
+       breq h_copyscratchpad_ok\r
+       ldi  r_bcount,1 \r
+       rjmp handle_end\r
+h_copyscratchpad_ok:\r
+       ldi r_rwbyte,0xAA\r
+       ldi r_sendflag,1\r
+       rjmp handle_end\r
+h_copyscratchpad_nok:\r
+       lds r_temp,pack+3\r
+       andi r_temp,~0x80\r
+       sts pack+3,r_temp\r
+       rjmp handle_end_sleep\r
+\r
+\r
+h_readmemory_addr:\r
+       cpi r_bytep,0\r
+       brne h_readmrmory_addr_byte1\r
+       sts pack,r_rwbyte\r
+       rjmp handle_end_inc\r
+h_readmrmory_addr_byte1:\r
+       sts pack+1,r_rwbyte\r
+       ldi r_mode,OW_READ_MEMORY\r
+       ldi r_sendflag,1\r
+       clr r_bytep\r
+       rjmp h_readmemory2\r
+h_readmemory:\r
+       lds r_bytep,pack\r
+       lds r_temp2,pack+1\r
+       inc r_bytep\r
+       clr r_temp\r
+       adc r_temp2,r_temp\r
+       sbrc r_temp2,1\r
+       rjmp h_readmemory_end\r
+       sts pack+1,r_temp\r
+       sts pack,r_bytep\r
+h_readmemory2:\r
+       lds r_bytep,pack\r
+       andi r_bytep,0x1F\r
+       configZ pack+3,r_bytep\r
+       ld   r_rwbyte,Z\r
+       rjmp handle_end\r
+h_readmemory_end:\r
+       rjmp handle_end_sleep\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+h_readmemorycounter_addr:\r
+       cpi r_bytep,0\r
+       brne h_readmrmorycounter_addr_byte1\r
+       sts pack,r_rwbyte\r
+       inc r_bytep\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end\r
+h_readmrmorycounter_addr_byte1:\r
+       sts pack+1,r_rwbyte\r
+       ldi r_mode,OW_READ_MEMORYCOUNTER\r
+       ;ldi r_bcount,1 \r
+       ldi r_sendflag,1\r
+       clr r_bytep\r
+       rjmp h_readmemorycounter2\r
+h_readmemorycounter:\r
+       lds r_bytep,pack\r
+       lds r_temp2,pack+1\r
+       ldi r_temp,1  ;inc leider kein c flag\r
+       add r_bytep,r_temp\r
+       clr r_temp\r
+       adc r_temp2,r_temp\r
+       mov r_temp,r_bytep\r
+       andi r_temp,0x1F\r
+       breq h_readmemorycounter_next\r
+       sts pack+1,r_temp2\r
+       sts pack,r_bytep\r
+h_readmemorycounter2:  ;Lesen von dem worauf die erstenzwei bytes zeigen\r
+       lds r_bytep,pack\r
+       andi r_bytep,0x1F\r
+       configZ pack+3,r_bytep\r
+       ld   r_rwbyte,Z\r
+       ;ldi r_bcount,1\r
+       rjmp handle_end\r
+//h_readmemorycounter_end:\r
+//     ldi  r_mode,OW_SLEEP\r
+//     clr r_sendflag\r
+//     rjmp handle_end\r
+h_readmemorycounter_next:  ; rest lesen\r
+       ldi  r_mode,OW_READ_MEMORYCOUNTER_EX\r
+       ldi r_bytep,34\r
+       lds r_temp2,pack\r
+       lds r_temp,pack+1\r
+       //lsr r_temp\r
+       //ror r_temp2\r
+\r
+       lsl r_temp2\r
+       rol r_temp\r
+       cpi r_temp,3\r
+       brne h_readmemorycounter_cFF\r
+       andi r_temp2,0xC0\r
+       swap r_temp2\r
+\r
+       ;cpi r_temp,0xE0\r
+\r
+       configZ counters,r_temp2\r
+       ld r_temp,Z+\r
+       sts pack+35,r_temp      \r
+       ld r_temp,Z+\r
+       sts pack+36,r_temp      \r
+       ld r_temp,Z+\r
+       sts pack+37,r_temp      \r
+       ld r_temp,Z+\r
+       sts pack+38,r_temp      \r
+       rjmp h_readmemorycounter_ex\r
+h_readmemorycounter_cFF:\r
+       ldi r_temp,0xFF\r
+       sts pack+35,r_temp      \r
+       sts pack+36,r_temp      \r
+       sts pack+37,r_temp      \r
+       sts pack+38,r_temp      \r
+\r
+h_readmemorycounter_ex:\r
+       inc r_bytep\r
+       cpi r_bytep,45\r
+       breq h_readmemorycounter_ex_end\r
+       cpi r_bytep,43\r
+       brne h_readmemorycounter_ex2\r
+       lds r_temp,crc\r
+       com r_temp\r
+       sts pack+43,r_temp\r
+       lds r_temp,crc+1\r
+       com r_temp\r
+       sts pack+44,r_temp\r
+h_readmemorycounter_ex2:\r
+       ;ldi r_bcount,1\r
+       configZ pack,r_bytep\r
+       ld   r_rwbyte,Z\r
+       rjmp handle_end\r
+h_readmemorycounter_ex_end:\r
+       lds r_bytep,pack\r
+       lds r_temp2,pack+1\r
+       ldi r_temp,1  ;inc leider kein c flag\r
+       add r_bytep,r_temp\r
+       clr r_temp\r
+       adc r_temp2,r_temp\r
+       sbrc r_temp2,1 ;am ene von allem \r
+       rjmp h_readmemorycounter_ex_sleep\r
+       CRCInit1\r
+       ldi  r_mode,OW_READ_MEMORYCOUNTER\r
+       sts pack+1,r_temp2\r
+       sts pack,r_bytep\r
+       rjmp h_readmemorycounter2\r
+h_readmemorycounter_ex_sleep:\r
+       ldi r_mode,OW_SLEEP\r
+       clr r_sendflag\r
+       rjmp handle_end\r
+\r
+\r
+\r
+       \r
+\r
+#include "../common/OWPinInterrupt.s"\r
 .end
\ No newline at end of file