1unit ATtiny261; 2 3{$goto on} 4 5interface 6 7var 8 // PORTA 9 PORTA : byte absolute $00+$3B; // Port A Data Register 10 DDRA : byte absolute $00+$3A; // Port A Data Direction Register 11 PINA : byte absolute $00+$39; // Port A Input Pins 12 // PORTB 13 PORTB : byte absolute $00+$38; // Port B Data Register 14 DDRB : byte absolute $00+$37; // Port B Data Direction Register 15 PINB : byte absolute $00+$36; // Port B Input Pins 16 // AD_CONVERTER 17 ADMUX : byte absolute $00+$27; // The ADC multiplexer Selection Register 18 ADCSRA : byte absolute $00+$26; // The ADC Control and Status register 19 ADC : word absolute $00+$24; // ADC Data Register Bytes 20 ADCL : byte absolute $00+$24; // ADC Data Register Bytes 21 ADCH : byte absolute $00+$24+1; // ADC Data Register Bytes 22 ADCSRB : byte absolute $00+$23; // ADC Control and Status Register B 23 DIDR1 : byte absolute $00+$22; // Digital Input Disable Register 1 24 DIDR0 : byte absolute $00+$21; // Digital Input Disable Register 0 25 // ANALOG_COMPARATOR 26 ACSRB : byte absolute $00+$29; // Analog Comparator Control And Status Register B 27 ACSRA : byte absolute $00+$28; // Analog Comparator Control And Status Register A 28 // USI 29 USIPP : byte absolute $00+$31; // USI Pin Position 30 USIBR : byte absolute $00+$30; // USI Buffer Register 31 USIDR : byte absolute $00+$2F; // USI Data Register 32 USISR : byte absolute $00+$2E; // USI Status Register 33 USICR : byte absolute $00+$2D; // USI Control Register 34 // EEPROM 35 EEAR : word absolute $00+$3E; // EEPROM Address Register Bytes 36 EEARL : byte absolute $00+$3E; // EEPROM Address Register Bytes 37 EEARH : byte absolute $00+$3E+1; // EEPROM Address Register Bytes 38 EEDR : byte absolute $00+$3D; // EEPROM Data Register 39 EECR : byte absolute $00+$3C; // EEPROM Control Register 40 // WATCHDOG 41 WDTCR : byte absolute $00+$41; // Watchdog Timer Control Register 42 // TIMER_COUNTER_0 43 TIMSK : byte absolute $00+$59; // Timer/Counter Interrupt Mask Register 44 TIFR : byte absolute $00+$58; // Timer/Counter0 Interrupt Flag register 45 TCCR0A : byte absolute $00+$35; // Timer/Counter Control Register A 46 TCCR0B : byte absolute $00+$53; // Timer/Counter Control Register B 47 TCNT0H : byte absolute $00+$34; // Timer/Counter0 High 48 TCNT0L : byte absolute $00+$52; // Timer/Counter0 Low 49 OCR0A : byte absolute $00+$33; // Timer/Counter0 Output Compare Register 50 OCR0B : byte absolute $00+$32; // Timer/Counter0 Output Compare Register 51 // TIMER_COUNTER_1 52 TCCR1A : byte absolute $00+$50; // Timer/Counter Control Register A 53 TCCR1B : byte absolute $00+$4F; // Timer/Counter Control Register B 54 TCCR1C : byte absolute $00+$47; // Timer/Counter Control Register C 55 TCCR1D : byte absolute $00+$46; // Timer/Counter Control Register D 56 TCCR1E : byte absolute $00+$20; // Timer/Counter1 Control Register E 57 TCNT1 : byte absolute $00+$4E; // Timer/Counter Register 58 TC1H : byte absolute $00+$45; // Timer/Counter 1 Register High 59 OCR1A : byte absolute $00+$4D; // Output Compare Register 60 OCR1B : byte absolute $00+$4C; // Output Compare Register 61 OCR1C : byte absolute $00+$4B; // Output compare register 62 OCR1D : byte absolute $00+$4A; // Output compare register 63 DT1 : byte absolute $00+$44; // Timer/Counter 1 Dead Time Value 64 // BOOT_LOAD 65 SPMCSR : byte absolute $00+$57; // Store Program Memory Control Register 66 // EXTERNAL_INTERRUPT 67 MCUCR : byte absolute $00+$55; // MCU Control Register 68 GIMSK : byte absolute $00+$5B; // General Interrupt Mask Register 69 GIFR : byte absolute $00+$5A; // General Interrupt Flag register 70 PCMSK1 : byte absolute $00+$42; // Pin Change Enable Mask 1 71 PCMSK0 : byte absolute $00+$43; // Pin Change Enable Mask 0 72 // CPU 73 SREG : byte absolute $00+$5F; // Status Register 74 PRR : byte absolute $00+$56; // Power Reduction Register 75 SPL : byte absolute $00+$5D; // Stack Pointer Low Byte 76 MCUSR : byte absolute $00+$54; // MCU Status register 77 OSCCAL : byte absolute $00+$51; // Oscillator Calibration Register 78 CLKPR : byte absolute $00+$48; // Clock Prescale Register 79 PLLCSR : byte absolute $00+$49; // PLL Control and status register 80 DWDR : byte absolute $00+$40; // debugWire data register 81 GPIOR2 : byte absolute $00+$2C; // General Purpose IO register 2 82 GPIOR1 : byte absolute $00+$2B; // General Purpose register 1 83 GPIOR0 : byte absolute $00+$2A; // General purpose register 0 84 85const 86 // ADMUX 87 REFS = 6; // Reference Selection Bits 88 ADLAR = 5; // Left Adjust Result 89 MUX = 0; // Analog Channel and Gain Selection Bits 90 // ADCSRA 91 ADEN = 7; // ADC Enable 92 ADSC = 6; // ADC Start Conversion 93 ADATE = 5; // ADC Auto Trigger Enable 94 ADIF = 4; // ADC Interrupt Flag 95 ADIE = 3; // ADC Interrupt Enable 96 ADPS = 0; // ADC Prescaler Select Bits 97 // ADCSRB 98 BIN = 7; // Bipolar Input Mode 99 GSEL = 6; // Gain Select 100 IPR = 5; // Input Polarity Mode 101 REFS2 = 4; // 102 MUX5 = 3; // 103 ADTS = 0; // ADC Auto Trigger Sources 104 // DIDR1 105 ADC10D = 7; // ADC10 Digital input Disable 106 ADC9D = 6; // ADC9 Digital input Disable 107 ADC8D = 5; // ADC8 Digital input Disable 108 ADC7D = 4; // ADC7 Digital input Disable 109 // DIDR0 110 ADC6D = 7; // ADC6 Digital input Disable 111 ADC5D = 6; // ADC5 Digital input Disable 112 ADC4D = 5; // ADC4 Digital input Disable 113 ADC3D = 4; // ADC3 Digital input Disable 114 AREFD = 3; // AREF Digital Input Disable 115 ADC2D = 2; // ADC2 Digital input Disable 116 ADC1D = 1; // ADC1 Digital input Disable 117 ADC0D = 0; // ADC0 Digital input Disable 118 // ACSRB 119 HSEL = 7; // Hysteresis Select 120 HLEV = 6; // Hysteresis Level 121 ACM = 0; // Analog Comparator Multiplexer 122 // ACSRA 123 ACD = 7; // Analog Comparator Disable 124 ACBG = 6; // Analog Comparator Bandgap Select 125 ACO = 5; // Analog Compare Output 126 ACI = 4; // Analog Comparator Interrupt Flag 127 ACIE = 3; // Analog Comparator Interrupt Enable 128 ACME = 2; // Analog Comparator Multiplexer Enable 129 ACIS = 0; // Analog Comparator Interrupt Mode Select bits 130 // USISR 131 USISIF = 7; // Start Condition Interrupt Flag 132 USIOIF = 6; // Counter Overflow Interrupt Flag 133 USIPF = 5; // Stop Condition Flag 134 USIDC = 4; // Data Output Collision 135 USICNT = 0; // USI Counter Value Bits 136 // USICR 137 USISIE = 7; // Start Condition Interrupt Enable 138 USIOIE = 6; // Counter Overflow Interrupt Enable 139 USIWM = 4; // USI Wire Mode Bits 140 USICS = 2; // USI Clock Source Select Bits 141 USICLK = 1; // Clock Strobe 142 USITC = 0; // Toggle Clock Port Pin 143 // EECR 144 EEPM = 4; // EEPROM Programming Mode Bits 145 EERIE = 3; // EEPROM Ready Interrupt Enable 146 EEMPE = 2; // EEPROM Master Write Enable 147 EEPE = 1; // EEPROM Write Enable 148 EERE = 0; // EEPROM Read Enable 149 // WDTCR 150 WDIF = 7; // Watchdog Timeout Interrupt Flag 151 WDIE = 6; // Watchdog Timeout Interrupt Enable 152 WDP = 0; // Watchdog Timer Prescaler Bits 153 WDCE = 4; // Watchdog Change Enable 154 WDE = 3; // Watch Dog Enable 155 // TIMSK 156 OCIE0A = 4; // Timer/Counter0 Output Compare Match A Interrupt Enable 157 OCIE0B = 3; // Timer/Counter0 Output Compare Match B Interrupt Enable 158 TOIE0 = 1; // Timer/Counter0 Overflow Interrupt Enable 159 TICIE0 = 0; // Timer/Counter0 Input Capture Interrupt Enable 160 // TIFR 161 OCF0A = 4; // Timer/Counter0 Output Compare Flag 0A 162 OCF0B = 3; // Timer/Counter0 Output Compare Flag 0B 163 TOV0 = 1; // Timer/Counter0 Overflow Flag 164 ICF0 = 0; // Timer/Counter0 Input Capture Flag 165 // TCCR0A 166 TCW0 = 7; // Timer/Counter 0 Width 167 ICEN0 = 6; // Input Capture Mode Enable 168 ICNC0 = 5; // Input Capture Noice Canceler 169 ICES0 = 4; // Input Capture Edge Select 170 ACIC0 = 3; // Analog Comparator Input Capture Enable 171 WGM00 = 0; // Waveform Generation Mode 172 // TCCR0B 173 TSM = 4; // Timer/Counter Synchronization Mode 174 PSR0 = 3; // Timer/Counter 0 Prescaler Reset 175 CS0 = 0; // Clock Select 176 // TCCR1A 177 COM1A = 6; // Compare Output Mode, Bits 178 COM1B = 4; // Compare Output Mode, Bits 179 FOC1A = 3; // Force Output Compare Match 1A 180 FOC1B = 2; // Force Output Compare Match 1B 181 PWM1A = 1; // Pulse Width Modulator Enable 182 PWM1B = 0; // Pulse Width Modulator Enable 183 // TCCR1B 184 PSR1 = 6; // Timer/Counter 1 Prescaler reset 185 DTPS1 = 4; // Dead Time Prescaler 186 CS1 = 0; // Clock Select Bits 187 // TCCR1C 188 COM1A1S = 7; // COM1A1 Shadow Bit 189 COM1A0S = 6; // COM1A0 Shadow Bit 190 COM1B1S = 5; // COM1B1 Shadow Bit 191 COM1B0S = 4; // COM1B0 Shadow Bit 192 COM1D = 2; // Comparator D output mode 193 FOC1D = 1; // Force Output Compare Match 1D 194 PWM1D = 0; // Pulse Width Modulator D Enable 195 // TCCR1D 196 FPIE1 = 7; // Fault Protection Interrupt Enable 197 FPEN1 = 6; // Fault Protection Mode Enable 198 FPNC1 = 5; // Fault Protection Noise Canceler 199 FPES1 = 4; // Fault Protection Edge Select 200 FPAC1 = 3; // Fault Protection Analog Comparator Enable 201 FPF1 = 2; // Fault Protection Interrupt Flag 202 WGM1 = 0; // Waveform Generation Mode Bit 203 // TCCR1E 204 OC1OE = 0; // Ouput Compare Override Enable Bits 205 // TIMSK 206 OCIE1D = 7; // OCIE1D: Timer/Counter1 Output Compare Interrupt Enable 207 OCIE1A = 6; // OCIE1A: Timer/Counter1 Output Compare Interrupt Enable 208 OCIE1B = 5; // OCIE1A: Timer/Counter1 Output Compare B Interrupt Enable 209 TOIE1 = 2; // Timer/Counter1 Overflow Interrupt Enable 210 // TIFR 211 OCF1D = 7; // Timer/Counter1 Output Compare Flag 1D 212 OCF1A = 6; // Timer/Counter1 Output Compare Flag 1A 213 OCF1B = 5; // Timer/Counter1 Output Compare Flag 1B 214 TOV1 = 2; // Timer/Counter1 Overflow Flag 215 // DT1 216 DT1H = 4; // 217 DT1L = 0; // 218 // SPMCSR 219 CTPB = 4; // Clear temporary page buffer 220 RFLB = 3; // Read fuse and lock bits 221 PGWRT = 2; // Page Write 222 PGERS = 1; // Page Erase 223 SPMEN = 0; // Store Program Memory Enable 224 // MCUCR 225 ISC01 = 1; // Interrupt Sense Control 0 Bit 1 226 ISC00 = 0; // Interrupt Sense Control 0 Bit 0 227 // GIMSK 228 INT = 6; // External Interrupt Request 1 Enable 229 PCIE = 4; // Pin Change Interrupt Enables 230 // GIFR 231 INTF = 6; // External Interrupt Flags 232 PCIF = 5; // Pin Change Interrupt Flag 233 // SREG 234 I = 7; // Global Interrupt Enable 235 T = 6; // Bit Copy Storage 236 H = 5; // Half Carry Flag 237 S = 4; // Sign Bit 238 V = 3; // Two's Complement Overflow Flag 239 N = 2; // Negative Flag 240 Z = 1; // Zero Flag 241 C = 0; // Carry Flag 242 // PRR 243 PRTIM1 = 3; // Power Reduction Timer/Counter1 244 PRTIM0 = 2; // Power Reduction Timer/Counter0 245 PRUSI = 1; // Power Reduction USI 246 PRADC = 0; // Power Reduction ADC 247 // MCUCR 248 PUD = 6; // Pull-up Disable 249 SE = 5; // Sleep Enable 250 SM = 3; // Sleep Mode Select Bits 251 ISC0 = 0; // Interrupt Sense Control 0 bits 252 // MCUSR 253 WDRF = 3; // Watchdog Reset Flag 254 BORF = 2; // Brown-out Reset Flag 255 EXTRF = 1; // External Reset Flag 256 PORF = 0; // Power-On Reset Flag 257 // CLKPR 258 CLKPCE = 7; // Clock Prescaler Change Enable 259 CLKPS = 0; // Clock Prescaler Select Bits 260 // PLLCSR 261 LSM = 7; // Low speed mode 262 PCKE = 2; // PCK Enable 263 PLLE = 1; // PLL Enable 264 PLOCK = 0; // PLL Lock detector 265 266implementation 267 268{$define RELBRANCHES} 269 270{$i avrcommon.inc} 271 272procedure INT0_ISR; external name 'INT0_ISR'; // Interrupt 1 External Interrupt 0 273procedure PCINT_ISR; external name 'PCINT_ISR'; // Interrupt 2 Pin Change Interrupt 274procedure TIMER1_COMPA_ISR; external name 'TIMER1_COMPA_ISR'; // Interrupt 3 Timer/Counter1 Compare Match 1A 275procedure TIMER1_COMPB_ISR; external name 'TIMER1_COMPB_ISR'; // Interrupt 4 Timer/Counter1 Compare Match 1B 276procedure TIMER1_OVF_ISR; external name 'TIMER1_OVF_ISR'; // Interrupt 5 Timer/Counter1 Overflow 277procedure TIMER0_OVF_ISR; external name 'TIMER0_OVF_ISR'; // Interrupt 6 Timer/Counter0 Overflow 278procedure USI_START_ISR; external name 'USI_START_ISR'; // Interrupt 7 USI Start 279procedure USI_OVF_ISR; external name 'USI_OVF_ISR'; // Interrupt 8 USI Overflow 280procedure EE_RDY_ISR; external name 'EE_RDY_ISR'; // Interrupt 9 EEPROM Ready 281procedure ANA_COMP_ISR; external name 'ANA_COMP_ISR'; // Interrupt 10 Analog Comparator 282procedure ADC_ISR; external name 'ADC_ISR'; // Interrupt 11 ADC Conversion Complete 283procedure WDT_ISR; external name 'WDT_ISR'; // Interrupt 12 Watchdog Time-Out 284procedure INT1_ISR; external name 'INT1_ISR'; // Interrupt 13 External Interrupt 1 285procedure TIMER0_COMPA_ISR; external name 'TIMER0_COMPA_ISR'; // Interrupt 14 Timer/Counter0 Compare Match A 286procedure TIMER0_COMPB_ISR; external name 'TIMER0_COMPB_ISR'; // Interrupt 15 Timer/Counter0 Compare Match B 287procedure TIMER0_CAPT_ISR; external name 'TIMER0_CAPT_ISR'; // Interrupt 16 ADC Conversion Complete 288procedure TIMER1_COMPD_ISR; external name 'TIMER1_COMPD_ISR'; // Interrupt 17 Timer/Counter1 Compare Match D 289procedure FAULT_PROTECTION_ISR; external name 'FAULT_PROTECTION_ISR'; // Interrupt 18 Timer/Counter1 Fault Protection 290 291procedure _FPC_start; assembler; nostackframe; 292label 293 _start; 294 asm 295 .init 296 .globl _start 297 298 rjmp _start 299 rjmp INT0_ISR 300 rjmp PCINT_ISR 301 rjmp TIMER1_COMPA_ISR 302 rjmp TIMER1_COMPB_ISR 303 rjmp TIMER1_OVF_ISR 304 rjmp TIMER0_OVF_ISR 305 rjmp USI_START_ISR 306 rjmp USI_OVF_ISR 307 rjmp EE_RDY_ISR 308 rjmp ANA_COMP_ISR 309 rjmp ADC_ISR 310 rjmp WDT_ISR 311 rjmp INT1_ISR 312 rjmp TIMER0_COMPA_ISR 313 rjmp TIMER0_COMPB_ISR 314 rjmp TIMER0_CAPT_ISR 315 rjmp TIMER1_COMPD_ISR 316 rjmp FAULT_PROTECTION_ISR 317 318 {$i start.inc} 319 320 .weak INT0_ISR 321 .weak PCINT_ISR 322 .weak TIMER1_COMPA_ISR 323 .weak TIMER1_COMPB_ISR 324 .weak TIMER1_OVF_ISR 325 .weak TIMER0_OVF_ISR 326 .weak USI_START_ISR 327 .weak USI_OVF_ISR 328 .weak EE_RDY_ISR 329 .weak ANA_COMP_ISR 330 .weak ADC_ISR 331 .weak WDT_ISR 332 .weak INT1_ISR 333 .weak TIMER0_COMPA_ISR 334 .weak TIMER0_COMPB_ISR 335 .weak TIMER0_CAPT_ISR 336 .weak TIMER1_COMPD_ISR 337 .weak FAULT_PROTECTION_ISR 338 339 .set INT0_ISR, Default_IRQ_handler 340 .set PCINT_ISR, Default_IRQ_handler 341 .set TIMER1_COMPA_ISR, Default_IRQ_handler 342 .set TIMER1_COMPB_ISR, Default_IRQ_handler 343 .set TIMER1_OVF_ISR, Default_IRQ_handler 344 .set TIMER0_OVF_ISR, Default_IRQ_handler 345 .set USI_START_ISR, Default_IRQ_handler 346 .set USI_OVF_ISR, Default_IRQ_handler 347 .set EE_RDY_ISR, Default_IRQ_handler 348 .set ANA_COMP_ISR, Default_IRQ_handler 349 .set ADC_ISR, Default_IRQ_handler 350 .set WDT_ISR, Default_IRQ_handler 351 .set INT1_ISR, Default_IRQ_handler 352 .set TIMER0_COMPA_ISR, Default_IRQ_handler 353 .set TIMER0_COMPB_ISR, Default_IRQ_handler 354 .set TIMER0_CAPT_ISR, Default_IRQ_handler 355 .set TIMER1_COMPD_ISR, Default_IRQ_handler 356 .set FAULT_PROTECTION_ISR, Default_IRQ_handler 357 end; 358 359end. 360