Clean Simple Counter DS2423
authorTobias <tm@tm3d.de>
Thu, 13 Apr 2017 10:57:05 +0000 (12:57 +0200)
committerTobias <tm@tm3d.de>
Thu, 13 Apr 2017 10:57:05 +0000 (12:57 +0200)
DS2423/DS2423.c
DS2423/DS2423.cproj
common/OWDS2423.S

index ccc2d30..6a37778 100644 (file)
@@ -32,7 +32,6 @@
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
 \r
 #define _4_COUNTERS_\r
-//#define _EEPROM_SAVE_\r
 #define _CPULLUP_\r
 \r
 #define F_CPU 8000000UL\r
 #include <avr/sleep.h>\r
 \r
 \r
-#if  defined(__AVR_ATtiny25__)||defined(__AVR_ATtiny45__)  || defined(__AVR_ATtiny85__)\r
-\r
-#if defined(_4_COUNTERS_)&&defined(_EEPROM_SAVE_)\r
-#error on ATtinyX5 you can not enable four counters and EEPROM save\r
-#endif\r
-#endif\r
-\r
 \r
 extern void OWINIT();\r
 \r
@@ -91,20 +83,6 @@ volatile counters_t counters;
 \r
 volatile uint8_t istat;\r
 \r
-#if  defined(__AVR_ATtiny25__)||defined(__AVR_ATtiny45__)  || defined(__AVR_ATtiny85__)\r
-#define PCINT_VECTOR PCINT0_vect\r
-#define PIN_REG PINB\r
-#define PIN_DDR DDRB\r
-#define PIN_CH2 (1<<PINB3)\r
-#define PIN_CH3 (1<<PINB4)\r
-#define PIN_CH0 (1<<PINB0)\r
-#define PIN_CH1 (1<<PINB1)\r
-#define PORT_EE PINB\r
-#define PIN_EE (1<<PINB0)\r
-#define TEST_TIMER  ((TIMSK & (1<<TOIE0))==0)\r
-#endif\r
-\r
-\r
 #if  defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__)  || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__)  || defined(__AVR_ATtiny84A__)\r
 #define PCINT_VECTOR PCINT0_vect\r
 #define PIN_REG PINA\r
@@ -128,25 +106,6 @@ ISR(PCINT0_vect) {
        if (((PIN_REG&PIN_CH1)==0)&&((istat&PIN_CH1)==PIN_CH1)) {       counters.c32[1]++;      }\r
        #endif\r
        istat=PIN_REG;\r
-       #ifdef _EEPROM_SAVE_\r
-       if (((PORT_EE&PIN_EE)==0)&&((istat&PIN_EE)==PIN_EE)) {\r
-               //PORTB&=~(1<<PINB1);\r
-               EEARH=0;\r
-#ifndef _4_COUNTERS_\r
-               counters.c32[0]++;//Count the save cycles \r
-#endif\r
-               for(uint8_t i=0;i<16;i++) {\r
-                       uint8_t addr=i^0x0C;\r
-                       while(EECR & (1<<EEPE));\r
-                       EECR = (0<<EEPM1)|(0<<EEPM0);\r
-                       EEARL = i;\r
-                       EEDR = counters.c8[addr];\r
-                       EECR |= (1<<EEMPE);\r
-                       EECR |= (1<<EEPE);\r
-               }\r
-               //PORTB|=(1<<PINB1);\r
-       }\r
-       #endif\r
 }\r
 \r
 \r
@@ -163,37 +122,6 @@ int main(void){
        ADCSRB|=(1<<ACME); //Disable Analog multiplexer\r
        MCUCR &=~(1<<PUD); //All Pins Pullup...\r
        \r
-               \r
-#if  defined(__AVR_ATtiny25__)||defined(__AVR_ATtiny45__)  || defined(__AVR_ATtiny85__)\r
-       PORTB|=(1<<PINB5) //Reset\r
-#ifdef _CPULLUP_\r
-       |PIN_CH2|PIN_CH3\r
-#ifdef _4_COUNTERS_    \r
-       |PIN_CH0|PIN_CH1\r
-#endif \r
-#endif \r
-       ;\r
-       \r
-       GIMSK|=(1<<PCIE);\r
-       \r
-       PCMSK=(1<<PCINT3)|(1<<PCINT4)\r
-#ifdef _4_COUNTERS_\r
-       |(1<<PCINT0)|(1<<PCINT1)\r
-#endif\r
-       ;\r
-#ifdef _EEPROM_SAVE_\r
-       DDRB&=~PIN_EE;\r
-       PCMSK|=(1<<PCINT0);\r
-       PORTB&=~PIN_EE; //Spannungsueberpruefung\r
-#endif\r
-       DDRB &=~((1<<PINB3)|(1<<PINB4)\r
-#ifdef _4_COUNTERS_\r
-       |(1<<PINB0)|(1<<PINB1)\r
-#endif\r
-       );\r
-       istat=PIN_REG;\r
-#endif\r
-\r
 \r
 #if  defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__)  || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__)  || defined(__AVR_ATtiny84A__)\r
 \r
@@ -215,42 +143,9 @@ int main(void){
                |(1<<PCINT6)|(1<<PCINT7)\r
 #endif\r
        ;\r
-       \r
-       \r
-#ifdef _EEPROM_SAVE_\r
-       DDRA&=~(1<<PINA0);\r
-       PCMSK0|=(1<<PCINT0);\r
-       PORTA&=~(1<<PINA0); //Spannungsueberpruefung\r
-#endif\r
-       istat=PINB;\r
+       istat=PINA;\r
 #endif\r
 \r
-#ifdef _EEPROM_SAVE_\r
-               EEARH=0;\r
-               \r
-               uint8_t addr;\r
-               for(uint8_t i=0;i<16;i++) {\r
-                       addr=i^0x0C;\r
-                       while(EECR & (1<<EEPE));   \r
-                       EEARL=i;\r
-                       EECR |= (1<<EERE);\r
-                       counters.c8[addr]=EEDR;\r
-               }\r
-               for (uint8_t i=0;i<4;i++) {\r
-                       if (counters.c32[i]==0xFFFFFFFF) counters.c32[i]=0;\r
-                       //counters.c32[i]=0;\r
-               }\r
-\r
-               /*for(uint8_t i=0;i<16;i++) {\r
-                       while(EECR & (1<<EEPE));\r
-                       EECR = (1<<EEPM0);\r
-                       EEARL = i;\r
-                       EECR |= (1<<EEMPE);\r
-                       EECR |= (1<<EEPE);\r
-               }*/\r
-       \r
-   \r
-#endif\r
        sei();\r
     while(1)   {\r
                \r
index 93d1f5a..00ef9d7 100644 (file)
     <BootSegment>2</BootSegment>\r
     <eraseonlaunchrule>1</eraseonlaunchrule>\r
     <AsfFrameworkConfig>\r
-      <framework-data xmlns="">\r
-        <options />\r
-        <configurations />\r
-        <files />\r
-        <documentation help="" />\r
-        <offline-documentation help="" />\r
-        <dependencies>\r
-          <content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.22.0" />\r
-        </dependencies>\r
-      </framework-data>\r
+      <framework-data>\r
+  <options />\r
+  <configurations />\r
+  <files />\r
+  <documentation help="" />\r
+  <offline-documentation help="" />\r
+  <dependencies>\r
+    <content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.28.1" />\r
+  </dependencies>\r
+</framework-data>\r
     </AsfFrameworkConfig>\r
     <avrtool>com.atmel.avrdbg.tool.atmelice</avrtool>\r
     <com_atmel_avrdbg_tool_atmelice>\r
index 32be7dc..32b4156 100644 (file)
@@ -38,7 +38,7 @@
 #include "../common/OWCRC16.s"\r
 \r
 .extern pack,45\r
-.extern counters,8\r
+.extern counters,16\r
 \r
 .macro CHIP_INIT       \r
 .endm\r