This documentation was generated automatically from the AVR Studio part description file ATtiny461.pdf
.
sfrb PORTA = $1B;
#define PORTA0_BIT 0
#define PORTA0_MASK 1
#define PORTA1_BIT 1
#define PORTA1_MASK 2
#define PORTA2_BIT 2
#define PORTA2_MASK 4
#define PORTA3_BIT 3
#define PORTA3_MASK 8
#define PORTA4_BIT 4
#define PORTA4_MASK 16
#define PORTA5_BIT 5
#define PORTA5_MASK 32
#define PORTA6_BIT 6
#define PORTA6_MASK 64
#define PORTA7_BIT 7
#define PORTA7_MASK 128
sfrb DDRA = $1A;
#define DDA0_BIT 0
#define DDA0_MASK 1
#define DDA1_BIT 1
#define DDA1_MASK 2
#define DDA2_BIT 2
#define DDA2_MASK 4
#define DDA3_BIT 3
#define DDA3_MASK 8
#define DDA4_BIT 4
#define DDA4_MASK 16
#define DDA5_BIT 5
#define DDA5_MASK 32
#define DDA6_BIT 6
#define DDA6_MASK 64
#define DDA7_BIT 7
#define DDA7_MASK 128
sfrb PINA = $19;
#define PINA0_BIT 0
#define PINA0_MASK 1
#define PINA1_BIT 1
#define PINA1_MASK 2
#define PINA2_BIT 2
#define PINA2_MASK 4
#define PINA3_BIT 3
#define PINA3_MASK 8
#define PINA4_BIT 4
#define PINA4_MASK 16
#define PINA5_BIT 5
#define PINA5_MASK 32
#define PINA6_BIT 6
#define PINA6_MASK 64
#define PINA7_BIT 7
#define PINA7_MASK 128
sfrb PORTB = $18;
#define PORTB0_BIT 0
#define PORTB0_MASK 1
#define PORTB1_BIT 1
#define PORTB1_MASK 2
#define PORTB2_BIT 2
#define PORTB2_MASK 4
#define PORTB3_BIT 3
#define PORTB3_MASK 8
#define PORTB4_BIT 4
#define PORTB4_MASK 16
#define PORTB5_BIT 5
#define PORTB5_MASK 32
#define PORTB6_BIT 6
#define PORTB6_MASK 64
#define PORTB7_BIT 7
#define PORTB7_MASK 128
sfrb DDRB = $17;
#define DDB0_BIT 0
#define DDB0_MASK 1
#define DDB1_BIT 1
#define DDB1_MASK 2
#define DDB2_BIT 2
#define DDB2_MASK 4
#define DDB3_BIT 3
#define DDB3_MASK 8
#define DDB4_BIT 4
#define DDB4_MASK 16
#define DDB5_BIT 5
#define DDB5_MASK 32
#define DDB6_BIT 6
#define DDB6_MASK 64
#define DDB7_BIT 7
#define DDB7_MASK 128
sfrb PINB = $16;
#define PINB0_BIT 0
#define PINB0_MASK 1
#define PINB1_BIT 1
#define PINB1_MASK 2
#define PINB2_BIT 2
#define PINB2_MASK 4
#define PINB3_BIT 3
#define PINB3_MASK 8
#define PINB4_BIT 4
#define PINB4_MASK 16
#define PINB5_BIT 5
#define PINB5_MASK 32
#define PINB6_BIT 6
#define PINB6_MASK 64
#define PINB7_BIT 7
#define PINB7_MASK 128
AD Converter Feature list: 10-bit Resolution. 0.5 LSB Integral Non-Linearity. +-2 LSB Absolute Accuracy. TBD - 260 µs Conversion Time. Up to TBD kSPS at maximum resolution. 8 Multiplexed Single Ended Input Channels. 7 Differential input channels (TQFP package only). 2 Differential input channels with optional gain of 10x and 200x (TQFP package only). Optional left adjustment for ADC result readout. 0 - VCC ADC Input Voltage Range. Selectable 2.56 V ADC reference voltage. Free Running or Single Conversion Mode. Interrupt on ADC Conversion Complete. Sleep Mode N
sfrb ADMUX = $07;
#define MUX0_BIT 0
#define MUX0_MASK 1
The value of these bits selects which combination of analog inputs are connected to the ADC. These bits also select the gain for the differential channels. See Table 92 for details. If these bits are changed during a conversion, the change will not go in effect until this conversion is complete (ADIF in ADCSR is set).
#define MUX1_BIT 1
#define MUX1_MASK 2
The value of these bits selects which combination of analog inputs are connected to the ADC. These bits also select the gain for the differential channels. See Table 92 for details. If these bits are changed during a conversion, the change will not go in effect until this conversion is complete (ADIF in ADCSR is set).
#define MUX2_BIT 2
#define MUX2_MASK 4
The value of these bits selects which combination of analog inputs are connected to the ADC. These bits also select the gain for the differential channels. See Table 92 for details. If these bits are changed during a conversion, the change will not go in effect until this conversion is complete (ADIF in ADCSR is set).
#define MUX3_BIT 3
#define MUX3_MASK 8
The value of these bits selects which combination of analog inputs are connected to the ADC. These bits also select the gain for the differential channels. See Table 92 for details. If these bits are changed during a conversion, the change will not go in effect until this conversion is complete (ADIF in ADCSR is set).
#define MUX4_BIT 4
#define MUX4_MASK 16
The value of these bits selects which combination of analog inputs are connected to the ADC. These bits also select the gain for the differential channels. See Table 92 for details. If these bits are changed during a conversion, the change will not go in effect until this conversion is complete (ADIF in ADCSR is set).
#define ADLAR_BIT 5
#define ADLAR_MASK 32
The ADLAR bit affects the presentation of the ADC conversion result in the ADC data register. If ADLAR is cleared, the result is right adjusted. If ADLAR is set, the result is left adjusted. Changing the ADLAR bit will affect the ADC data register immediately, regardless of any ongoing conversions. For a complete description of this bit, see ?The ADC Data Register -ADCL and ADCH? on page 198.
#define REFS0_BIT 6
#define REFS0_MASK 64
These bits select the voltage reference for the ADC. If these bits are changed during a conversion, the change will not go in effect until this conversion is complete (ADIF in ADCSR is set). If differential channels are used, the selected reference should not be closer to AV CC than indicated in Table 94 on page 200. The internal voltage reference options may not be used if an external reference voltage is being applied to the AREF pin.
#define REFS1_BIT 7
#define REFS1_MASK 128
These bits select the voltage reference for the ADC. If these bits are changed during a conversion, the change will not go in effect until this conversion is complete (ADIF in ADCSR is set). If differential channels are used, the selected reference should not be closer to AV CC than indicated in Table 94 on page 200. The internal voltage reference options may not be used if an external reference voltage is being applied to the AREF pin.
sfrb ADCSRA = $06;
#define ADPS0_BIT 0
#define ADPS0_MASK 1
These bits determine the division factor between the XTAL frequency and the input clock to the ADC.
#define ADPS1_BIT 1
#define ADPS1_MASK 2
These bits determine the division factor between the XTAL frequency and the input clock to the ADC.
#define ADPS2_BIT 2
#define ADPS2_MASK 4
These bits determine the division factor between the XTAL frequency and the input clock to the ADC.
#define ADIE_BIT 3
#define ADIE_MASK 8
When this bit is set (one) and the I-bit in SREG is set (one), the ADC Conversion Complete Interrupt is activated.
#define ADIF_BIT 4
#define ADIF_MASK 16
This bit is set (one) when an ADC conversion completes and the data registers are updated. The ADC Conversion Complete Interrupt is executed if the ADIE bit and the I-bit in SREG are set (one). ADIF is cleared by hardware when executing the corresponding interrupt handling vector. Alternatively, ADIF is cleared by writing a logical one to the flag. Beware that if doing a read-modify-write on ADCSR, a pending interrupt can be disabled. This also applies if the SBI and CBI instructions are used.
#define ADATE_BIT 5
#define ADATE_MASK 32
When this bit is written to one,Auto Triggering of the ADC is enabled.The ADC will start a conversion on a positive edge of the selected trigger signal.The trigger source is selected by setting the ADC Trigger Select bits,ADTS in ADCSRB.
#define ADSC_BIT 6
#define ADSC_MASK 64
In Single Conversion Mode, a logical ?1? must be written to this bit to start each conversion. In Free Running Mode, a logical ?1? must be written to this bit to start the first conversion. The first time ADSC has been written after the ADC has been enabled, or if ADSC is written at the same time as the ADC is enabled, an extended conversion will result. This extended conversion performs initialization of the ADC. ADSC will read as one as long as a conversion is in progress. When the conversion is complete, it returns to zero. When a dummy conversion precedes a real conversion, ADSC will stay high until the real conversion completes. Writing a 0 to this bit has no effect
#define ADEN_BIT 7
#define ADEN_MASK 128
Writing a logical ?1? to this bit enables the ADC. By clearing this bit to zero, the ADC is turned off. Turning the ADC off while a conversion is in progress, will terminate this conversion.
sfrb ADCH = $05;
#define ADCH0_BIT 0
#define ADCH0_MASK 1
#define ADCH1_BIT 1
#define ADCH1_MASK 2
#define ADCH2_BIT 2
#define ADCH2_MASK 4
#define ADCH3_BIT 3
#define ADCH3_MASK 8
#define ADCH4_BIT 4
#define ADCH4_MASK 16
#define ADCH5_BIT 5
#define ADCH5_MASK 32
#define ADCH6_BIT 6
#define ADCH6_MASK 64
#define ADCH7_BIT 7
#define ADCH7_MASK 128
sfrb ADCL = $04;
#define ADCL0_BIT 0
#define ADCL0_MASK 1
#define ADCL1_BIT 1
#define ADCL1_MASK 2
#define ADCL2_BIT 2
#define ADCL2_MASK 4
#define ADCL3_BIT 3
#define ADCL3_MASK 8
#define ADCL4_BIT 4
#define ADCL4_MASK 16
#define ADCL5_BIT 5
#define ADCL5_MASK 32
#define ADCL6_BIT 6
#define ADCL6_MASK 64
#define ADCL7_BIT 7
#define ADCL7_MASK 128
sfrb ADCSRB = $03;
#define ADTS0_BIT 0
#define ADTS0_MASK 1
If ADATE in ADCSRA is written to one,the value of these bits selects which source will trigger an ADC conversion.If ADATE is cleared,the ADTS2:0 settings will have no effect.A conversion will be triggered by the rising edge of the selected interrupt flag.Note that switching from a trigger source that is cleared to a trigger source that is set,will generate a positive edge on the trigger signal.If ADEN in ADCSRA is set,this will start a conversion.Switching to Free Running Mode (ADTS [2:0 ]=0)will not cause a trigger event,even if the ADC Interrupt Flag is set .
#define ADTS1_BIT 1
#define ADTS1_MASK 2
If ADATE in ADCSRA is written to one,the value of these bits selects which source will trigger an ADC conversion.If ADATE is cleared,the ADTS2:0 settings will have no effect.A conversion will be triggered by the rising edge of the selected interrupt flag.Note that switching from a trigger source that is cleared to a trigger source that is set,will generate a positive edge on the trigger signal.If ADEN in ADCSRA is set,this will start a conversion.Switching to Free Running Mode (ADTS [2:0 ]=0)will not cause a trigger event,even if the ADC Interrupt Flag is set .
#define ADTS2_BIT 2
#define ADTS2_MASK 4
If ADATE in ADCSRA is written to one,the value of these bits selects which source will trigger an ADC conversion.If ADATE is cleared,the ADTS2:0 settings will have no effect.A conversion will be triggered by the rising edge of the selected interrupt flag.Note that switching from a trigger source that is cleared to a trigger source that is set,will generate a positive edge on the trigger signal.If ADEN in ADCSRA is set,this will start a conversion.Switching to Free Running Mode (ADTS [2:0 ]=0)will not cause a trigger event,even if the ADC Interrupt Flag is set .
#define MUX5_BIT 3
#define MUX5_MASK 8
#define REFS2_BIT 4
#define REFS2_MASK 16
#define IPR_BIT 5
#define IPR_MASK 32
#define GSEL_BIT 6
#define GSEL_MASK 64
#define BIN_BIT 7
#define BIN_MASK 128
The gain stage is working in the unipolar mode as default, but the bipolar mode can be selected by writing the BIN bit in the ADCSRB register.
sfrb DIDR1 = $02;
#define ADC7D_BIT 4
#define ADC7D_MASK 16
When this bit is written logic one,the digital input buffer on the corresponding ADC pin is disabled.The corresponding PIN register bit will always read as zero when this bit is set.When an analog signal is applied to the ADC7..0 pin and the digital input from this pin is not needed,this bit should be written logic one to reduce power consumption in the digital input buffer.
#define ADC8D_BIT 5
#define ADC8D_MASK 32
When this bit is written logic one,the digital input buffer on the corresponding ADC pin is disabled.The corresponding PIN register bit will always read as zero when this bit is set.When an analog signal is applied to the ADC7..0 pin and the digital input from this pin is not needed,this bit should be written logic one to reduce power consumption in the digital input buffer.
#define ADC9D_BIT 6
#define ADC9D_MASK 64
When this bit is written logic one,the digital input buffer on the corresponding ADC pin is disabled.The corresponding PIN register bit will always read as zero when this bit is set.When an analog signal is applied to the ADC7..0 pin and the digital input from this pin is not needed,this bit should be written logic one to reduce power consumption in the digital input buffer.
#define ADC10D_BIT 7
#define ADC10D_MASK 128
When this bit is written logic one,the digital input buffer on the corresponding ADC pin is disabled.The corresponding PIN register bit will always read as zero when this bit is set.When an analog signal is applied to the ADC7..0 pin and the digital input from this pin is not needed,this bit should be written logic one to reduce power consumption in the digital input buffer.
sfrb DIDR0 = $01;
#define ADC0D_BIT 0
#define ADC0D_MASK 1
When this bit is written logic one,the digital input buffer on the corresponding ADC pin is disabled.The corresponding PIN register bit will always read as zero when this bit is set.When an analog signal is applied to the ADC7..0 pin and the digital input from this pin is not needed,this bit should be written logic one to reduce power consumption in the digital input buffer.
#define ADC1D_BIT 1
#define ADC1D_MASK 2
When this bit is written logic one,the digital input buffer on the corresponding ADC pin is disabled.The corresponding PIN register bit will always read as zero when this bit is set.When an analog signal is applied to the ADC7..0 pin and the digital input from this pin is not needed,this bit should be written logic one to reduce power consumption in the digital input buffer.
#define ADC2D_BIT 2
#define ADC2D_MASK 4
When this bit is written logic one,the digital input buffer on the corresponding ADC pin is disabled.The corresponding PIN register bit will always read as zero when this bit is set.When an analog signal is applied to the ADC7..0 pin and the digital input from this pin is not needed,this bit should be written logic one to reduce power consumption in the digital input buffer.
#define AREFD_BIT 3
#define AREFD_MASK 8
When this bit is written logic one, the digital input buffer on the AREF pin is disabled. The corresponding PIN register bit will always read as zero when this bit is set. When an analog signal is applied to the AREF pin and the digital input from this pin is not needed, this bit should be written logic one to reduce power consumption in the digital input buffer.
#define ADC3D_BIT 4
#define ADC3D_MASK 16
When this bit is written logic one,the digital input buffer on the corresponding ADC pin is disabled.The corresponding PIN register bit will always read as zero when this bit is set.When an analog signal is applied to the ADC7..0 pin and the digital input from this pin is not needed,this bit should be written logic one to reduce power consumption in the digital input buffer.
#define ADC4D_BIT 5
#define ADC4D_MASK 32
When this bit is written logic one,the digital input buffer on the corresponding ADC pin is disabled.The corresponding PIN register bit will always read as zero when this bit is set.When an analog signal is applied to the ADC7..0 pin and the digital input from this pin is not needed,this bit should be written logic one to reduce power consumption in the digital input buffer.
#define ADC5D_BIT 6
#define ADC5D_MASK 64
When this bit is written logic one,the digital input buffer on the corresponding ADC pin is disabled.The corresponding PIN register bit will always read as zero when this bit is set.When an analog signal is applied to the ADC7..0 pin and the digital input from this pin is not needed,this bit should be written logic one to reduce power consumption in the digital input buffer.
#define ADC6D_BIT 7
#define ADC6D_MASK 128
When this bit is written logic one,the digital input buffer on the corresponding ADC pin is disabled.The corresponding PIN register bit will always read as zero when this bit is set.When an analog signal is applied to the ADC7..0 pin and the digital input from this pin is not needed,this bit should be written logic one to reduce power consumption in the digital input buffer.
sfrb ACSRB = $09;
#define ACM0_BIT 0
#define ACM0_MASK 1
#define ACM1_BIT 1
#define ACM1_MASK 2
#define ACM2_BIT 2
#define ACM2_MASK 4
#define HLEV_BIT 6
#define HLEV_MASK 64
#define HSEL_BIT 7
#define HSEL_MASK 128
sfrb ACSRA = $08;
#define ACIS0_BIT 0
#define ACIS0_MASK 1
These bits determine which comparator events that trigger the Analog Comparator interrupt.
#define ACIS1_BIT 1
#define ACIS1_MASK 2
These bits determine which comparator events that trigger the Analog Comparator interrupt.
#define ACME_BIT 2
#define ACME_MASK 4
These bits determine which comparator events that trigger the Analog Comparator interrupt.
#define ACIE_BIT 3
#define ACIE_MASK 8
When the ACIE bit is written logic one and the I-bit in the Status Register is set, the analog comparator interrupt is acti-vated. When written logic zero, the interrupt is disabled.
#define ACI_BIT 4
#define ACI_MASK 16
This bit is set by hardware when a comparator output event triggers the interrupt mode defined by ACIS1 and ACIS0. The Analog Comparator Interrupt routine is executed if the ACIE bit is set and the I-bit in SREG is set. ACI is cleared by hard-ware when executing the corresponding interrupt handling vector. Alternatively, ACI is cleared by writing a logic one to the flag.
#define ACO_BIT 5
#define ACO_MASK 32
The output of the analog comparator is synchronized and then directly connected to ACO. The synchronization introduces a delay of 1-2 clock cycles.
#define ACBG_BIT 6
#define ACBG_MASK 64
When this bit is set, a fixed bandgap reference voltage replaces the positive input to the Analog Comparator. When this bit is cleared, AIN0 is applied to the positive input of the Analog Comparator. See ?Internal Voltage Reference? on page 42.
#define ACD_BIT 7
#define ACD_MASK 128
When this bit is written logic one, the power to the analog comparator is switched off. This bit can be set at any time to turn off the analog comparator. This will reduce power consumption in active and idle mode. When changing the ACD bit, the Analog Comparator Interrupt must be disabled by clearing the ACIE bit in ACSR. Otherwise an interrupt can occur when the bit is changed.
Universal Serial Interface
sfrb USIPP = $11;
#define USIPOS_BIT 0
#define USIPOS_MASK 1
sfrb USIBR = $10;
#define USIBR0_BIT 0
#define USIBR0_MASK 1
#define USIBR1_BIT 1
#define USIBR1_MASK 2
#define USIBR2_BIT 2
#define USIBR2_MASK 4
#define USIBR3_BIT 3
#define USIBR3_MASK 8
#define USIBR4_BIT 4
#define USIBR4_MASK 16
#define USIBR5_BIT 5
#define USIBR5_MASK 32
#define USIBR6_BIT 6
#define USIBR6_MASK 64
#define USIBR7_BIT 7
#define USIBR7_MASK 128
sfrb USIDR = $0F;
#define USIDR0_BIT 0
#define USIDR0_MASK 1
#define USIDR1_BIT 1
#define USIDR1_MASK 2
#define USIDR2_BIT 2
#define USIDR2_MASK 4
#define USIDR3_BIT 3
#define USIDR3_MASK 8
#define USIDR4_BIT 4
#define USIDR4_MASK 16
#define USIDR5_BIT 5
#define USIDR5_MASK 32
#define USIDR6_BIT 6
#define USIDR6_MASK 64
#define USIDR7_BIT 7
#define USIDR7_MASK 128
sfrb USISR = $0E;
#define USICNT0_BIT 0
#define USICNT0_MASK 1
#define USICNT1_BIT 1
#define USICNT1_MASK 2
#define USICNT2_BIT 2
#define USICNT2_MASK 4
#define USICNT3_BIT 3
#define USICNT3_MASK 8
#define USIDC_BIT 4
#define USIDC_MASK 16
#define USIPF_BIT 5
#define USIPF_MASK 32
#define USIOIF_BIT 6
#define USIOIF_MASK 64
#define USISIF_BIT 7
#define USISIF_MASK 128
sfrb USICR = $0D;
#define USITC_BIT 0
#define USITC_MASK 1
#define USICLK_BIT 1
#define USICLK_MASK 2
#define USICS0_BIT 2
#define USICS0_MASK 4
#define USICS1_BIT 3
#define USICS1_MASK 8
#define USIWM0_BIT 4
#define USIWM0_MASK 16
#define USIWM1_BIT 5
#define USIWM1_MASK 32
#define USIOIE_BIT 6
#define USIOIE_MASK 64
#define USISIE_BIT 7
#define USISIE_MASK 128
EEPROM Read/Write Access. The EEPROM access registers are accessible in the I/O space. The write access time for the EEPROM is given in Table 1. A self-timing function, however, lets the user software detect when the next byte can be written. If the user code contains instructions that write the EEPROM, some precautions must be taken. In heavily filtered power supplies, V CC is likely to rise or fall slowly on power-up/down. This causes the device for some period of time to run at a voltage lower than specified as minimum for the clock frequency used. See ?Preventing EEPROM Corruption? on page 19. for details on how to avoid problems in these situations.In order to prevent unintentional EEPROM writes, a specific write procedure must be followed. Refer to the description of the EEPROM Control Register for details on this. When the EEPROM is read, the CPU is halted for four clock cycles before the next instruction is executed. When theEEPROM is written, the CPU is halted for two clock cycles before the next instruction is execut
sfrb EEARH = $1F;
#define EEAR8_BIT 0
#define EEAR8_MASK 1
sfrb EEARL = $1E;
#define EEAR0_BIT 0
#define EEAR0_MASK 1
#define EEAR1_BIT 1
#define EEAR1_MASK 2
#define EEAR2_BIT 2
#define EEAR2_MASK 4
#define EEAR3_BIT 3
#define EEAR3_MASK 8
#define EEAR4_BIT 4
#define EEAR4_MASK 16
#define EEAR5_BIT 5
#define EEAR5_MASK 32
#define EEAR6_BIT 6
#define EEAR6_MASK 64
#define EEAR7_BIT 7
#define EEAR7_MASK 128
sfrb EEDR = $1D;
#define EEDR0_BIT 0
#define EEDR0_MASK 1
#define EEDR1_BIT 1
#define EEDR1_MASK 2
#define EEDR2_BIT 2
#define EEDR2_MASK 4
#define EEDR3_BIT 3
#define EEDR3_MASK 8
#define EEDR4_BIT 4
#define EEDR4_MASK 16
#define EEDR5_BIT 5
#define EEDR5_MASK 32
#define EEDR6_BIT 6
#define EEDR6_MASK 64
#define EEDR7_BIT 7
#define EEDR7_MASK 128
sfrb EECR = $1C;
#define EERE_BIT 0
#define EERE_MASK 1
The EEPROM Read Enable Signal EERE is the read strobe to the EEPROM. When the correct address is set up in the EEAR register, the EERE bit must be written to a logic one to trigger the EEPROM read. The EEPROM read access takes one instruction, and the requested data is available immediately. When the EEPROM is read, the CPU is halted for four cycles before the next instruction is executed. The user should poll the EEWE bit before starting the read operation. If a write operation is in progress, it is neither possible to read the EEPROM, nor to change the EEAR register. The calibrated oscillator is used to time the EEPROM accesses. Table 1 lists the typical programming time for EEPROM access from the CPU
#define EEPE_BIT 1
#define EEPE_MASK 2
The EEPROM Write Enable Signal EEWE is the write strobe to the EEPROM. When address and data are correctly set up, the EEWE bit must be set to write the value into the EEPROM. The EEMWE bit must be set when the logical one is written to EEWE, otherwise no EEPROM write takes place. The following procedure should be followed when writing the EEPROM (the order of steps 3 and 4 is not essential): 1. Wait until EEWE becomes zero. 2. Wait until SPMEN in SPMCR becomes zero. 3. Write new EEPROM address to EEAR (optional). 4. Write new EEPROM data to EEDR (optional). 5. Write a logical one to the EEMWE bit while writing a zero to EEWE in EECR. 6. Within four clock cycles after setting EEMWE, write a logical one to EEWE. The EEPROM can not be programmed during a CPU write to the Flash memory. The software must check that the Flash programming is completed before initiating a new EEPROM write. Step 2 is only relevant if the software contains a boot loader allowing the CPU to program the Flash. If the Flash is never being updated by the CPU, step 2 can be omitted. See ?Boot Loader Support - Read While Write self-programming? on page 228 for details about boot programming. Caution: An interrupt between step 5 and step 6 will make the write cycle fail, since the EEPROM Master Write Enable will time-out. If an interrupt routine accessing the EEPROM is interrupting another EEPROM access, the EEAR or EEDR regis-ter will be modified, causing the interrupted EEPROM access to fail. It is recommended to have the global interrupt flag cleared during the 4 last steps to avoid these problems. When the write access time has elapsed, the EEWE bit is cleared by hardware. The user software can poll this bit and wait for a zero before writing the next byte. When EEWE has been set, the CPU is halted for two cycles before the next instruc-tion is executed
#define EEMPE_BIT 2
#define EEMPE_MASK 4
The EEMWE bit determines whether setting EEWE to one causes the EEPROM to be written. When EEMWE is written to one, writing EEWE to one within 4 clock cycles will write data to the EEPROM at the selected address. If EEMWE is zero, writing EEWE to one will have no effect. When EEMWE has been written to one by software, hardware clears the bit to zero after four clock cycles. See the description of the EEWE bit for an EEPROM write procedure.
#define EERIE_BIT 3
#define EERIE_MASK 8
EEPROM Ready Interrupt Enable Writing EERIE to one enables the EEPROM Ready Interrupt if the I bit in SREG is set. Writing EERIE to zero disables the interrupt. The EEPROM Ready interrupt generates a constant interrupt when EEWE is cleared.
#define EEPM0_BIT 4
#define EEPM0_MASK 16
The EEPROM Programming mode bit setting defines which programming action that will be triggered when writing EEPE. It is possible to program data in one atomic operation (erase the old value and program the new value) or to split the Erase and Write operations in two different operations. The Programming times for the different modes are shown in Table 2. While EEPE is set, any write to EEPMn will be ignored. During reset, the EEPMn bits will be reset to 0b00 unless the EEPROM is busy programming.
#define EEPM1_BIT 5
#define EEPM1_MASK 32
The EEPROM Programming mode bit setting defines which programming action that will be triggered when writing EEPE. It is possible to program data in one atomic operation (erase the old value and program the new value) or to split the Erase and Write operations in two different operations. The Programming times for the different modes are shown in Table 2. While EEPE is set, any write to EEPMn will be ignored. During reset, the EEPMn bits will be reset to 0b00 unless the EEPROM is busy programming.
sfrb WDTCR = $21;
#define WDP0_BIT 0
#define WDP0_MASK 1
#define WDP1_BIT 1
#define WDP1_MASK 2
#define WDP2_BIT 2
#define WDP2_MASK 4
#define WDE_BIT 3
#define WDE_MASK 8
When the WDE is set (one) the Watchdog Timer is enabled, and if the WDE is cleared (zero) the Watchdog Timer function is disabled. WDE can only be cleared if the WDTOE bit is set(one). To disable an enabled watchdog timer, the following procedure must be followed: 1. In the same operation, write a logical one to WDTOE and WDE. A logical one must be written to WDE even though it is set to one before the disable operation starts. 2. Within the next four clock cycles, write a logical 0 to WDE. This disables the watchdog
#define WDCE_BIT 4
#define WDCE_MASK 16
#define WDP3_BIT 5
#define WDP3_MASK 32
#define WDIE_BIT 6
#define WDIE_MASK 64
#define WDIF_BIT 7
#define WDIF_MASK 128
sfrb TIMSK = $39;
#define TICIE0_BIT 0
#define TICIE0_MASK 1
#define TOIE0_BIT 1
#define TOIE0_MASK 2
#define OCIE0B_BIT 3
#define OCIE0B_MASK 8
#define OCIE0A_BIT 4
#define OCIE0A_MASK 16
sfrb TIFR = $38;
#define ICF0_BIT 0
#define ICF0_MASK 1
#define TOV0_BIT 1
#define TOV0_MASK 2
#define OCF0B_BIT 3
#define OCF0B_MASK 8
#define OCF0A_BIT 4
#define OCF0A_MASK 16
sfrb TCCR0A = $15;
#define WGM00_BIT 0
#define WGM00_MASK 1
This bit controls the counting sequence of the counter, The source for maximum counter value.
#define ACIC0_BIT 3
#define ACIC0_MASK 8
#define ICES0_BIT 4
#define ICES0_MASK 16
#define ICNC0_BIT 5
#define ICNC0_MASK 32
#define ICEN0_BIT 6
#define ICEN0_MASK 64
#define TCW0_BIT 7
#define TCW0_MASK 128
sfrb TCCR0B = $33;
#define CS00_BIT 0
#define CS00_MASK 1
#define CS01_BIT 1
#define CS01_MASK 2
#define CS02_BIT 2
#define CS02_MASK 4
#define PSR0_BIT 3
#define PSR0_MASK 8
#define TSM_BIT 4
#define TSM_MASK 16
sfrb TCNT0H = $14;
#define TCNT0_0_BIT 0
#define TCNT0_0_MASK 1
#define TCNT0_1_BIT 1
#define TCNT0_1_MASK 2
#define TCNT0_2_BIT 2
#define TCNT0_2_MASK 4
#define TCNT0_3_BIT 3
#define TCNT0_3_MASK 8
#define TCNT0_4_BIT 4
#define TCNT0_4_MASK 16
#define TCNT0_5_BIT 5
#define TCNT0_5_MASK 32
#define TCNT0_6_BIT 6
#define TCNT0_6_MASK 64
#define TCNT0_7_BIT 7
#define TCNT0_7_MASK 128
sfrb TCNT0L = $32;
#define TCNT0_0_BIT 0
#define TCNT0_0_MASK 1
#define TCNT0_1_BIT 1
#define TCNT0_1_MASK 2
#define TCNT0_2_BIT 2
#define TCNT0_2_MASK 4
#define TCNT0_3_BIT 3
#define TCNT0_3_MASK 8
#define TCNT0_4_BIT 4
#define TCNT0_4_MASK 16
#define TCNT0_5_BIT 5
#define TCNT0_5_MASK 32
#define TCNT0_6_BIT 6
#define TCNT0_6_MASK 64
#define TCNT0_7_BIT 7
#define TCNT0_7_MASK 128
sfrb OCR0A = $13;
#define OCR0_0_BIT 0
#define OCR0_0_MASK 1
#define OCR0_1_BIT 1
#define OCR0_1_MASK 2
#define OCR0_2_BIT 2
#define OCR0_2_MASK 4
#define OCR0_3_BIT 3
#define OCR0_3_MASK 8
#define OCR0_4_BIT 4
#define OCR0_4_MASK 16
#define OCR0_5_BIT 5
#define OCR0_5_MASK 32
#define OCR0_6_BIT 6
#define OCR0_6_MASK 64
#define OCR0_7_BIT 7
#define OCR0_7_MASK 128
sfrb OCR0B = $12;
#define OCR0_0_BIT 0
#define OCR0_0_MASK 1
#define OCR0_1_BIT 1
#define OCR0_1_MASK 2
#define OCR0_2_BIT 2
#define OCR0_2_MASK 4
#define OCR0_3_BIT 3
#define OCR0_3_MASK 8
#define OCR0_4_BIT 4
#define OCR0_4_MASK 16
#define OCR0_5_BIT 5
#define OCR0_5_MASK 32
#define OCR0_6_BIT 6
#define OCR0_6_MASK 64
#define OCR0_7_BIT 7
#define OCR0_7_MASK 128
sfrb TCCR1A = $30;
#define PWM1B_BIT 0
#define PWM1B_MASK 1
When set (one), this bit enables PWM mode for Timer/Counter1.
#define PWM1A_BIT 1
#define PWM1A_MASK 2
When set (one), this bit enables PWM mode for Timer/Counter1.
#define FOC1B_BIT 2
#define FOC1B_MASK 4
#define FOC1A_BIT 3
#define FOC1A_MASK 8
#define COM1B0_BIT 4
#define COM1B0_MASK 16
The COM1A1 and COM1A0 control bits determine any output pin action following a compare match A in Timer/Counter1. Output pin actions affect pin PB1(OC1A). Since this is an alternative function to an I/O port, the corresponding direction control bit must be set (one) to control an output pin.
#define COM1B1_BIT 5
#define COM1B1_MASK 32
The COM1A1 and COM1A0 control bits determine any output pin action following a compare match A in Timer/Counter1. Output pin actions affect pin PB1(OC1A). Since this is an alternative function to an I/O port, the corresponding direction control bit must be set (one) to control an output pin.
#define COM1A0_BIT 6
#define COM1A0_MASK 64
The COM1A1 and COM1A0 control bits determine any output pin action following a compare match A in Timer/Counter1. Output pin actions affect pin PB1(OC1A). Since this is an alternative function to an I/O port, the corresponding direction control bit must be set (one) to control an output pin.
#define COM1A1_BIT 7
#define COM1A1_MASK 128
The COM1A1 and COM1A0 control bits determine any output pin action following a compare match A in Timer/Counter1. Output pin actions affect pin PB1(OC1A). Since this is an alternative function to an I/O port, the corresponding direction control bit must be set (one) to control an output pin.
sfrb TCCR1B = $2F;
#define CS10_BIT 0
#define CS10_MASK 1
The Clock Select bits 3, 2, 1, and 0 define the prescaling source of Timer/Counter1.
#define CS11_BIT 1
#define CS11_MASK 2
The Clock Select bits 3, 2, 1, and 0 define the prescaling source of Timer/Counter1.
#define CS12_BIT 2
#define CS12_MASK 4
The Clock Select bits 3, 2, 1, and 0 define the prescaling source of Timer/Counter1.
#define CS13_BIT 3
#define CS13_MASK 8
The Clock Select bits 3, 2, 1, and 0 define the prescaling source of Timer/Counter1.
#define DTPS10_BIT 4
#define DTPS10_MASK 16
#define DTPS11_BIT 5
#define DTPS11_MASK 32
#define PSR1_BIT 6
#define PSR1_MASK 64
sfrb TCCR1C = $27;
#define PWM1D_BIT 0
#define PWM1D_MASK 1
#define FOC1D_BIT 1
#define FOC1D_MASK 2
#define COM1D0_BIT 2
#define COM1D0_MASK 4
#define COM1D1_BIT 3
#define COM1D1_MASK 8
#define COM1B0S_BIT 4
#define COM1B0S_MASK 16
#define COM1B1S_BIT 5
#define COM1B1S_MASK 32
#define COM1A0S_BIT 6
#define COM1A0S_MASK 64
#define COM1A1S_BIT 7
#define COM1A1S_MASK 128
sfrb TCCR1D = $26;
#define WGM10_BIT 0
#define WGM10_MASK 1
#define WGM11_BIT 1
#define WGM11_MASK 2
#define FPF1_BIT 2
#define FPF1_MASK 4
#define FPAC1_BIT 3
#define FPAC1_MASK 8
#define FPES1_BIT 4
#define FPES1_MASK 16
#define FPNC1_BIT 5
#define FPNC1_MASK 32
#define FPEN1_BIT 6
#define FPEN1_MASK 64
Setting this bit (to one) activates the Shut-Down Mode.
#define FPIE1_BIT 7
#define FPIE1_MASK 128
Setting this bit (to one) enables the Shut-Down Interrupt.
sfrb TCCR1E = $00;
#define OC1OE0_BIT 0
#define OC1OE0_MASK 1
Ouput Compare Override Enable bits are used to connect or disconnect the Output Compare Pins in PWM6 Modes with an instant response on the corresponding Output Compare Pins. The actual value from the port register will be visible on the port pin, when the Output Compare Override Enable Bit is cleared
#define OC1OE1_BIT 1
#define OC1OE1_MASK 2
Ouput Compare Override Enable bits are used to connect or disconnect the Output Compare Pins in PWM6 Modes with an instant response on the corresponding Output Compare Pins. The actual value from the port register will be visible on the port pin, when the Output Compare Override Enable Bit is cleared
#define OC1OE2_BIT 2
#define OC1OE2_MASK 4
Ouput Compare Override Enable bits are used to connect or disconnect the Output Compare Pins in PWM6 Modes with an instant response on the corresponding Output Compare Pins. The actual value from the port register will be visible on the port pin, when the Output Compare Override Enable Bit is cleared
#define OC1OE3_BIT 3
#define OC1OE3_MASK 8
Ouput Compare Override Enable bits are used to connect or disconnect the Output Compare Pins in PWM6 Modes with an instant response on the corresponding Output Compare Pins. The actual value from the port register will be visible on the port pin, when the Output Compare Override Enable Bit is cleared
#define OC1OE4_BIT 4
#define OC1OE4_MASK 16
Ouput Compare Override Enable bits are used to connect or disconnect the Output Compare Pins in PWM6 Modes with an instant response on the corresponding Output Compare Pins. The actual value from the port register will be visible on the port pin, when the Output Compare Override Enable Bit is cleared
#define OC1OE5_BIT 5
#define OC1OE5_MASK 32
Ouput Compare Override Enable bits are used to connect or disconnect the Output Compare Pins in PWM6 Modes with an instant response on the corresponding Output Compare Pins. The actual value from the port register will be visible on the port pin, when the Output Compare Override Enable Bit is cleared
sfrb TCNT1 = $2E;
#define TC1H_0_BIT 0
#define TC1H_0_MASK 1
#define TC1H_1_BIT 1
#define TC1H_1_MASK 2
#define TC1H_2_BIT 2
#define TC1H_2_MASK 4
#define TC1H_3_BIT 3
#define TC1H_3_MASK 8
#define TC1H_4_BIT 4
#define TC1H_4_MASK 16
#define TC1H_5_BIT 5
#define TC1H_5_MASK 32
#define TC1H_6_BIT 6
#define TC1H_6_MASK 64
#define TC1H_7_BIT 7
#define TC1H_7_MASK 128
sfrb TC1H = $25;
#define TC18_BIT 0
#define TC18_MASK 1
#define TC19_BIT 1
#define TC19_MASK 2
sfrb OCR1A = $2D;
#define OCR1A0_BIT 0
#define OCR1A0_MASK 1
#define OCR1A1_BIT 1
#define OCR1A1_MASK 2
#define OCR1A2_BIT 2
#define OCR1A2_MASK 4
#define OCR1A3_BIT 3
#define OCR1A3_MASK 8
#define OCR1A4_BIT 4
#define OCR1A4_MASK 16
#define OCR1A5_BIT 5
#define OCR1A5_MASK 32
#define OCR1A6_BIT 6
#define OCR1A6_MASK 64
#define OCR1A7_BIT 7
#define OCR1A7_MASK 128
sfrb OCR1B = $2C;
#define OCR1B0_BIT 0
#define OCR1B0_MASK 1
#define OCR1B1_BIT 1
#define OCR1B1_MASK 2
#define OCR1B2_BIT 2
#define OCR1B2_MASK 4
#define OCR1B3_BIT 3
#define OCR1B3_MASK 8
#define OCR1B4_BIT 4
#define OCR1B4_MASK 16
#define OCR1B5_BIT 5
#define OCR1B5_MASK 32
#define OCR1B6_BIT 6
#define OCR1B6_MASK 64
#define OCR1B7_BIT 7
#define OCR1B7_MASK 128
sfrb OCR1C = $2B;
#define OCR1C0_BIT 0
#define OCR1C0_MASK 1
#define OCR1C1_BIT 1
#define OCR1C1_MASK 2
#define OCR1C2_BIT 2
#define OCR1C2_MASK 4
#define OCR1C3_BIT 3
#define OCR1C3_MASK 8
#define OCR1C4_BIT 4
#define OCR1C4_MASK 16
#define OCR1C5_BIT 5
#define OCR1C5_MASK 32
#define OCR1C6_BIT 6
#define OCR1C6_MASK 64
#define OCR1C7_BIT 7
#define OCR1C7_MASK 128
sfrb OCR1D = $2A;
#define OCR1D0_BIT 0
#define OCR1D0_MASK 1
#define OCR1D1_BIT 1
#define OCR1D1_MASK 2
#define OCR1D2_BIT 2
#define OCR1D2_MASK 4
#define OCR1D3_BIT 3
#define OCR1D3_MASK 8
#define OCR1D4_BIT 4
#define OCR1D4_MASK 16
#define OCR1D5_BIT 5
#define OCR1D5_MASK 32
#define OCR1D6_BIT 6
#define OCR1D6_MASK 64
#define OCR1C7_BIT 7
#define OCR1C7_MASK 128
sfrb TIMSK = $39;
#define TOIE1_BIT 2
#define TOIE1_MASK 4
When the TOIE1 bit is set (one) and the I-bit in the Status Register is set (one), the Timer/Counter1 Overflow interrupt is enabled. The corresponding interrupt (at vector $004) is executed if an overflow in Timer/Counter1 occurs (i.e., when the TOV1 bit is set in the Timer/Counter Interrupt Flag Register [TIFR]).
#define OCIE1B_BIT 5
#define OCIE1B_MASK 32
#define OCIE1A_BIT 6
#define OCIE1A_MASK 64
When the OCIE1A bit is set (one) and the I-bit in the Status Register is set (one), the Timer/Counter1 Compare Match, interrupt is enabled. The corresponding interrupt (at vector $003) is executed if a compare match A in Timer/Counter1 occurs, i.e., when the OCF1A bit is set (one) in the Timer/Counter Interrupt Flag Register (TIFR).
#define OCIE1D_BIT 7
#define OCIE1D_MASK 128
When the OCIE1D bit is set (one) and the I-bit in the Status Register is set (one), the Timer/Counter1 Compare Match, interrupt is enabled. The corresponding interrupt (at vector $003) is executed if a compare match A in Timer/Counter1 occurs, i.e., when the OCF1A bit is set (one) in the Timer/Counter Interrupt Flag Register (TIFR).
sfrb TIFR = $38;
#define TOV1_BIT 2
#define TOV1_MASK 4
The bit TOV0 is set (one) when an overflow occurs in Timer/Counter0. TOV0 is cleared by hardware when executing the corresponding interrupt handling vector. Alternatively, TOV0 is cleared by writing a logical ?1? to the flag. When the SREG I-bit, TOIE0 (Timer/Counter0 Overf low Interrupt Enable) and TOV0 are set (one), the Timer/Counter0 Overflow interrupt is executed.
#define OCF1B_BIT 5
#define OCF1B_MASK 32
#define OCF1A_BIT 6
#define OCF1A_MASK 64
The OCF1A bit is set (one) when compare match occurs between Timer/Counter1 and the data value in OCR1A (Output Compare Register 1A). OCF1A is cleared by hard-ware when executing the corresponding interrupt handling vector. Alternatively, OCF1A is cleared by writing a logical ?1? to the flag. When the I-bit in SREG, OCIE1A, and OCF1A are set (one), the Timer/Counter1 compare match A interrupt is executed.
#define OCF1D_BIT 7
#define OCF1D_MASK 128
The OCF1D bit is set (one) when compare match occurs between Timer/Counter1 and the data value in OCR1A (Output Compare Register 1A). OCF1A is cleared by hard-ware when executing the corresponding interrupt handling vector. Alternatively, OCF1A is cleared by writing a logical ?1? to the flag. When the I-bit in SREG, OCIE1A, and OCF1A are set (one), the Timer/Counter1 compare match A interrupt is executed.
sfrb DTPS = ;
#define DTPS0_BIT 0
#define DTPS0_MASK 1
#define DTPS1_BIT 1
#define DTPS1_MASK 2
sfrb DT1 = $24;
#define DT1L0_BIT 0
#define DT1L0_MASK 1
#define DT1L1_BIT 1
#define DT1L1_MASK 2
#define DT1L2_BIT 2
#define DT1L2_MASK 4
#define DT1L3_BIT 3
#define DT1L3_MASK 8
#define DT1H0_BIT 4
#define DT1H0_MASK 16
#define DT1H1_BIT 5
#define DT1H1_MASK 32
#define DT1H2_BIT 6
#define DT1H2_MASK 64
#define DT1H3_BIT 7
#define DT1H3_MASK 128
The Boot Loader Support provides a real Read While Write self-programming mechanism for downloading and uploading program code by the MCU itself. This feature allows flexible application software updates controlled by the MCU using a Flash-resident Boot Loader program. The Boot Loader program can use any available data interface and associated proto-col to read code and write (program) that code into the Flash memory, or read the code from the program memory. The program code within the Boot Loader section has the capability to write into the entire Flash, including the Boot Loader Memory. The Boot Loader can thus even modify itself, and it can also erase itself from the code if the feature is not needed anymore. The size of the Boot Loader Memory is configurable with fuses and the Boot Loader has two separate sets of Boot Lock Bits which can be set independently. This gives the user a unique flexibility to select different levels of protection. Boot Loader Features: Read While Write self-programming. Flexibl Boot Memory size. High security (separate Boot Lock bits for a flexible protection). Separate fuse to select reset vector Optimized page (1) size. Code efficient algorithm Efficient read-modify-write suppo
sfrb SPMCSR = $37;
#define SPMEN_BIT 0
#define SPMEN_MASK 1
This bit enables the SPM instruction for the next four clock cycles. If written to one together with either RWWSRE, BLB-SET, PGWRT or PGERS, the following SPM instruction will have a special meaning, see description above. If only SPMEN is written, the following SPM instruction will store the value in R1:R0 in the temporary page buffer addressed by the Z pointer. The LSB of the Z pointer is ignored. The SPMEN bit will auto-clear upon completion of an SPM instruction, or if no SPM instruction is executed within four clock cycles. During page erase and page write, the SPMEN bit remain high until the operation is completed. Writing any other combination than ?10001?, "01001", "00101", "00011" or "00001" in the lower five bits will have no eff
#define PGERS_BIT 1
#define PGERS_MASK 2
If this bit is written to one at the same time as SPMEN, the next SPM instruction within four clock cycles executes page erase. The page address is taken from the high part of the Z pointer. The data in R1 and R0 are ignored. The PGERS bit will auto-clear upon completion of a page erase, or if no SPM instruction is executed within four clock cycles. The CPU is halted during the entire page write operation if the NRWW section is addressed.
#define PGWRT_BIT 2
#define PGWRT_MASK 4
If this bit is written to one at the same time as SPMEN, the next SPM instruction within four clock cycles executes page write, with the data stored in the temporary buffer. The page address is taken from the high part of the Z pointer. The data in R1 and R0 are ignored. The PGWRT bit will auto-clear upon completion of a page write, or if no SPM instruction is exe-cuted within four clock cycles. The CPU is halted during the entire page write operation if the NRWW section is addressed.
#define RFLB_BIT 3
#define RFLB_MASK 8
#define CTPB_BIT 4
#define CTPB_MASK 16
sfrb SREG = $3F;
sfrb PRR = $36;
#define PRADC_BIT 0
#define PRADC_MASK 1
Writing a logic one to this bit shuts down the ADC. The ADC must be disabled before shut down. The analog comparator cannot use the ADC input MUX when the ADC is shut down.
#define PRUSI_BIT 1
#define PRUSI_MASK 2
Writing a logic one to this bit shuts down the USI by stopping the clock to the module. When waking up the USI again, the USI should be re initialized to ensure proper operation.
#define PRTIM0_BIT 2
#define PRTIM0_MASK 4
Writing a logic one to this bit shuts down the Timer/Counter0 module. When the Timer/Counter0 is enabled, operation will continue like before the shutdown.
#define PRTIM1_BIT 3
#define PRTIM1_MASK 8
Writing a logic one to this bit shuts down the Timer/Counter1 module. When the Timer/Counter1 is enabled, operation will continue like before the shutdown.
sfrb SPH = $3E;
#define SP8_BIT 0
#define SP8_MASK 1
sfrb SPL = $3D;
#define SP0_BIT 0
#define SP0_MASK 1
#define SP1_BIT 1
#define SP1_MASK 2
#define SP2_BIT 2
#define SP2_MASK 4
#define SP3_BIT 3
#define SP3_MASK 8
#define SP4_BIT 4
#define SP4_MASK 16
#define SP5_BIT 5
#define SP5_MASK 32
#define SP6_BIT 6
#define SP6_MASK 64
#define SP7_BIT 7
#define SP7_MASK 128
sfrb MCUCR = $35;
#define ISC00_BIT 0
#define ISC00_MASK 1
#define ISC01_BIT 1
#define ISC01_MASK 2
#define SM0_BIT 3
#define SM0_MASK 8
#define SM1_BIT 4
#define SM1_MASK 16
#define SE_BIT 5
#define SE_MASK 32
The SE bit must be set (one) to make the MCU enter the sleep mode when the SLEEP instruction is executed. To avoid the MCU entering the sleep mode unless it is the programmers purpose, it is recommended to set the Sleep Enable SE bit just before the execution of the SLEEP instruction.
#define PUD_BIT 6
#define PUD_MASK 64
sfrb MCUSR = $34;
#define PORF_BIT 0
#define PORF_MASK 1
This bit is set by a power-on reset. A watchdog reset or an external reset will leave this bit unchanged
#define EXTRF_BIT 1
#define EXTRF_MASK 2
After a power-on reset, this bit is undefined (X). It will be set by an external reset. A watchdog reset will leave this bit unchanged.
#define BORF_BIT 2
#define BORF_MASK 4
#define WDRF_BIT 3
#define WDRF_MASK 8
sfrb OSCCAL = $31;
#define CAL0_BIT 0
#define CAL0_MASK 1
#define CAL1_BIT 1
#define CAL1_MASK 2
#define CAL2_BIT 2
#define CAL2_MASK 4
#define CAL3_BIT 3
#define CAL3_MASK 8
#define CAL4_BIT 4
#define CAL4_MASK 16
#define CAL5_BIT 5
#define CAL5_MASK 32
#define CAL6_BIT 6
#define CAL6_MASK 64
#define CAL7_BIT 7
#define CAL7_MASK 128
sfrb CLKPR = $28;
#define CLKPS0_BIT 0
#define CLKPS0_MASK 1
These bits define the division factor between the selected clock source and the internal system clock. These bits can be written run-time to vary the clock frequency to suit the application requirements. As the divider divides the master clock input to the MCU, the speed of all synchronous peripherals is reduced when a division factor is used. The division factors are given a table in the device user guide.. To avoid unintentional changes of clock frequency, a special write procedure must be followed to change the CLKPS bits: 1. Write the Clock Prescaler Change Enable (CLKPCE) bit to one and all other bits in CLKPR to zero. 2. Within four cycles, write the desired value to CLKPS while writing a zero to CLKPCE. Interrupts must be disabled when changing prescaler setting to make sure the write procedure is not interrupted
#define CLKPS1_BIT 1
#define CLKPS1_MASK 2
These bits define the division factor between the selected clock source and the internal system clock. These bits can be written run-time to vary the clock frequency to suit the application requirements. As the divider divides the master clock input to the MCU, the speed of all synchronous peripherals is reduced when a division factor is used. The division factors are given a table in the device user guide.. To avoid unintentional changes of clock frequency, a special write procedure must be followed to change the CLKPS bits: 1. Write the Clock Prescaler Change Enable (CLKPCE) bit to one and all other bits in CLKPR to zero. 2. Within four cycles, write the desired value to CLKPS while writing a zero to CLKPCE. Interrupts must be disabled when changing prescaler setting to make sure the write procedure is not interrupted
#define CLKPS2_BIT 2
#define CLKPS2_MASK 4
These bits define the division factor between the selected clock source and the internal system clock. These bits can be written run-time to vary the clock frequency to suit the application requirements. As the divider divides the master clock input to the MCU, the speed of all synchronous peripherals is reduced when a division factor is used. The division factors are given a table in the device user guide.. To avoid unintentional changes of clock frequency, a special write procedure must be followed to change the CLKPS bits: 1. Write the Clock Prescaler Change Enable (CLKPCE) bit to one and all other bits in CLKPR to zero. 2. Within four cycles, write the desired value to CLKPS while writing a zero to CLKPCE. Interrupts must be disabled when changing prescaler setting to make sure the write procedure is not interrupted
#define CLKPS3_BIT 3
#define CLKPS3_MASK 8
#define CLKPCE_BIT 7
#define CLKPCE_MASK 128
The CLKPCE bit must be written to logic one to enable change of the CLKPS bits. The CLKPCE bit is only update when the other bits in CLKPR are simultaniosly written to zero. CLKPCE is cleared by hardware four cycles after it is written or when CLKPS is written. Rewriting the CLKPCE bit within this time-out period does neither extend the time-out period, nor clear the CLKPCE bit.
sfrb PLLCSR = $29;
#define PLOCK_BIT 0
#define PLOCK_MASK 1
#define PLLE_BIT 1
#define PLLE_MASK 2
#define PCKE_BIT 2
#define PCKE_MASK 4
#define LSM_BIT 7
#define LSM_MASK 128
sfrb DWDR = $20;
#define DWDR0_BIT 0
#define DWDR0_MASK 1
#define DWDR1_BIT 1
#define DWDR1_MASK 2
#define DWDR2_BIT 2
#define DWDR2_MASK 4
#define DWDR3_BIT 3
#define DWDR3_MASK 8
#define DWDR4_BIT 4
#define DWDR4_MASK 16
#define DWDR5_BIT 5
#define DWDR5_MASK 32
#define DWDR6_BIT 6
#define DWDR6_MASK 64
#define DWDR7_BIT 7
#define DWDR7_MASK 128
sfrb GPIOR2 = $0C;
#define GPIOR20_BIT 0
#define GPIOR20_MASK 1
#define GPIOR21_BIT 1
#define GPIOR21_MASK 2
#define GPIOR22_BIT 2
#define GPIOR22_MASK 4
#define GPIOR23_BIT 3
#define GPIOR23_MASK 8
#define GPIOR24_BIT 4
#define GPIOR24_MASK 16
#define GPIOR25_BIT 5
#define GPIOR25_MASK 32
#define GPIOR26_BIT 6
#define GPIOR26_MASK 64
#define GPIOR27_BIT 7
#define GPIOR27_MASK 128
sfrb GPIOR1 = $0B;
#define GPIOR10_BIT 0
#define GPIOR10_MASK 1
#define GPIOR11_BIT 1
#define GPIOR11_MASK 2
#define GPIOR12_BIT 2
#define GPIOR12_MASK 4
#define GPIOR13_BIT 3
#define GPIOR13_MASK 8
#define GPIOR14_BIT 4
#define GPIOR14_MASK 16
#define GPIOR15_BIT 5
#define GPIOR15_MASK 32
#define GPIOR16_BIT 6
#define GPIOR16_MASK 64
#define GPIOR17_BIT 7
#define GPIOR17_MASK 128
sfrb GPIOR0 = $0A;
#define GPIOR00_BIT 0
#define GPIOR00_MASK 1
RW
#define GPIOR01_BIT 1
#define GPIOR01_MASK 2
#define GPIOR02_BIT 2
#define GPIOR02_MASK 4
#define GPIOR03_BIT 3
#define GPIOR03_MASK 8
#define GPIOR04_BIT 4
#define GPIOR04_MASK 16
#define GPIOR05_BIT 5
#define GPIOR05_MASK 32
#define GPIOR06_BIT 6
#define GPIOR06_MASK 64
#define GPIOR07_BIT 7
#define GPIOR07_MASK 128
sfrb MCUCR = $35;
#define ISC00_BIT 0
#define ISC00_MASK 1
#define ISC01_BIT 1
#define ISC01_MASK 2
sfrb GIMSK = $3B;
#define PCIE0_BIT 4
#define PCIE0_MASK 16
#define PCIE1_BIT 5
#define PCIE1_MASK 32
#define INT0_BIT 6
#define INT0_MASK 64
When the INT0 bit is set (one) and the I-bit in the Status Register (SREG) is set (one), the external pin interrupt is enabled. The Interrupt Sense Control0 bits 1/0 (ISC01 and ISC00) in the MCU general Control Register (MCUCR) defines whether the external interrupt is activated on rising or falling edge of the INT0 pin or level sensed. Activity on the pin will cause an interrupt request even if INT0 is configured as an output. The corresponding interrupt of External Interrupt Request 0 is executed from program memory address $001. See also ?External Interrupts.? ? Bits 5..0 - Res: Reserved bits
#define INT1_BIT 7
#define INT1_MASK 128
When the INT1 bit is set (one) and the I-bit in the Status Register (SREG) is set (one), the external pin interrupt is enabled. The Interrupt Sense Control0 bits 1/0 (ISC01 and ISC00) in the MCU general Control Register (MCUCR) defines whether the external interrupt is activated on rising or falling edge of the INT0 pin or level sensed. Activity on the pin will cause an interrupt request even if INT0 is configured as an output. The corresponding interrupt of External Interrupt Request 0 is executed from program memory address $001. See also ?External Interrupts.? ? Bits 5..0 - Res: Reserved bit
sfrb GIFR = $3A;
#define PCIF_BIT 5
#define PCIF_MASK 32
#define INTF0_BIT 6
#define INTF0_MASK 64
When an event on the INT0 pin triggers an interrupt request, INTF0 becomes set (one). If the I-bit in SREG and the INT0 bit in GIMSK are set (one), the MCU will jump to the interrupt vector at address $001. The flag is cleared when the interrupt routine is executed. Alternatively, the flag can be cleared by writing a logical one to it.
#define INTF1_BIT 7
#define INTF1_MASK 128
When an event on the INT1 pin triggers an interrupt request, INTF0 becomes set (one). If the I-bit in SREG and the INT0 bit in GIMSK are set (one), the MCU will jump to the interrupt vector at address $001. The flag is cleared when the interrupt routine is executed. Alternatively, the flag can be cleared by writing a logical one to it.
sfrb PCMSK1 = $22;
#define PCINT8_BIT 0
#define PCINT8_MASK 1
#define PCINT9_BIT 1
#define PCINT9_MASK 2
#define PCINT10_BIT 2
#define PCINT10_MASK 4
#define PCINT11_BIT 3
#define PCINT11_MASK 8
#define PCINT12_BIT 4
#define PCINT12_MASK 16
#define PCINT13_BIT 5
#define PCINT13_MASK 32
#define PCINT14_BIT 6
#define PCINT14_MASK 64
#define PCINT15_BIT 7
#define PCINT15_MASK 128
sfrb PCMSK0 = $23;
#define PCINT0_BIT 0
#define PCINT0_MASK 1
#define PCINT1_BIT 1
#define PCINT1_MASK 2
#define PCINT2_BIT 2
#define PCINT2_MASK 4
#define PCINT3_BIT 3
#define PCINT3_MASK 8
#define PCINT4_BIT 4
#define PCINT4_MASK 16
#define PCINT5_BIT 5
#define PCINT5_MASK 32
#define PCINT6_BIT 6
#define PCINT6_MASK 64
#define PCINT7_BIT 7
#define PCINT7_MASK 128