This documentation was generated automatically from the AVR Studio part description file ATtiny2313.pdf
.
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
sfrb TIMSK = $39;
#define OCIE0A_BIT 0
#define OCIE0A_MASK 1
#define TOIE0_BIT 1
#define TOIE0_MASK 2
#define OCIE0B_BIT 2
#define OCIE0B_MASK 4
sfrb TIFR = $38;
#define OCF0A_BIT 0
#define OCF0A_MASK 1
#define TOV0_BIT 1
#define TOV0_MASK 2
#define OCF0B_BIT 2
#define OCF0B_MASK 4
sfrb OCR0B = $3C;
#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 OCR0A = $36;
#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 TCCR0A = $30;
#define WGM00_BIT 0
#define WGM00_MASK 1
Controls the Waveform Generation Mode, please refer to datasheet for further details.
#define WGM01_BIT 1
#define WGM01_MASK 2
Controls the Waveform Generation Mode, please refer to datasheet for further details.
#define COM0B0_BIT 4
#define COM0B0_MASK 16
Controls Output Compare Pin B behaviour. Please refer to datasheet.
#define COM0B1_BIT 5
#define COM0B1_MASK 32
Controls Output Compare Pin B behaviour. Please refer to datasheet.
#define COM0A0_BIT 6
#define COM0A0_MASK 64
Controls Output Compare Pin A behaviour. Please refer to datasheet.
#define COM0A1_BIT 7
#define COM0A1_MASK 128
Controls Output Compare Pin A behaviour. Please refer to datasheet.
sfrb TCNT0 = $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 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 WGM02_BIT 3
#define WGM02_MASK 8
#define FOC0B_BIT 6
#define FOC0B_MASK 64
#define FOC0A_BIT 7
#define FOC0A_MASK 128
sfrb TIMSK = $39;
#define ICIE1_BIT 3
#define ICIE1_MASK 8
When the TICIE1 bit is set (one) and the I-bit in the Status Register is set (one), the Timer/Counter1 Input Capture Event Interrupt is enabled. The corresponding interrupt (at vector $003) is executed if a capture-triggering event occurs on pin ICP, i.e., when the ICF1 bit is set in the Timer/Counter Interrupt Flag Register - TIFR.
#define OCIE1B_BIT 5
#define OCIE1B_MASK 32
When the OCIE1B bit is set (one) and the I-bit in the Status Register is set (one), the Timer/Counter1 CompareB Match interrupt is enabled. The corresponding interrupt is executed if a CompareB match in Timer/Counter1 occurs, i.e., when the OCF1B bit is set in the Timer/Counter Interrupt Flag Register - TIFR.
#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 CompareA Match interrupt is enabled. The corresponding interrupt (at vector $004) is executed if a CompareA match in Timer/Counter1 occurs, i.e., when the OCF1A bit is set in the Timer/Counter Interrupt Flag Register - TIFR.
#define TOIE1_BIT 7
#define TOIE1_MASK 128
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 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.
sfrb TIFR = $38;
#define ICF1_BIT 3
#define ICF1_MASK 8
The ICF1 bit is set (one) to flag an input capture event, indicating that the Timer/Counter1 value has been transferred to the input capture register - ICR1. ICF1 is cleared by hardware when executing the corresponding interrupt handling vector. Alternatively, ICF1 is cleared by writing a logic one to the flag. When the SREG I-bit, and TICIE1 (Timer/Counter1 Input Capture Interrupt Enable), and ICF1 are set (one), the Timer/Counter1 Capture Interrupt is executed.
#define OCF1B_BIT 5
#define OCF1B_MASK 32
The OCF1B bit is set (one) when compare match occurs between the Timer/Counter1 and the data in OCR1B - Output Compare Register 1B. OCF1B is cleared by hardware when executing the corresponding interrupt handling vector. Alterna-tively, OCF1B is cleared by writing a logic one to the flag. When the I-bit in SREG, and OCIE1A (Timer/Counter1 Compare match InterruptB Enable), and the OCF1B are set (one), the Timer/Counter1 Compare B match Interrupt is executed.
#define OCF1A_BIT 6
#define OCF1A_MASK 64
The OCF1A bit is set (one) when compare match occurs between the Timer/Counter1 and the data in OCR1A - Output Compare Register 1A. OCF1A is cleared by hardware when executing the corresponding interrupt handling vector. Alterna-tively, OCF1A is cleared by writing a logic one to the flag. When the I-bit in SREG, and OCIE1A (Timer/Counter1 Compare match InterruptA Enable), and the OCF1A are set (one), the Timer/Counter1 Compare A match Interrupt is executed.
#define TOV1_BIT 7
#define TOV1_MASK 128
The TOV1 is set (one) when an overflow occurs in Timer/Counter1. TOV1 is cleared by hardware when executing the cor-responding interrupt handling vector. Alternatively, TOV1 is cleared by writing a logic one to the flag. When the I-bit in SREG, and TOIE1 (Timer/Counter1 Overflow Interrupt Enable), and TOV1 are set (one), the Timer/Counter1 Overflow Interrupt is executed. In PWM mode, this bit is set when Timer/Counter1 changes counting direction at $0000.
sfrb TCCR1A = $2F;
#define WGM10_BIT 0
#define WGM10_MASK 1
#define WGM11_BIT 1
#define WGM11_MASK 2
#define COM1B0_BIT 4
#define COM1B0_MASK 16
#define COM1B1_BIT 5
#define COM1B1_MASK 32
#define COM1A0_BIT 6
#define COM1A0_MASK 64
The COM1A1 and COM1A0 control bits determine any output pin action following a compare match in Timer/Counter1. Any output pin actions affect pin OC1A - Output CompareA pin 1. This is an alternative function to an I/O port and the corresponding direction control bit must be set (one) to control the output pin. The control configuration is shown in the databook.
#define COM1A1_BIT 7
#define COM1A1_MASK 128
The COM1A1 and COM1A0 control bits determine any output pin action following a compare match in Timer/Counter1. Any output pin actions affect pin OC1A - Output CompareA pin 1. This is an alternative function to an I/O port and the corresponding direction control bit must be set (one) to control the output pin. The control configuration is shown in the databook.
sfrb TCCR1B = $2E;
#define CS10_BIT 0
#define CS10_MASK 1
#define CS11_BIT 1
#define CS11_MASK 2
#define CS12_BIT 2
#define CS12_MASK 4
#define WGM12_BIT 3
#define WGM12_MASK 8
#define WGM13_BIT 4
#define WGM13_MASK 16
#define ICES1_BIT 6
#define ICES1_MASK 64
While the ICES1 bit is cleared (zero), the Timer/Counter1 contents are transferred to the Input Capture Register - ICR1 - on the falling edge of the input capture pin - ICP. While the ICES1 bit is set (one), the Timer/Counter1 contents are transferred to the Input Capture Register - ICR1 - on the rising edge of the input capture pin - ICP.
#define ICNC1_BIT 7
#define ICNC1_MASK 128
When the ICNC1 bit is cleared (zero), the input capture trigger noise canceler function is disabled. The input capture is triggered at the first rising/falling edge sampled on the ICP - input capture pin - as specified. When the ICNC1 bit is set (one), four successive samples are measures on the ICP - input capture pin, and all samples must be high/low according to the input capture trigger specification in the ICES1 bit. The actual sampling frequency is XTAL clock frequency.
sfrb TCCR1C = $22;
#define FOC1B_BIT 6
#define FOC1B_MASK 64
The FOC1A/FOC1B bits are only active when the WGM13:0 bits specifies a non-PWM mode. However, for ensuring compatibility with future devices, these bits must be set to zero when TCCR1A is written when operating in a PWM mode. When writing a logical one to the FOC1A/FOC1B bit, an immediate compare match is forced on the Waveform Generation unit. The OC1A/OC1B output is changed according to its COM1x1:0 bits setting. Note that the FOC1A/FOC1B bits are implemented as strobes. Therefore it is the value present in the COM1x1:0 bits that determine the effect of the forced compare. A FOC1A/FOC1B strobe will not generate any interrupt nor will it clear the timer in Clear Timer on Compare match (CTC) mode using OCR1A as TOP. The FOC1A/FOC1B bits are always read as zero
#define FOC1A_BIT 7
#define FOC1A_MASK 128
The FOC1A/FOC1B bits are only active when the WGM13:0 bits specifies a non-PWM mode. However, for ensuring compatibility with future devices, these bits must be set to zero when TCCR1A is written when operating in a PWM mode. When writing a logical one to the FOC1A/FOC1B bit, an immediate compare match is forced on the Waveform Generation unit. The OC1A/OC1B output is changed according to its COM1x1:0 bits setting. Note that the FOC1A/FOC1B bits are implemented as strobes. Therefore it is the value present in the COM1x1:0 bits that determine the effect of the forced compare. A FOC1A/FOC1B strobe will not generate any interrupt nor will it clear the timer in Clear Timer on Compare match (CTC) mode using OCR1A as TOP. The FOC1A/FOC1B bits are always read as zero
sfrb TCNT1H = $2D;
#define TCNT1H0_BIT 0
#define TCNT1H0_MASK 1
#define TCNT1H1_BIT 1
#define TCNT1H1_MASK 2
#define TCNT1H2_BIT 2
#define TCNT1H2_MASK 4
#define TCNT1H3_BIT 3
#define TCNT1H3_MASK 8
#define TCNT1H4_BIT 4
#define TCNT1H4_MASK 16
#define TCNT1H5_BIT 5
#define TCNT1H5_MASK 32
#define TCNT1H6_BIT 6
#define TCNT1H6_MASK 64
#define TCNT1H7_BIT 7
#define TCNT1H7_MASK 128
sfrb TCNT1L = $2C;
#define TCNT1L0_BIT 0
#define TCNT1L0_MASK 1
#define TCNT1L1_BIT 1
#define TCNT1L1_MASK 2
#define TCNT1L2_BIT 2
#define TCNT1L2_MASK 4
#define TCNT1L3_BIT 3
#define TCNT1L3_MASK 8
#define TCNT1L4_BIT 4
#define TCNT1L4_MASK 16
#define TCNT1L5_BIT 5
#define TCNT1L5_MASK 32
#define TCNT1L6_BIT 6
#define TCNT1L6_MASK 64
#define TCNT1L7_BIT 7
#define TCNT1L7_MASK 128
sfrb OCR1AH = $2B;
#define OCR1AH0_BIT 0
#define OCR1AH0_MASK 1
#define OCR1AH1_BIT 1
#define OCR1AH1_MASK 2
#define OCR1AH2_BIT 2
#define OCR1AH2_MASK 4
#define OCR1AH3_BIT 3
#define OCR1AH3_MASK 8
#define OCR1AH4_BIT 4
#define OCR1AH4_MASK 16
#define OCR1AH5_BIT 5
#define OCR1AH5_MASK 32
#define OCR1AH6_BIT 6
#define OCR1AH6_MASK 64
#define OCR1AH7_BIT 7
#define OCR1AH7_MASK 128
sfrb OCR1AL = $2A;
#define OCR1AL0_BIT 0
#define OCR1AL0_MASK 1
#define OCR1AL1_BIT 1
#define OCR1AL1_MASK 2
#define OCR1AL2_BIT 2
#define OCR1AL2_MASK 4
#define OCR1AL3_BIT 3
#define OCR1AL3_MASK 8
#define OCR1AL4_BIT 4
#define OCR1AL4_MASK 16
#define OCR1AL5_BIT 5
#define OCR1AL5_MASK 32
#define OCR1AL6_BIT 6
#define OCR1AL6_MASK 64
#define OCR1AL7_BIT 7
#define OCR1AL7_MASK 128
sfrb OCR1BH = $29;
#define OCR1AH0_BIT 0
#define OCR1AH0_MASK 1
#define OCR1AH1_BIT 1
#define OCR1AH1_MASK 2
#define OCR1AH2_BIT 2
#define OCR1AH2_MASK 4
#define OCR1AH3_BIT 3
#define OCR1AH3_MASK 8
#define OCR1AH4_BIT 4
#define OCR1AH4_MASK 16
#define OCR1AH5_BIT 5
#define OCR1AH5_MASK 32
#define OCR1AH6_BIT 6
#define OCR1AH6_MASK 64
#define OCR1AH7_BIT 7
#define OCR1AH7_MASK 128
sfrb OCR1BL = $28;
#define OCR1AL0_BIT 0
#define OCR1AL0_MASK 1
#define OCR1AL1_BIT 1
#define OCR1AL1_MASK 2
#define OCR1AL2_BIT 2
#define OCR1AL2_MASK 4
#define OCR1AL3_BIT 3
#define OCR1AL3_MASK 8
#define OCR1AL4_BIT 4
#define OCR1AL4_MASK 16
#define OCR1AL5_BIT 5
#define OCR1AL5_MASK 32
#define OCR1AL6_BIT 6
#define OCR1AL6_MASK 64
#define OCR1AL7_BIT 7
#define OCR1AL7_MASK 128
sfrb ICR1H = $25;
#define ICR1H0_BIT 0
#define ICR1H0_MASK 1
#define ICR1H1_BIT 1
#define ICR1H1_MASK 2
#define ICR1H2_BIT 2
#define ICR1H2_MASK 4
#define ICR1H3_BIT 3
#define ICR1H3_MASK 8
#define ICR1H4_BIT 4
#define ICR1H4_MASK 16
#define ICR1H5_BIT 5
#define ICR1H5_MASK 32
#define ICR1H6_BIT 6
#define ICR1H6_MASK 64
#define ICR1H7_BIT 7
#define ICR1H7_MASK 128
sfrb ICR1L = $24;
#define ICR1L0_BIT 0
#define ICR1L0_MASK 1
#define ICR1L1_BIT 1
#define ICR1L1_MASK 2
#define ICR1L2_BIT 2
#define ICR1L2_MASK 4
#define ICR1L3_BIT 3
#define ICR1L3_MASK 8
#define ICR1L4_BIT 4
#define ICR1L4_MASK 16
#define ICR1L5_BIT 5
#define ICR1L5_MASK 32
#define ICR1L6_BIT 6
#define ICR1L6_MASK 64
#define ICR1L7_BIT 7
#define ICR1L7_MASK 128
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 GIMSK = $3B;
#define PCIE_BIT 5
#define PCIE_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 Control1 bits 1/0 (ISC11 and ISC10) in the MCU general Control Register (MCUCR) defines whether the external interrupt is activated on rising or falling edge of the INT1 pin or level sensed. Activity on the pin will cause an interrupt request even if INT1 is configured as an output. The corresponding interrupt of External Interrupt Request 1 is executed from program memory address $002. See also ?External Interrupts?.
sfrb EIFR = $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, INTF1 becomes set (one). If the I-bit in SREG and the INT1 bit in GIMSK are set (one), the MCU will jump to the interrupt vector at address $002. The flag is cleared when the interrupt routine is executed. Alternatively, the flag can be cleared by writing a logical one to it.
The Universal Synchronous and Asynchronous serial Receiver and Transmitter (USART) is a highly flexible serial communication device. The main features are: ? Full Duplex Operation (Independent Serial Receive and Transmit Registers) ? Asynchronous or Synchronous Operation ? Master or Slave Clocked Synchronous Operation ? High Resolution Baud Rate Generator ? Supports Serial Frames with 5, 6, 7, 8 or 9 Data Bits and 1 or 2 Stop Bits ? Odd or Even Parity Generation and Parity Check Supported by Hardware ? Data OverRun Detection ? Framing Error Detection ? Noise Filtering Includes False Start Bit Detection and Digital Low Pass Filter ? Three Separate Interrupts on TX Complete, TX Data Register Empty and RX Complete ? Multi-processor Communication Mode ? Double Speed Asynchronous Comm
sfrb UDR = $0C;
#define UDR0_BIT 0
#define UDR0_MASK 1
#define UDR1_BIT 1
#define UDR1_MASK 2
#define UDR2_BIT 2
#define UDR2_MASK 4
#define UDR3_BIT 3
#define UDR3_MASK 8
#define UDR4_BIT 4
#define UDR4_MASK 16
#define UDR5_BIT 5
#define UDR5_MASK 32
#define UDR6_BIT 6
#define UDR6_MASK 64
#define UDR7_BIT 7
#define UDR7_MASK 128
sfrb UCSRA = $0B;
#define MPCM_BIT 0
#define MPCM_MASK 1
#define U2X_BIT 1
#define U2X_MASK 2
#define UPE_BIT 2
#define UPE_MASK 4
#define DOR_BIT 3
#define DOR_MASK 8
This bit is set if an Overrun condition is detected, i.e. when a character already present in the UDRregister is not read before the next character has been shifted into the Receiver Shift register. The OR bit is buffered, which means that it will be set once the valid data still in UDR0E is read. The OR bit is cleared (zero) when data is received and transferred to UDR0.
#define FE_BIT 4
#define FE_MASK 16
This bit is set if a Framing Error condition is detected, i.e. when the stop bit of an incoming character is zero. The FE bit is cleared when the stop bit of received data is one.
#define UDRE_BIT 5
#define UDRE_MASK 32
This bit is set (one) when a character written to UDRis transferred to the Transmit shift register. Setting of this bit indicates that the transmitter is ready to receive a new character for transmission. When the UDR0IE bit in UCR is set, the USART Transmit Complete interrupt to be executed as long as UDR0E is set. UDR0E is cleared by writing UDR0. When interrupt-driven data transmittal is used, the USART Data Register Empty Interrupt routine must write UDRin order to clear UDR0E, otherwise a new interrupt will occur once the interrupt routine terminates. UDR0E is set (one) during reset to indicate that the transmitter is rea
#define TXC_BIT 6
#define TXC_MASK 64
This bit is set (one) when the entire character (including the stop bit) in the Transmit Shift register has been shifted out and no new data has been written to UDR0. This flag is especially useful in half-duplex communications interfaces, where a transmitting application must enter receive mode and free the communications bus immediately after completing the transmission. When the TXCIE bit in UCR is set, setting of TXC causes the USART Transmit Complete interrupt to be executed. TXC is cleared by hardware when executing the corresponding interrupt handling vector. Alternatively, the TXC bit is cleared (zero) by writing a logical one to the bi
#define RXC_BIT 7
#define RXC_MASK 128
This bit is set (one) when a received character is transferred from the Receiver Shift register to UDR0. The bit is set regard-less of any detected framing errors. When the RXCIE bit in UCR is set, the USART Receive Complete interrupt will be executed when RXC is set(one). RXC is cleared by reading UDR0. When interrupt-driven data reception is used, the USART Receive Complete Interrupt routine must read UDRin order to clear RXC, otherwise a new interrupt will occur once the interrupt routine terminates.
sfrb UCSRB = $0A;
#define TXB8_BIT 0
#define TXB8_MASK 1
TXB8 is the 9th data bit in the character to be transmitted when operating with serial frames with 9 data bits. Must be writ-ten before writing the low bits to UDR0.
#define RXB8_BIT 1
#define RXB8_MASK 2
RXB8 is the 9th data bit of the received character when operating with serial frames with 9 data bits. Must be read before reading the low bits from UDR0.
#define UCSZ2_BIT 2
#define UCSZ2_MASK 4
#define TXEN_BIT 3
#define TXEN_MASK 8
Writing this bit to one enables the USART transmitter. The transmitter will override normal port operation for the TxD pin when enabled. The disabling of the transmitter (writing TXEN to zero) will not become effective until ongoing and pending transmissions are completed, i.e. when the transmit shift register and transmit buffer register does not contain data to be transmitted. When disabled, the transmitter will no longer override the TxD port.
#define RXEN_BIT 4
#define RXEN_MASK 16
Writing this bit to one enables the USART receiver. The receiver will override normal port operation for the RxD pin when enabled. Disabling the receiver will flush the receive buffer invalidating the FE, DOR and PE flags.
#define UDRIE_BIT 5
#define UDRIE_MASK 32
Writing this bit to one enables interrupt on the UDR0E flag. A Data Register Empty interrupt will be generated only if the UDR0IE bit is written to one, the global interrupt flag in SREG is written to one and the UDR0E bit in UCSR0A is set.
#define TXCIE_BIT 6
#define TXCIE_MASK 64
Writing this bit to one enables interrupt on the TXC flag. A USART Transmit Complete interrupt will be generated only if the TXCIE bit is written to one, the global interrupt flag in SREG is written to one and the TXC bit in UCSR0A is set.
#define RXCIE_BIT 7
#define RXCIE_MASK 128
Writing this bit to one enables interrupt on the RXC flag. A USART Receive Complete interrupt will be generated only if the RXCIE bit is written to one, the global interrupt flag in SREG is written to one and the RXC bit in UCSR0A is set.
sfrb UCSRC = $03;
#define UCPOL_BIT 0
#define UCPOL_MASK 1
#define UCSZ0_BIT 1
#define UCSZ0_MASK 2
#define UCSZ1_BIT 2
#define UCSZ1_MASK 4
#define USBS_BIT 3
#define USBS_MASK 8
#define UPM0_BIT 4
#define UPM0_MASK 16
#define UPM1_BIT 5
#define UPM1_MASK 32
#define UMSEL_BIT 6
#define UMSEL_MASK 64
sfrb UBRRH = $02;
#define UBRR8_BIT 0
#define UBRR8_MASK 1
#define UBRR9_BIT 1
#define UBRR9_MASK 2
#define UBRR10_BIT 2
#define UBRR10_MASK 4
#define UBRR11_BIT 3
#define UBRR11_MASK 8
sfrb UBRRL = $09;
#define UBRR0_BIT 0
#define UBRR0_MASK 1
#define UBRR1_BIT 1
#define UBRR1_MASK 2
#define UBRR2_BIT 2
#define UBRR2_MASK 4
#define UBRR3_BIT 3
#define UBRR3_MASK 8
#define UBRR4_BIT 4
#define UBRR4_MASK 16
#define UBRR5_BIT 5
#define UBRR5_MASK 32
#define UBRR6_BIT 6
#define UBRR6_MASK 64
#define UBRR7_BIT 7
#define UBRR7_MASK 128
sfrb ACSR = $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 ACIC_BIT 2
#define ACIC_MASK 4
#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.
sfrb DIDR = $01;
#define AIN0D_BIT 0
#define AIN0D_MASK 1
#define AIN1D_BIT 1
#define AIN1D_MASK 2
sfrb PORTD = $12;
#define PORTD0_BIT 0
#define PORTD0_MASK 1
#define PORTD1_BIT 1
#define PORTD1_MASK 2
#define PORTD2_BIT 2
#define PORTD2_MASK 4
#define PORTD3_BIT 3
#define PORTD3_MASK 8
#define PORTD4_BIT 4
#define PORTD4_MASK 16
#define PORTD5_BIT 5
#define PORTD5_MASK 32
#define PORTD6_BIT 6
#define PORTD6_MASK 64
sfrb DDRD = $11;
#define DDD0_BIT 0
#define DDD0_MASK 1
#define DDD1_BIT 1
#define DDD1_MASK 2
#define DDD2_BIT 2
#define DDD2_MASK 4
#define DDD3_BIT 3
#define DDD3_MASK 8
#define DDD4_BIT 4
#define DDD4_MASK 16
#define DDD5_BIT 5
#define DDD5_MASK 32
#define DDD6_BIT 6
#define DDD6_MASK 64
sfrb PIND = $10;
#define PIND0_BIT 0
#define PIND0_MASK 1
#define PIND1_BIT 1
#define PIND1_MASK 2
#define PIND2_BIT 2
#define PIND2_MASK 4
#define PIND3_BIT 3
#define PIND3_MASK 8
#define PIND4_BIT 4
#define PIND4_MASK 16
#define PIND5_BIT 5
#define PIND5_MASK 32
#define PIND6_BIT 6
#define PIND6_MASK 64
sfrb EEAR = $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
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 set. When the EERE bit is cleared (zero) by hardware, requested data is found in the EEDR register. The EEPROM read access takes one instruction and there is no need to poll the EERE bit. When EERE has been set, 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 when new data or address is written to the EEPROM I/O registers, the write operation will be interrupted, and the result is undefined.
#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 2 and 3 is unessential): 1. Wait until EEWE becomes zero. 2. Write new EEPROM address to EEARL and EEARH (optional). 3. Write new EEPROM data to EEDR (optional). 4. Write a logical one to the EEMWE bit in EECR (to be able to write a logical one to the EEMWE bit, the EEWE bit mustbewritten to zero in thesamecycle). 5. Within four clock cycles after setting EEMWE, write a logical one to EEWE. When the write access time (typically 2.5 ms at V CC =5Vor 4msatV CC = 2.7V) has elapsed, the EEWE bit is cleared (zero) 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 or two cycles before the next instruction is executed. Caution: An interrupt between step 4 and step 5 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.
#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 set(one) setting EEWE will write data to the EEPROM at the selected address If EEMWE is zero, setting EEWE will have no effect. When EEMWE has been set (one) by software, hardware clears the bit to zero after four clock cycles. See the description of the EEWE bit for a EEPROM write procedure.
#define EERIE_BIT 3
#define EERIE_MASK 8
When the I-bit in SREG and EERIE are set (one), the EEPROM Ready Interrupt is enabled. When cleared (zero), the interrupt is disabled. The EEPROM Ready Interrupt generates a constant interrupt when EEWE is cleared (zero).
#define EEPM0_BIT 4
#define EEPM0_MASK 16
#define EEPM1_BIT 5
#define EEPM1_MASK 32
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
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
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
sfrb SREG = $3F;
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 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 CTPB, RFLB, 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 remains 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 effe
#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.
#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 executed within four clock cycles. The CPU is halted during the entire Page Write operation.
#define RFLB_BIT 3
#define RFLB_MASK 8
An LPM instruction within three cycles after RFLB and SPMEN are set in the SPMCSR Register, will read either the Lock bits or the Fuse bits (depending on Z0 in the Zpointer) into the destination register.
#define CTPB_BIT 4
#define CTPB_MASK 16
If the CTPB bit is written while filling the temporary page buffer, the temporary page buffer will be cleared and the data will be lost.
sfrb MCUCR = $35;
#define ISC00_BIT 0
#define ISC00_MASK 1
#define ISC01_BIT 1
#define ISC01_MASK 2
#define ISC10_BIT 2
#define ISC10_MASK 4
#define ISC11_BIT 3
#define ISC11_MASK 8
#define SM0_BIT 4
#define SM0_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 SM1_BIT 6
#define SM1_MASK 64
#define PUD_BIT 7
#define PUD_MASK 128
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
sfrb CLKPR = $26;
#define CLKPS0_BIT 0
#define CLKPS0_MASK 1
#define CLKPS1_BIT 1
#define CLKPS1_MASK 2
#define CLKPS2_BIT 2
#define CLKPS2_MASK 4
#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 updated when the other bits in CLKPR are simultaneously written to zero. CLKPCE is cleared by hardware four cycles after it is written or when CLKPS bits are written. Rewriting the CLKPCE bit within this time-out period does neither extend the time-out period, nor clear the CLKPCE bit.
sfrb GTCCR = $23;
#define PSR10_BIT 0
#define PSR10_MASK 1
sfrb PCMSK = $20;
#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
sfrb GPIOR2 = $15;
#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 = $14;
#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 = $13;
#define GPIOR00_BIT 0
#define GPIOR00_MASK 1
#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
Universal Serial Interface
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