// 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
\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
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
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
|(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
<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