This documentation was generated automatically from the AVR Studio part description file AT90PWM2.pdf.

PORTB

PORTB - Port B Data Register

sfrb PORTB = $05;

PORTB0 - Port B Data Register bit 0

#define PORTB0 0

PORTB1 - Port B Data Register bit 1

#define PORTB1 1

PORTB2 - Port B Data Register bit 2

#define PORTB2 2

PORTB3 - Port B Data Register bit 3

#define PORTB3 3

PORTB4 - Port B Data Register bit 4

#define PORTB4 4

PORTB5 - Port B Data Register bit 5

#define PORTB5 5

PORTB6 - Port B Data Register bit 6

#define PORTB6 6

PORTB7 - Port B Data Register bit 7

#define PORTB7 7

DDRB - Port B Data Direction Register

sfrb DDRB = $04;

DDB0 - Port B Data Direction Register bit 0

#define DDB0 0

DDB1 - Port B Data Direction Register bit 1

#define DDB1 1

DDB2 - Port B Data Direction Register bit 2

#define DDB2 2

DDB3 - Port B Data Direction Register bit 3

#define DDB3 3

DDB4 - Port B Data Direction Register bit 4

#define DDB4 4

DDB5 - Port B Data Direction Register bit 5

#define DDB5 5

DDB6 - Port B Data Direction Register bit 6

#define DDB6 6

DDB7 - Port B Data Direction Register bit 7

#define DDB7 7

PINB - Port B Input Pins

sfrb PINB = $03;

PINB0 - Port B Input Pins bit 0

#define PINB0 0

PINB1 - Port B Input Pins bit 1

#define PINB1 1

PINB2 - Port B Input Pins bit 2

#define PINB2 2

PINB3 - Port B Input Pins bit 3

#define PINB3 3

PINB4 - Port B Input Pins bit 4

#define PINB4 4

PINB5 - Port B Input Pins bit 5

#define PINB5 5

PINB6 - Port B Input Pins bit 6

#define PINB6 6

PINB7 - Port B Input Pins bit 7

#define PINB7 7

PORTD

PORTD - Port D Data Register

sfrb PORTD = $0B;

PORTD0 - Port D Data Register bit 0

#define PORTD0 0

PORTD1 - Port D Data Register bit 1

#define PORTD1 1

PORTD2 - Port D Data Register bit 2

#define PORTD2 2

PORTD3 - Port D Data Register bit 3

#define PORTD3 3

PORTD4 - Port D Data Register bit 4

#define PORTD4 4

PORTD5 - Port D Data Register bit 5

#define PORTD5 5

PORTD6 - Port D Data Register bit 6

#define PORTD6 6

PORTD7 - Port D Data Register bit 7

#define PORTD7 7

DDRD - Port D Data Direction Register

sfrb DDRD = $0A;

DDD0 - Port D Data Direction Register bit 0

#define DDD0 0

DDD1 - Port D Data Direction Register bit 1

#define DDD1 1

DDD2 - Port D Data Direction Register bit 2

#define DDD2 2

DDD3 - Port D Data Direction Register bit 3

#define DDD3 3

DDD4 - Port D Data Direction Register bit 4

#define DDD4 4

DDD5 - Port D Data Direction Register bit 5

#define DDD5 5

DDD6 - Port D Data Direction Register bit 6

#define DDD6 6

DDD7 - Port D Data Direction Register bit 7

#define DDD7 7

PIND - Port D Input Pins

sfrb PIND = $09;

PIND0 - Port D Input Pins bit 0

#define PIND0 0

PIND1 - Port D Input Pins bit 1

#define PIND1 1

PIND2 - Port D Input Pins bit 2

#define PIND2 2

PIND3 - Port D Input Pins bit 3

#define PIND3 3

PIND4 - Port D Input Pins bit 4

#define PIND4 4

PIND5 - Port D Input Pins bit 5

#define PIND5 5

PIND6 - Port D Input Pins bit 6

#define PIND6 6

PIND7 - Port D Input Pins bit 7

#define PIND7 7

BOOT LOAD

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 suppor

SPMCSR - Store Program Memory Control Register

sfrb SPMCSR = $37;

SPMEN - Store Program Memory Enable

#define SPMEN 0

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 effec

PGERS - Page Erase

#define PGERS 1

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.

PGWRT - Page Write

#define PGWRT 2

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.

BLBSET - Boot Lock Bit Set

#define BLBSET 3

If this bit is written to one at the same time as SPMEN, the next SPM instruction within four clock cycles sets Boot Lock bits, according to the data in R0. The data in R1 and the address in the Z pointer are ignored. The BLBSET bit will automatically be cleared upon completion of the lock bit set, or if no SPM instruction is executed within four clock cycles. An LPM instruction within three cycles after BLBSET and SPMEN are set in the SPMCR register, will read either the Lock-bits or the Fuse bits (depending on Z0 in the Z pointer) into the destination register. See ?Reading the Fuse and Lock Bits from Software? on page 235 for details

RWWSRE - Read While Write section read enable

#define RWWSRE 4

When programming (page erase or page write) to the RWW section, the RWW section is blocked for reading (the RWWSB will be set by hardware). To re-enable the RWW section, the user software must wait until the programming is completed (SPMEN will be cleared). Then, if the RWWSRE bit is written to one at the same time as SPMEN, the next SPM instruction within four clock cycles re-enables the RWW section. The RWW section cannot be re-enabled while Flash is busy with a page erase or a page write (SPMEN is set). If the RWWSRE bit is written while the Flash is being loaded, the Flash load operation will abort and the data loaded will be lo

RWWSB - Read While Write Section Busy

#define RWWSB 6

When a self-programming (page erase or page write) operation to the RWW section is initiated, the RWWSB will be set (one) by hardware. When the RWWSB bit is set, the RWW section cannot be accessed. The RWWSB bit will be cleared if the RWWSRE bit is written to one after a self-programming operation is completed. Alternatively the RWWSB bit will auto-matically be cleared if a page load operation is initiated.

SPMIE - SPM Interrupt Enable

#define SPMIE 7

When the SPMIE bit is written to one, and the I-bit in the Status Register is set (one), the SPM ready interrupt will be enabled. The SPM ready Interrupt will be executed as long as the SPMEN bit in the SPMCR register is cleared.

EEPROM

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 execute

EEARH - EEPROM Read/Write Access High Byte

sfrb EEARH = $22;

EEAR8 - EEPROM Read/Write Access Bit 8

#define EEAR8 0

EEAR9 - EEPROM Read/Write Access Bit 9

#define EEAR9 1

EEAR10 - EEPROM Read/Write Access Bit 10

#define EEAR10 2

EEAR11 - EEPROM Read/Write Access Bit 11

#define EEAR11 3

EEARL - EEPROM Read/Write Access Low Byte

sfrb EEARL = $21;

EEARL0 - EEPROM Read/Write Access Bit 0

#define EEARL0 0

EEARL1 - EEPROM Read/Write Access Bit 1

#define EEARL1 1

EEARL2 - EEPROM Read/Write Access Bit 2

#define EEARL2 2

EEARL3 - EEPROM Read/Write Access Bit 3

#define EEARL3 3

EEARL4 - EEPROM Read/Write Access Bit 4

#define EEARL4 4

EEARL5 - EEPROM Read/Write Access Bit 5

#define EEARL5 5

EEARL6 - EEPROM Read/Write Access Bit 6

#define EEARL6 6

EEARL7 - EEPROM Read/Write Access Bit 7

#define EEARL7 7

EEDR - EEPROM Data Register

sfrb EEDR = $20;

EEDR0 - EEPROM Data Register bit 0

#define EEDR0 0

EEDR1 - EEPROM Data Register bit 1

#define EEDR1 1

EEDR2 - EEPROM Data Register bit 2

#define EEDR2 2

EEDR3 - EEPROM Data Register bit 3

#define EEDR3 3

EEDR4 - EEPROM Data Register bit 4

#define EEDR4 4

EEDR5 - EEPROM Data Register bit 5

#define EEDR5 5

EEDR6 - EEPROM Data Register bit 6

#define EEDR6 6

EEDR7 - EEPROM Data Register bit 7

#define EEDR7 7

EECR - EEPROM Control Register

sfrb EECR = $1F;

EERE - EEPROM Read Enable

#define EERE 0

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

EEWE - EEPROM Write Enable

#define EEWE 1

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

EEMWE - EEPROM Master Write Enable

#define EEMWE 2

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.

EERIE - EEPROM Ready Interrupt Enable

#define EERIE 3

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.

PSC0

Power Stage Controller

PICR0H - PSC 0 Input Capture Register High

sfrb PICR0H = 0xDF;

PICR0_8

#define PICR0_8 0

PICR0_9

#define PICR0_9 1

PICR0_10

#define PICR0_10 2

PICR0_11

#define PICR0_11 3

PICR0L - PSC 0 Input Capture Register Low

sfrb PICR0L = 0xDE;

PICR0_0

#define PICR0_0 0

PICR0_1

#define PICR0_1 1

PICR0_2

#define PICR0_2 2

PICR0_3

#define PICR0_3 3

PICR0_4

#define PICR0_4 4

PICR0_5

#define PICR0_5 5

PICR0_6

#define PICR0_6 6

PICR0_7

#define PICR0_7 7

PFRC0B - PSC 0 Input B Control

sfrb PFRC0B = 0xDD;

PRFM0B0 - PSC 0 Retrigger and Fault Mode for Part B

#define PRFM0B0 0

PRFM0B1 - PSC 0 Retrigger and Fault Mode for Part B

#define PRFM0B1 1

PRFM0B2 - PSC 0 Retrigger and Fault Mode for Part B

#define PRFM0B2 2

PRFM0B3 - PSC 0 Retrigger and Fault Mode for Part B

#define PRFM0B3 3

PFLTE0B - PSC 0 Filter Enable on Input Part B

#define PFLTE0B 4

PELEV0B - PSC 0 Edge Level Selector on Input Part B

#define PELEV0B 5

PISEL0B - PSC 0 Input Select for Part B

#define PISEL0B 6

PCAE0B - PSC 0 Capture Enable Input Part B

#define PCAE0B 7

PFRC0A - PSC 0 Input A Control

sfrb PFRC0A = 0xDC;

PRFM0A0 - PSC 0 Retrigger and Fault Mode for Part A

#define PRFM0A0 0

PRFM0A1 - PSC 0 Retrigger and Fault Mode for Part A

#define PRFM0A1 1

PRFM0A2 - PSC 0 Retrigger and Fault Mode for Part A

#define PRFM0A2 2

PRFM0A3 - PSC 0 Retrigger and Fault Mode for Part A

#define PRFM0A3 3

PFLTE0A - PSC 0 Filter Enable on Input Part A

#define PFLTE0A 4

PELEV0A - PSC 0 Edge Level Selector on Input Part A

#define PELEV0A 5

PISEL0A - PSC 0 Input Select for Part A

#define PISEL0A 6

PCAE0A - PSC 0 Capture Enable Input Part A

#define PCAE0A 7

PCTL0 - PSC 0 Control Register

sfrb PCTL0 = 0xDB;

PRUN0 - PSC 0 Run

#define PRUN0 0

PCCYC0 - PSC0 Complete Cycle

#define PCCYC0 1

PARUN0 - PSC0 Auto Run

#define PARUN0 2

PAOC0A - PSC 0 Asynchronous Output Control A

#define PAOC0A 3

PAOC0B - PSC 0 Asynchronous Output Control B

#define PAOC0B 4

PBFM0 - PSC 0 Balance Flank Width Modulation

#define PBFM0 5

PPRE00 - PSC 0 Prescaler Select 0

#define PPRE00 6

PPRE01 - PSC 0 Prescaler Select 1

#define PPRE01 7

PCNF0 - PSC 0 Configuration Register

sfrb PCNF0 = 0xDA;

PCLKSEL0 - PSC 0 Input Clock Select

#define PCLKSEL0 1

POP0 - PSC 0 Output Polarity

#define POP0 2

PMODE00 - PSC 0 Mode

#define PMODE00 3

PMODE01 - PSC 0 Mode

#define PMODE01 4

PLOCK0 - PSC 0 Lock

#define PLOCK0 5

PALOCK0 - PSC 0 Autolock

#define PALOCK0 6

PFIFTY0 - PSC 0 Fifty

#define PFIFTY0 7

OCR0RBH - Output Compare RB Register High

sfrb OCR0RBH = 0xD9;

OCR0RB_8

#define OCR0RB_8 0

OCR0RB_9

#define OCR0RB_9 1

OCR0RB_00

#define OCR0RB_00 2

OCR0RB_01

#define OCR0RB_01 3

OCR0RB_02

#define OCR0RB_02 4

OCR0RB_03

#define OCR0RB_03 5

OCR0RB_04

#define OCR0RB_04 6

OCR0RB_05

#define OCR0RB_05 7

OCR0RBL - Output Compare RB Register Low

sfrb OCR0RBL = 0xD8;

OCR0RB_0

#define OCR0RB_0 0

OCR0RB_1

#define OCR0RB_1 1

OCR0RB_2

#define OCR0RB_2 2

OCR0RB_3

#define OCR0RB_3 3

OCR0RB_4

#define OCR0RB_4 4

OCR0RB_5

#define OCR0RB_5 5

OCR0RB_6

#define OCR0RB_6 6

OCR0RB_7

#define OCR0RB_7 7

OCR0SBH - Output Compare SB Register High

sfrb OCR0SBH = 0xD7;

OCR0SB_8

#define OCR0SB_8 0

OCR0SB_9

#define OCR0SB_9 1

OCR0SB_00

#define OCR0SB_00 2

OCR0SB_01

#define OCR0SB_01 3

OCR0SBL - Output Compare SB Register Low

sfrb OCR0SBL = 0xD6;

OCR0SB_0

#define OCR0SB_0 0

OCR0SB_1

#define OCR0SB_1 1

OCR0SB_2

#define OCR0SB_2 2

OCR0SB_3

#define OCR0SB_3 3

OCR0SB_4

#define OCR0SB_4 4

OCR0SB_5

#define OCR0SB_5 5

OCR0SB_6

#define OCR0SB_6 6

OCR0SB_7

#define OCR0SB_7 7

OCR0RAH - Output Compare RA Register High

sfrb OCR0RAH = 0xD5;

OCR0RA_8

#define OCR0RA_8 0

OCR0RA_9

#define OCR0RA_9 1

OCR0RA_00

#define OCR0RA_00 2

OCR0RA_01

#define OCR0RA_01 3

OCR0RAL - Output Compare RA Register Low

sfrb OCR0RAL = 0xD4;

OCR0RA_0

#define OCR0RA_0 0

OCR0RA_1

#define OCR0RA_1 1

OCR0RA_2

#define OCR0RA_2 2

OCR0RA_3

#define OCR0RA_3 3

OCR0RA_4

#define OCR0RA_4 4

OCR0RA_5

#define OCR0RA_5 5

OCR0RA_6

#define OCR0RA_6 6

OCR0RA_7

#define OCR0RA_7 7

OCR0SAH - Output Compare SA Register High

sfrb OCR0SAH = 0xD3;

OCR0SA_8

#define OCR0SA_8 0

OCR0SA_9

#define OCR0SA_9 1

OCR0SA_00

#define OCR0SA_00 2

OCR0SA_01

#define OCR0SA_01 3

OCR0SAL - Output Compare SA Register Low

sfrb OCR0SAL = 0xD2;

OCR0SA_0

#define OCR0SA_0 0

OCR0SA_1

#define OCR0SA_1 1

OCR0SA_2

#define OCR0SA_2 2

OCR0SA_3

#define OCR0SA_3 3

OCR0SA_4

#define OCR0SA_4 4

OCR0SA_5

#define OCR0SA_5 5

OCR0SA_6

#define OCR0SA_6 6

OCR0SA_7

#define OCR0SA_7 7

PSOC0 - PSC0 Synchro and Output Configuration

sfrb PSOC0 = 0xD0;

POEN0A - PSCOUT00 Output Enable

#define POEN0A 0

POEN0B - PSCOUT01 Output Enable

#define POEN0B 2

PSYNC00 - Synchronization Out for ADC Selection

#define PSYNC00 4

PSYNC01 - Synchronization Out for ADC Selection

#define PSYNC01 5

PIM0 - PSC0 Interrupt Mask Register

sfrb PIM0 = $A1;

PEOPE0 - End of Cycle Interrupt Enable

#define PEOPE0 0

PEVE0A - External Event A Interrupt Enable

#define PEVE0A 3

PEVE0B - External Event B Interrupt Enable

#define PEVE0B 4

PSEIE0 - PSC 0 Synchro Error Interrupt Enable

#define PSEIE0 5

PIFR0 - PSC0 Interrupt Flag Register

sfrb PIFR0 = $A0;

PEOP0 - End of PSC0 Interrupt

#define PEOP0 0

PRN00 - Ramp Number

#define PRN00 1

PRN01 - Ramp Number

#define PRN01 2

PEV0A - External Event A Interrupt

#define PEV0A 3

PEV0B - External Event B Interrupt

#define PEV0B 4

PSEI0 - PSC 0 Synchro Error Interrupt

#define PSEI0 5

PSC2

Power Stage Controller

PICR2H - PSC 2 Input Capture Register High

sfrb PICR2H = 0xFF;

PICR2_8

#define PICR2_8 0

PICR2_9

#define PICR2_9 1

PICR2_10

#define PICR2_10 2

PICR2_11

#define PICR2_11 3

PICR2L - PSC 2 Input Capture Register Low

sfrb PICR2L = 0xFE;

PICR2_0

#define PICR2_0 0

PICR2_1

#define PICR2_1 1

PICR2_2

#define PICR2_2 2

PICR2_3

#define PICR2_3 3

PICR2_4

#define PICR2_4 4

PICR2_5

#define PICR2_5 5

PICR2_6

#define PICR2_6 6

PICR2_7

#define PICR2_7 7

PFRC2B - PSC 2 Input B Control

sfrb PFRC2B = 0xFD;

PRFM2B0 - PSC 2 Retrigger and Fault Mode for Part B

#define PRFM2B0 0

PRFM2B1 - PSC 2 Retrigger and Fault Mode for Part B

#define PRFM2B1 1

PRFM2B2 - PSC 2 Retrigger and Fault Mode for Part B

#define PRFM2B2 2

PRFM2B3 - PSC 2 Retrigger and Fault Mode for Part B

#define PRFM2B3 3

PFLTE2B - PSC 2 Filter Enable on Input Part B

#define PFLTE2B 4

PELEV2B - PSC 2 Edge Level Selector on Input Part B

#define PELEV2B 5

PISEL2B - PSC 2 Input Select for Part B

#define PISEL2B 6

PCAE2B - PSC 2 Capture Enable Input Part B

#define PCAE2B 7

PFRC2A - PSC 2 Input B Control

sfrb PFRC2A = 0xFC;

PRFM2A0 - PSC 2 Retrigger and Fault Mode for Part A

#define PRFM2A0 0

PRFM2A1 - PSC 2 Retrigger and Fault Mode for Part A

#define PRFM2A1 1

PRFM2A2 - PSC 2 Retrigger and Fault Mode for Part A

#define PRFM2A2 2

PRFM2A3 - PSC 2 Retrigger and Fault Mode for Part A

#define PRFM2A3 3

PFLTE2A - PSC 2 Filter Enable on Input Part A

#define PFLTE2A 4

PELEV2A - PSC 2 Edge Level Selector on Input Part A

#define PELEV2A 5

PISEL2A - PSC 2 Input Select for Part A

#define PISEL2A 6

PCAE2A - PSC 2 Capture Enable Input Part A

#define PCAE2A 7

PCTL2 - PSC 2 Control Register

sfrb PCTL2 = 0xFB;

PRUN2 - PSC 2 Run

#define PRUN2 0

PCCYC2 - PSC2 Complete Cycle

#define PCCYC2 1

PARUN2 - PSC2 Auto Run

#define PARUN2 2

PAOC2A - PSC 2 Asynchronous Output Control A

#define PAOC2A 3

PAOC2B - PSC 2 Asynchronous Output Control B

#define PAOC2B 4

PBFM2 - Balance Flank Width Modulation

#define PBFM2 5

PPRE20 - PSC 2 Prescaler Select 0

#define PPRE20 6

PPRE21 - PSC 2 Prescaler Select 1

#define PPRE21 7

PCNF2 - PSC 2 Configuration Register

sfrb PCNF2 = 0xFA;

POME2 - PSC 2 Output Matrix Enable

#define POME2 0

PCLKSEL2 - PSC 2 Input Clock Select

#define PCLKSEL2 1

POP2 - PSC 2 Output Polarity

#define POP2 2

PMODE20 - PSC 2 Mode

#define PMODE20 3

PMODE21 - PSC 2 Mode

#define PMODE21 4

PLOCK2 - PSC 2 Lock

#define PLOCK2 5

PALOCK2 - PSC 2 Autolock

#define PALOCK2 6

PFIFTY2 - PSC 2 Fifty

#define PFIFTY2 7

OCR2RBH - Output Compare RB Register High

sfrb OCR2RBH = 0xF9;

OCR2RB_8

#define OCR2RB_8 0

OCR2RB_9

#define OCR2RB_9 1

OCR2RB_10

#define OCR2RB_10 2

OCR2RB_11

#define OCR2RB_11 3

OCR2RB_12

#define OCR2RB_12 4

OCR2RB_13

#define OCR2RB_13 5

OCR2RB_14

#define OCR2RB_14 6

OCR2RB_15

#define OCR2RB_15 7

OCR2RBL - Output Compare RB Register Low

sfrb OCR2RBL = 0xF8;

OCR2RB_0

#define OCR2RB_0 0

OCR2RB_1

#define OCR2RB_1 1

OCR2RB_2

#define OCR2RB_2 2

OCR2RB_3

#define OCR2RB_3 3

OCR2RB_4

#define OCR2RB_4 4

OCR2RB_5

#define OCR2RB_5 5

OCR2RB_6

#define OCR2RB_6 6

OCR2RB_7

#define OCR2RB_7 7

OCR2SBH - Output Compare SB Register High

sfrb OCR2SBH = 0xF7;

OCR2SB_8

#define OCR2SB_8 0

OCR2SB_9

#define OCR2SB_9 1

OCR2SB_10

#define OCR2SB_10 2

OCR2SB_11

#define OCR2SB_11 3

OCR2SBL - Output Compare SB Register Low

sfrb OCR2SBL = 0xF6;

OCR2SB_0

#define OCR2SB_0 0

OCR2SB_1

#define OCR2SB_1 1

OCR2SB_2

#define OCR2SB_2 2

OCR2SB_3

#define OCR2SB_3 3

OCR2SB_4

#define OCR2SB_4 4

OCR2SB_5

#define OCR2SB_5 5

OCR2SB_6

#define OCR2SB_6 6

OCR2SB_7

#define OCR2SB_7 7

OCR2RAH - Output Compare RA Register High

sfrb OCR2RAH = 0xF5;

OCR2RA_8

#define OCR2RA_8 0

OCR2RA_9

#define OCR2RA_9 1

OCR2RA_10

#define OCR2RA_10 2

OCR2RA_11

#define OCR2RA_11 3

OCR2RAL - Output Compare RA Register Low

sfrb OCR2RAL = 0xF4;

OCR2RA_0

#define OCR2RA_0 0

OCR2RA_1

#define OCR2RA_1 1

OCR2RA_2

#define OCR2RA_2 2

OCR2RA_3

#define OCR2RA_3 3

OCR2RA_4

#define OCR2RA_4 4

OCR2RA_5

#define OCR2RA_5 5

OCR2RA_6

#define OCR2RA_6 6

OCR2RA_7

#define OCR2RA_7 7

OCR2SAH - Output Compare SA Register High

sfrb OCR2SAH = 0xF3;

OCR2SA_8

#define OCR2SA_8 0

OCR2SA_9

#define OCR2SA_9 1

OCR2SA_10

#define OCR2SA_10 2

OCR2SA_11

#define OCR2SA_11 3

OCR2SAL - Output Compare SA Register Low

sfrb OCR2SAL = 0xF2;

OCR2SA_0

#define OCR2SA_0 0

OCR2SA_1

#define OCR2SA_1 1

OCR2SA_2

#define OCR2SA_2 2

OCR2SA_3

#define OCR2SA_3 3

OCR2SA_4

#define OCR2SA_4 4

OCR2SA_5

#define OCR2SA_5 5

OCR2SA_6

#define OCR2SA_6 6

OCR2SA_7

#define OCR2SA_7 7

POM2 - PSC 2 Output Matrix

sfrb POM2 = 0xF1;

POMV2A0 - Output Matrix Output A Ramp 0

#define POMV2A0 0

POMV2A1 - Output Matrix Output A Ramp 1

#define POMV2A1 1

POMV2A2 - Output Matrix Output A Ramp 2

#define POMV2A2 2

POMV2A3 - Output Matrix Output A Ramp 3

#define POMV2A3 3

POMV2B0 - Output Matrix Output B Ramp 0

#define POMV2B0 4

POMV2B1 - Output Matrix Output B Ramp 2

#define POMV2B1 5

POMV2B2 - Output Matrix Output B Ramp 2

#define POMV2B2 6

POMV2B3 - Output Matrix Output B Ramp 3

#define POMV2B3 7

PSOC2 - PSC2 Synchro and Output Configuration

sfrb PSOC2 = 0xF0;

POEN2A - PSCOUT20 Output Enable

#define POEN2A 0

POEN2C - PSCOUT22 Output Enable

#define POEN2C 1

POEN2B - PSCOUT21 Output Enable

#define POEN2B 2

POEN2D - PSCOUT23 Output Enable

#define POEN2D 3

PSYNC2_0 - Synchronization Out for ADC Selection

#define PSYNC2_0 4

PSYNC2_1 - Synchronization Out for ADC Selection

#define PSYNC2_1 5

POS22 - PSC 2 Output 22 Select

#define POS22 6

POS23 - PSC 2 Output 23 Select

#define POS23 7

PIM2 - PSC2 Interrupt Mask Register

sfrb PIM2 = $A5;

PEOPE2 - End of Cycle Interrupt Enable

#define PEOPE2 0

PEVE2A - External Event A Interrupt Enable

#define PEVE2A 3

PEVE2B - External Event B Interrupt Enable

#define PEVE2B 4

PSEIE2 - PSC 2 Synchro Error Interrupt Enable

#define PSEIE2 5

PIFR2 - PSC2 Interrupt Flag Register

sfrb PIFR2 = $A4;

PEOP2 - End of PSC2 Interrupt

#define PEOP2 0

PRN20 - Ramp Number

#define PRN20 1

PRN21 - Ramp Number

#define PRN21 2

PEV2A - External Event A Interrupt

#define PEV2A 3

PEV2B - External Event B Interrupt

#define PEV2B 4

PSEI2 - PSC 2 Synchro Error Interrupt

#define PSEI2 5

EUSART

EUDR - EUSART I/O Data Register

sfrb EUDR = 0xCE;

EUDR0 - EUSART I/O Data Register bit 0

#define EUDR0 0

EUDR1 - EUSART I/O Data Register bit 1

#define EUDR1 1

EUDR2 - EUSART I/O Data Register bit 2

#define EUDR2 2

EUDR3 - EUSART I/O Data Register bit 3

#define EUDR3 3

EUDR4 - EUSART I/O Data Register bit 4

#define EUDR4 4

EUDR5 - EUSART I/O Data Register bit 5

#define EUDR5 5

EUDR6 - EUSART I/O Data Register bit 6

#define EUDR6 6

EUDR7 - EUSART I/O Data Register bit 7

#define EUDR7 7

EUCSRA - EUSART Control and Status Register A

sfrb EUCSRA = 0xC8;

URxS0 - EUSART Control and Status Register A Bit 0

#define URxS0 0

URxS1 - EUSART Control and Status Register A Bit 1

#define URxS1 1

URxS2 - EUSART Control and Status Register A Bit 2

#define URxS2 2

URxS3 - EUSART Control and Status Register A Bit 3

#define URxS3 3

UTxS0 - EUSART Control and Status Register A Bit 4

#define UTxS0 4

UTxS1 - EUSART Control and Status Register A Bit 5

#define UTxS1 5

UTxS2 - EUSART Control and Status Register A Bit 6

#define UTxS2 6

UTxS3 - EUSART Control and Status Register A Bit 7

#define UTxS3 7

.

EUCSRB - EUSART Control Register B

sfrb EUCSRB = 0xC9;

BODR - Order Bit

#define BODR 0

EMCH - Manchester Mode Bit

#define EMCH 1

EUSBS - EUSBS Enable Bit

#define EUSBS 3

EUSART - EUSART Enable Bit

#define EUSART 4

EUCSRC - EUSART Status Register C

sfrb EUCSRC = 0xCA;

STP0 - Stop Bit 0

#define STP0 0

STP1 - Stop Bit 1

#define STP1 1

F1617 - F1617 Bit

#define F1617 2

FEM - Frame Error Manchester Bit

#define FEM 3

MUBRRH - Manchester Receiver Baud Rate Register High Byte

sfrb MUBRRH = 0xCD;

MUBRR8 - Manchester Receiver Baud Rate Register Bit 8

#define MUBRR8 0

MUBRR9 - Manchester Receiver Baud Rate Register Bit 9

#define MUBRR9 1

MUBRR10 - Manchester Receiver Baud Rate Register Bit 10

#define MUBRR10 2

MUBRR11 - Manchester Receiver Baud Rate Register Bit 11

#define MUBRR11 3

MUBRR12 - Manchester Receiver Baud Rate Register Bit 12

#define MUBRR12 4

MUBRR13 - Manchester Receiver Baud Rate Register Bit 13

#define MUBRR13 5

MUBRR14 - Manchester Receiver Baud Rate Register Bit 14

#define MUBRR14 6

MUBRR15 - Manchester Receiver Baud Rate Register Bit 15

#define MUBRR15 7

MUBRRL - Manchester Receiver Baud Rate Register Low Byte

sfrb MUBRRL = 0xCC;

MUBRR0 - Manchester Receiver Baud Rate Register Bit 0

#define MUBRR0 0

MUBRR1 - Manchester Receiver Baud Rate Register Bit 1

#define MUBRR1 1

MUBRR2 - Manchester Receiver Baud Rate Register Bit 2

#define MUBRR2 2

MUBRR3 - Manchester Receiver Baud Rate Register Bit 3

#define MUBRR3 3

MUBRR4 - Manchester Receiver Baud Rate Register Bit 4

#define MUBRR4 4

MUBRR5 - Manchester Receiver Baud Rate Register Bit 5

#define MUBRR5 5

MUBRR6 - Manchester Receiver Baud Rate Register Bit 6

#define MUBRR6 6

MUBRR7 - Manchester Receiver Baud Rate Register Bit 7

#define MUBRR7 7

ANALOG COMPARATOR

AC0CON - Analog Comparator 0 Control Register

sfrb AC0CON = $AD;

AC0M0 - Analog Comparator 0 Multiplexer Register

#define AC0M0 0

AC0M1 - Analog Comparator 0 Multiplexer Regsiter

#define AC0M1 1

AC0M2 - Analog Comparator 0 Multiplexer Register

#define AC0M2 2

AC0IS0 - Analog Comparator 0 Interrupt Select Bit

#define AC0IS0 4

AC0IS1 - Analog Comparator 0 Interrupt Select Bit

#define AC0IS1 5

AC0IE - Analog Comparator 0 Interrupt Enable Bit

#define AC0IE 6

AC0EN - Analog Comparator 0 Enable Bit

#define AC0EN 7

AC1CON - Analog Comparator 1 Control Register

sfrb AC1CON = $AE;

AC1M0 - Analog Comparator 1 Multiplexer Register

#define AC1M0 0

AC1M1 - Analog Comparator 1 Multiplexer Regsiter

#define AC1M1 1

AC1M2 - Analog Comparator 1 Multiplexer Register

#define AC1M2 2

AC1ICE - Analog Comparator 1 Interrupt Capture Enable Bit

#define AC1ICE 3

AC1IS0 - Analog Comparator 1 Interrupt Select Bit

#define AC1IS0 4

AC1IS1 - Analog Comparator 1 Interrupt Select Bit

#define AC1IS1 5

AC1IE - Analog Comparator 1 Interrupt Enable Bit

#define AC1IE 6

AC1EN - Analog Comparator 1 Enable Bit

#define AC1EN 7

AC2CON - Analog Comparator 2 Control Register

sfrb AC2CON = $AF;

AC2M0 - Analog Comparator 2 Multiplexer Register

#define AC2M0 0

AC2M1 - Analog Comparator 2 Multiplexer Regsiter

#define AC2M1 1

AC2M2 - Analog Comparator 2 Multiplexer Register

#define AC2M2 2

AC2SADE - Analog Comparator 2 Start A/D Conversion Enable Bit

#define AC2SADE 3

AC2IS0 - Analog Comparator 2 Interrupt Select Bit

#define AC2IS0 4

AC2IS1 - Analog Comparator 2 Interrupt Select Bit

#define AC2IS1 5

AC2IE - Analog Comparator 2 Interrupt Enable Bit

#define AC2IE 6

AC2EN - Analog Comparator 2 Enable Bit

#define AC2EN 7

DA CONVERTER

Digital to Analog Converter

DACH - DAC Data Register High Byte

sfrb DACH = $AC;

DACH0 - DAC Data Register High Byte Bit 0

#define DACH0 0

DACH1 - DAC Data Register High Byte Bit 1

#define DACH1 1

DACH2 - DAC Data Register High Byte Bit 2

#define DACH2 2

DACH3 - DAC Data Register High Byte Bit 3

#define DACH3 3

DACH4 - DAC Data Register High Byte Bit 4

#define DACH4 4

DACH5 - DAC Data Register High Byte Bit 5

#define DACH5 5

DACH6 - DAC Data Register High Byte Bit 6

#define DACH6 6

DACH7 - DAC Data Register High Byte Bit 7

#define DACH7 7

DACL - DAC Data Register Low Byte

sfrb DACL = $AB;

DACL1 - DAC Data Register Low Byte Bit 1

#define DACL1 1

DACL2 - DAC Data Register Low Byte Bit 2

#define DACL2 2

DACL3 - DAC Data Register Low Byte Bit 3

#define DACL3 3

DACL4 - DAC Data Register Low Byte Bit 4

#define DACL4 4

DACL5 - DAC Data Register Low Byte Bit 5

#define DACL5 5

DACL6 - DAC Data Register Low Byte Bit 6

#define DACL6 6

DACL7 - DAC Data Register Low Byte Bit 7

#define DACL7 7

DACON - DAC Control Register

sfrb DACON = $AA;

DAEN - DAC Enable Bit

#define DAEN 0

DAOE - DAC Output Enable Bit

#define DAOE 1

DALA - DAC Left Adjust

#define DALA 2

DATS0 - DAC Trigger Selection Bit 0

#define DATS0 4

DATS1 - DAC Trigger Selection Bit 1

#define DATS1 5

DATS2 - DAC Trigger Selection Bit 2

#define DATS2 6

DAATE - DAC Auto Trigger Enable Bit

#define DAATE 7

CPU

SREG - Status Register

sfrb SREG = $3F;

SPH - Stack Pointer High

sfrb SPH = $3E;

SP8 - Stack pointer bit 8

#define SP8 0

SP9 - Stack pointer bit 9

#define SP9 1

SP10 - Stack pointer bit 10

#define SP10 2

SP11 - Stack pointer bit 11

#define SP11 3

SP12

#define SP12 4

SP13 - Stack pointer bit 13

#define SP13 5

SP14 - Stack pointer bit 14

#define SP14 6

SP15 - Stack pointer bit 15

#define SP15 7

SPL - Stack Pointer Low

sfrb SPL = $3D;

SP0 - Stack pointer bit 0

#define SP0 0

SP1 - Stack pointer bit 1

#define SP1 1

SP2 - Stack pointer bit 2

#define SP2 2

SP3 - Stack pointer bit 3

#define SP3 3

SP4

#define SP4 4

SP5 - Stack pointer bit 5

#define SP5 5

SP6 - Stack pointer bit 6

#define SP6 6

SP7 - Stack pointer bit 7

#define SP7 7

MCUCR - MCU Control Register

sfrb MCUCR = $35;

IVCE - Interrupt Vector Change Enable

#define IVCE 0

The IVCE bit must be written to logic one to enable change of the IVSEL bit.IVCE is cleared by hardware four cycles after it is written or when IVSEL is written.Setting the IVCE bit will disable interrupts.

IVSEL - Interrupt Vector Select

#define IVSEL 1

When the IVSEL bit is cleared (zero),the interrupt vectors are placed at the start of the Flash memory.When this bit is set (one),the interrupt vectors are moved to the beginning of the Boot Loader section of the flash.The actual address of the start of the boot flash section is determined by the BOOTSZ fuses.

PUD - Pull-up disable

#define PUD 4

When this bit is written to one,the pull-ups in the I/O ports are disabled even if the DDxn and PORTxn registers are configured to enable the pull-ups ({DDxn,PORTxn}=0b01).

SPIPS - SPI Pin Select

#define SPIPS 7

MCUSR - MCU Status Register

sfrb MCUSR = $34;

PORF - Power-on reset flag

#define PORF 0

This bit is set if a power-on reset occurs. The bit is reset only by writing a logic zero to the flag. To make use of the reset flags to identify a reset condition, the user should read and then reset the MCUCSR as early as possible in the program. If the register is cleared before another reset occurs, the source of the reset can be found by examining the reset flags.

EXTRF - External Reset Flag

#define EXTRF 1

This bit is set if an external reset occurs. The bit is reset by a power-on reset, or by writing a logic zero to the flag.

BORF - Brown-out Reset Flag

#define BORF 2

This bit is set if a brown-out reset occurs. The bit is reset by a power-on reset, or by writing a logic zero to the flag.

WDRF - Watchdog Reset Flag

#define WDRF 3

This bit is set if a watchdog reset occurs. The bit is reset by a power-on reset, or by writing a logic zero to the flag.

OSCCAL - Oscillator Calibration Value

sfrb OSCCAL = $66;

CAL0 - Oscillator Calibration Value Bit0

#define CAL0 0

CAL1 - Oscillator Calibration Value Bit1

#define CAL1 1

CAL2 - Oscillator Calibration Value Bit2

#define CAL2 2

CAL3 - Oscillator Calibration Value Bit3

#define CAL3 3

CAL4 - Oscillator Calibration Value Bit4

#define CAL4 4

CAL5 - Oscillator Calibration Value Bit5

#define CAL5 5

CAL6 - Oscillator Calibration Value Bit6

#define CAL6 6

CLKPR -

sfrb CLKPR = $61;

CLKPS0

#define CLKPS0 0

CLKPS1

#define CLKPS1 1

CLKPS2

#define CLKPS2 2

CLKPS3

#define CLKPS3 3

CPKPCE

#define CPKPCE 7

SMCR - Sleep Mode Control Register

sfrb SMCR = $33;

SE - Sleep Enable

#define SE 0

The SE bit must be written to logic one to make the MCU enter the sleep mode when the SLEEP instruction is executed.To

SM0 - Sleep Mode Select bit 0

#define SM0 1

These bits select between the five available sleep modes.

SM1 - Sleep Mode Select bit 1

#define SM1 2

These bits select between the five available sleep modes.

SM2 - Sleep Mode Select bit 2

#define SM2 3

These bits select between the five available sleep modes.

GPIOR3 - General Purpose IO Register 3

sfrb GPIOR3 = $1B;

GPIOR30 - General Purpose IO Register 3 bit 0

#define GPIOR30 0

GPIOR31 - General Purpose IO Register 3 bit 1

#define GPIOR31 1

GPIOR32 - General Purpose IO Register 3 bit 2

#define GPIOR32 2

GPIOR33 - General Purpose IO Register 3 bit 3

#define GPIOR33 3

GPIOR34 - General Purpose IO Register 3 bit 4

#define GPIOR34 4

GPIOR35 - General Purpose IO Register 3 bit 5

#define GPIOR35 5

GPIOR36 - General Purpose IO Register 3 bit 6

#define GPIOR36 6

GPIOR37 - General Purpose IO Register 3 bit 7

#define GPIOR37 7

GPIOR2 - General Purpose IO Register 2

sfrb GPIOR2 = $1A;

GPIOR20 - General Purpose IO Register 2 bit 0

#define GPIOR20 0

GPIOR21 - General Purpose IO Register 2 bit 1

#define GPIOR21 1

GPIOR22 - General Purpose IO Register 2 bit 2

#define GPIOR22 2

GPIOR23 - General Purpose IO Register 2 bit 3

#define GPIOR23 3

GPIOR24 - General Purpose IO Register 2 bit 4

#define GPIOR24 4

GPIOR25 - General Purpose IO Register 2 bit 5

#define GPIOR25 5

GPIOR26 - General Purpose IO Register 2 bit 6

#define GPIOR26 6

GPIOR27 - General Purpose IO Register 2 bit 7

#define GPIOR27 7

GPIOR1 - General Purpose IO Register 1

sfrb GPIOR1 = $19;

GPIOR10 - General Purpose IO Register 1 bit 0

#define GPIOR10 0

GPIOR11 - General Purpose IO Register 1 bit 1

#define GPIOR11 1

GPIOR12 - General Purpose IO Register 1 bit 2

#define GPIOR12 2

GPIOR13 - General Purpose IO Register 1 bit 3

#define GPIOR13 3

GPIOR14 - General Purpose IO Register 1 bit 4

#define GPIOR14 4

GPIOR15 - General Purpose IO Register 1 bit 5

#define GPIOR15 5

GPIOR16 - General Purpose IO Register 1 bit 6

#define GPIOR16 6

GPIOR17 - General Purpose IO Register 1 bit 7

#define GPIOR17 7

GPIOR0 - General Purpose IO Register 0

sfrb GPIOR0 = $1E;

GPIOR00 - General Purpose IO Register 0 bit 0

#define GPIOR00 0

GPIOR01 - General Purpose IO Register 0 bit 1

#define GPIOR01 1

GPIOR02 - General Purpose IO Register 0 bit 2

#define GPIOR02 2

GPIOR03 - General Purpose IO Register 0 bit 3

#define GPIOR03 3

GPIOR04 - General Purpose IO Register 0 bit 4

#define GPIOR04 4

GPIOR05 - General Purpose IO Register 0 bit 5

#define GPIOR05 5

GPIOR06 - General Purpose IO Register 0 bit 6

#define GPIOR06 6

GPIOR07 - General Purpose IO Register 0 bit 7

#define GPIOR07 7

PLLCSR - PLL Control And Status Register

sfrb PLLCSR = $29;

PLOCK - PLL Lock Detector

#define PLOCK 0

PLLE - PLL Enable

#define PLLE 1

PCKE - PCK Enable

#define PCKE 2

PORTE

PORTE - Port E Data Register

sfrb PORTE = $0E;

PORTE0

#define PORTE0 0

PORTE1

#define PORTE1 1

PORTE2

#define PORTE2 2

DDRE - Port E Data Direction Register

sfrb DDRE = $0D;

DDE0

#define DDE0 0

DDE1

#define DDE1 1

DDE2

#define DDE2 2

PINE - Port E Input Pins

sfrb PINE = $0C;

PINE0

#define PINE0 0

PINE1

#define PINE1 1

PINE2

#define PINE2 2

TIMER COUNTER 0

TIMSK0 - Timer/Counter0 Interrupt Mask Register

sfrb TIMSK0 = $6E;

TOIE0 - Timer/Counter0 Overflow Interrupt Enable

#define TOIE0 0

OCIE0A - Timer/Counter0 Output Compare Match A Interrupt Enable

#define OCIE0A 1

OCIE0B - Timer/Counter0 Output Compare Match B Interrupt Enable

#define OCIE0B 2

TIFR0 - Timer/Counter0 Interrupt Flag register

sfrb TIFR0 = $15;

TOV0 - Timer/Counter0 Overflow Flag

#define TOV0 0

OCF0A - Timer/Counter0 Output Compare Flag 0A

#define OCF0A 1

OCF0B - Timer/Counter0 Output Compare Flag 0B

#define OCF0B 2

TCCR0A - Timer/Counter Control Register A

sfrb TCCR0A = $24;

WGM00 - Waveform Generation Mode

#define WGM00 0

WGM01 - Waveform Generation Mode

#define WGM01 1

COM0B0 - Compare Output Mode, Fast PWm

#define COM0B0 4

COM0B1 - Compare Output Mode, Fast PWm

#define COM0B1 5

COM0A0 - Compare Output Mode, Phase Correct PWM Mode

#define COM0A0 6

COM0A1 - Compare Output Mode, Phase Correct PWM Mode

#define COM0A1 7

TCCR0B - Timer/Counter Control Register B

sfrb TCCR0B = $25;

CS00 - Clock Select

#define CS00 0

CS01 - Clock Select

#define CS01 1

CS02 - Clock Select

#define CS02 2

WGM02

#define WGM02 3

FOC0B - Force Output Compare B

#define FOC0B 6

FOC0A - Force Output Compare A

#define FOC0A 7

TCNT0 - Timer/Counter0

sfrb TCNT0 = $26;

TCNT0_0

#define TCNT0_0 0

TCNT0_1

#define TCNT0_1 1

TCNT0_2

#define TCNT0_2 2

TCNT0_3

#define TCNT0_3 3

TCNT0_4

#define TCNT0_4 4

TCNT0_5

#define TCNT0_5 5

TCNT0_6

#define TCNT0_6 6

TCNT0_7

#define TCNT0_7 7

OCR0A - Timer/Counter0 Output Compare Register

sfrb OCR0A = $27;

OCR0_0

#define OCR0_0 0

OCR0_1

#define OCR0_1 1

OCR0_2

#define OCR0_2 2

OCR0_3

#define OCR0_3 3

OCR0_4

#define OCR0_4 4

OCR0_5

#define OCR0_5 5

OCR0_6

#define OCR0_6 6

OCR0_7

#define OCR0_7 7

OCR0B - Timer/Counter0 Output Compare Register

sfrb OCR0B = $28;

OCR0_0

#define OCR0_0 0

OCR0_1

#define OCR0_1 1

OCR0_2

#define OCR0_2 2

OCR0_3

#define OCR0_3 3

OCR0_4

#define OCR0_4 4

OCR0_5

#define OCR0_5 5

OCR0_6

#define OCR0_6 6

OCR0_7

#define OCR0_7 7

GTCCR - General Timer/Counter Control Register

sfrb GTCCR = $23;

PSR10 - Prescaler Reset Timer/Counter1 and Timer/Counter0

#define PSR10 0

When this bit is one, Timer/Counter1 and Timer/Counter0 prescaler will be Reset. This bit is normally cleared immediately by hardware, except if the TSM bit is set. Note that Timer/Counter1 and Timer/Counter0 share the same prescaler and a reset of this prescaler will affect both timers.

ICPSEL1 - Timer1 Input Capture Selection Bit

#define ICPSEL1 6

TSM - Timer/Counter Synchronization Mode

#define TSM 7

Writing the TSM bit to one activates the Timer/Counter Synchronization mode. In this mode, the value that is written to the PSR2 and PSR10 bits is kept, hence keeping the corresponding prescaler reset signals asserted. This ensures that the corresponding Timer/Counters are halted and can be configured to the same value without the risk of one of them advancing during configuration. When the TSM bit is written to zero, the PSR2 and PSR10 bits are cleared by hardware, and the Timer/Counters start counting simultaneousl

TIMER COUNTER 1

TIMSK1 - Timer/Counter Interrupt Mask Register

sfrb TIMSK1 = $6F;

TOIE1 - Timer/Counter1 Overflow Interrupt Enable

#define TOIE1 0

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 $006) 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.

OCIE1A - Timer/Counter1 Output CompareA Match Interrupt Enable

#define OCIE1A 1

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.

OCIE1B - Timer/Counter1 Output CompareB Match Interrupt Enable

#define OCIE1B 2

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 (at vector $005) 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.

ICIE1 - Timer/Counter1 Input Capture Interrupt Enable

#define ICIE1 5

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 31, ICP, i.e., when the ICF1 bit is set in the Timer/Counter Interrupt Flag Register - TIFR.

TIFR1 - Timer/Counter Interrupt Flag register

sfrb TIFR1 = $16;

TOV1 - Timer/Counter1 Overflow Flag

#define TOV1 0

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.

OCF1A - Output Compare Flag 1A

#define OCF1A 1

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.

OCF1B - Output Compare Flag 1B

#define OCF1B 2

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 OCIE1B (Timer/Counter1 Compare match InterruptB Enable), and the OCF1B are set (one), the Timer/Counter1 Compare B match Interrupt is executed.

ICF1 - Input Capture Flag 1

#define ICF1 5

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.

TCCR1A - Timer/Counter1 Control Register A

sfrb TCCR1A = $80;

WGM10 - Waveform Generation Mode

#define WGM10 0

Combined with the WGM13:2 bits found in the TCCR1B register,these bits control the counting sequence of the counter, the source for maximum (TOP)counter value,and what type of waveform generation to be used.Modes of operation supported by the timer/counter unit are:Normal mode (counter),Clear Timer on Compare match (CTC)mode,and three types of Pulse Width Modulation (PWM)modes. PLease refer to the manual for a Mode Bit Description Table.

WGM11 - Waveform Generation Mode

#define WGM11 1

Combined with the WGM13:2 bits found in the TCCR1B register,these bits control the counting sequence of the counter, the source for maximum (TOP)counter value,and what type of waveform generation to be used.Modes of operation supported by the timer/counter unit are:Normal mode (counter),Clear Timer on Compare match (CTC)mode,and three types of Pulse Width Modulation (PWM)modes. PLease refer to the manual for a Mode Bit Description Table.

COM1B0 - Compare Output Mode 1B, bit 0

#define COM1B0 4

The COM1B1 and COM1B0 control bits determine any output pin action following a compare match in Timer/Counter1. Any output pin actions affect pin OC1B - Output CompareB. This is an alternative function to an I/O port, and the corre-sponding direction control bit must be set (one) to control an output pin.

COM1B1 - Compare Output Mode 1B, bit 1

#define COM1B1 5

The COM1B1 and COM1B0 control bits determine any output pin action following a compare match in Timer/Counter1. Any output pin actions affect pin OC1B - Output CompareB. This is an alternative function to an I/O port, and the corre-sponding direction control bit must be set (one) to control an output pin.

COM1A0 - Comparet Ouput Mode 1A, bit 0

#define COM1A0 6

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. This is an alternative function to an I/O port, and the corresponding direction control bit must be set (one) to control an output pin. The control configuration is shown in Table 10.

COM1A1 - Compare Output Mode 1A, bit 1

#define COM1A1 7

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. This is an alternative function to an I/O port, and the corresponding direction control bit must be set (one) to control an output pin. The control configuration is shown in Table 10.

TCCR1B - Timer/Counter1 Control Register B

sfrb TCCR1B = $81;

CS10 - Prescaler source of Timer/Counter 1

#define CS10 0

Select Prescaling Clock Source of Timer/Counter1. (0:0:0) = Stop. (0:0:1) = CK. (0:1:0) = CK / 8. (0:1:1) = CK / 64. (1:0:0) = CK / 256. (1:0:1) = CK / 1024. (1:1:0) = External Pin T1, falling edge. (1:1:1) = External Pin 1, rising edge.

CS11 - Prescaler source of Timer/Counter 1

#define CS11 1

Select Prescaling Clock Source of Timer/Counter1. (0:0:0) = Stop. (0:0:1) = CK. (0:1:0) = CK / 8. (0:1:1) = CK / 64. (1:0:0) = CK / 256. (1:0:1) = CK / 1024. (1:1:0) = External Pin T1, falling edge. (1:1:1) = External Pin 1, rising edge.

CS12 - Prescaler source of Timer/Counter 1

#define CS12 2

Select Prescaling Clock Source of Timer/Counter1. (0:0:0) = Stop. (0:0:1) = CK. (0:1:0) = CK / 8. (0:1:1) = CK / 64. (1:0:0) = CK / 256. (1:0:1) = CK / 1024. (1:1:0) = External Pin T1, falling edge. (1:1:1) = External Pin 1, rising edge.

WGM12 - Waveform Generation Mode

#define WGM12 3

Combined with the WGM13:2 bits found in the TCCR1B register,these bits control the counting sequence of the counter, the source for maximum (TOP)counter value,and what type of waveform generation to be used.Modes of operation supported by the timer/counter unit are:Normal mode (counter),Clear Timer on Compare match (CTC)mode,and three types of Pulse Width Modulation (PWM)modes. PLease refer to the manual for a Mode Bit Description Table.

WGM13 - Waveform Generation Mode

#define WGM13 4

Combined with the WGM13:2 bits found in the TCCR1B register,these bits control the counting sequence of the counter, the source for maximum (TOP)counter value,and what type of waveform generation to be used.Modes of operation supported by the timer/counter unit are:Normal mode (counter),Clear Timer on Compare match (CTC)mode,and three types of Pulse Width Modulation (PWM)modes. PLease refer to the manual for a Mode Bit Description Table.

ICES1 - Input Capture 1 Edge Select

#define ICES1 6

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.

ICNC1 - Input Capture 1 Noise Canceler

#define ICNC1 7

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.

TCCR1C - Timer/Counter1 Control Register C

sfrb TCCR1C = $82;

FOC1B

#define FOC1B 6

FOC1A

#define FOC1A 7

TCNT1H - Timer/Counter1 High Byte

sfrb TCNT1H = $85;

TCNT1H0 - Timer/Counter1 High Byte bit 0

#define TCNT1H0 0

TCNT1H1 - Timer/Counter1 High Byte bit 1

#define TCNT1H1 1

TCNT1H2 - Timer/Counter1 High Byte bit 2

#define TCNT1H2 2

TCNT1H3 - Timer/Counter1 High Byte bit 3

#define TCNT1H3 3

TCNT1H4 - Timer/Counter1 High Byte bit 4

#define TCNT1H4 4

TCNT1H5 - Timer/Counter1 High Byte bit 5

#define TCNT1H5 5

TCNT1H6 - Timer/Counter1 High Byte bit 6

#define TCNT1H6 6

TCNT1H7 - Timer/Counter1 High Byte bit 7

#define TCNT1H7 7

TCNT1L - Timer/Counter1 Low Byte

sfrb TCNT1L = $84;

TCNT1L0 - Timer/Counter1 Low Byte bit 0

#define TCNT1L0 0

TCNT1L1 - Timer/Counter1 Low Byte bit 1

#define TCNT1L1 1

TCNT1L2 - Timer/Counter1 Low Byte bit 2

#define TCNT1L2 2

TCNT1L3 - Timer/Counter1 Low Byte bit 3

#define TCNT1L3 3

TCNT1L4 - Timer/Counter1 Low Byte bit 4

#define TCNT1L4 4

TCNT1L5 - Timer/Counter1 Low Byte bit 5

#define TCNT1L5 5

TCNT1L6 - Timer/Counter1 Low Byte bit 6

#define TCNT1L6 6

TCNT1L7 - Timer/Counter1 Low Byte bit 7

#define TCNT1L7 7

OCR1AH - Timer/Counter1 Outbut Compare Register High Byte

sfrb OCR1AH = $89;

OCR1AH0 - Timer/Counter1 Outbut Compare Register High Byte bit 0

#define OCR1AH0 0

OCR1AH1 - Timer/Counter1 Outbut Compare Register High Byte bit 1

#define OCR1AH1 1

OCR1AH2 - Timer/Counter1 Outbut Compare Register High Byte bit 2

#define OCR1AH2 2

OCR1AH3 - Timer/Counter1 Outbut Compare Register High Byte bit 3

#define OCR1AH3 3

OCR1AH4 - Timer/Counter1 Outbut Compare Register High Byte bit 4

#define OCR1AH4 4

OCR1AH5 - Timer/Counter1 Outbut Compare Register High Byte bit 5

#define OCR1AH5 5

OCR1AH6 - Timer/Counter1 Outbut Compare Register High Byte bit 6

#define OCR1AH6 6

OCR1AH7 - Timer/Counter1 Outbut Compare Register High Byte bit 7

#define OCR1AH7 7

OCR1AL - Timer/Counter1 Outbut Compare Register Low Byte

sfrb OCR1AL = $88;

OCR1AL0 - Timer/Counter1 Outbut Compare Register Low Byte Bit 0

#define OCR1AL0 0

OCR1AL1 - Timer/Counter1 Outbut Compare Register Low Byte Bit 1

#define OCR1AL1 1

OCR1AL2 - Timer/Counter1 Outbut Compare Register Low Byte Bit 2

#define OCR1AL2 2

OCR1AL3 - Timer/Counter1 Outbut Compare Register Low Byte Bit 3

#define OCR1AL3 3

OCR1AL4 - Timer/Counter1 Outbut Compare Register Low Byte Bit 4

#define OCR1AL4 4

OCR1AL5 - Timer/Counter1 Outbut Compare Register Low Byte Bit 5

#define OCR1AL5 5

OCR1AL6 - Timer/Counter1 Outbut Compare Register Low Byte Bit 6

#define OCR1AL6 6

OCR1AL7 - Timer/Counter1 Outbut Compare Register Low Byte Bit 7

#define OCR1AL7 7

OCR1BH - Timer/Counter1 Output Compare Register High Byte

sfrb OCR1BH = $8B;

OCR1BH0 - Timer/Counter1 Output Compare Register High Byte bit 0

#define OCR1BH0 0

OCR1BH1 - Timer/Counter1 Output Compare Register High Byte bit 1

#define OCR1BH1 1

OCR1BH2 - Timer/Counter1 Output Compare Register High Byte bit 2

#define OCR1BH2 2

OCR1BH3 - Timer/Counter1 Output Compare Register High Byte bit 3

#define OCR1BH3 3

OCR1BH4 - Timer/Counter1 Output Compare Register High Byte bit 4

#define OCR1BH4 4

OCR1BH5 - Timer/Counter1 Output Compare Register High Byte bit 5

#define OCR1BH5 5

OCR1BH6 - Timer/Counter1 Output Compare Register High Byte bit 6

#define OCR1BH6 6

OCR1BH7 - Timer/Counter1 Output Compare Register High Byte bit 7

#define OCR1BH7 7

OCR1BL - Timer/Counter1 Output Compare Register Low Byte

sfrb OCR1BL = $8A;

OCR1BL0 - Timer/Counter1 Output Compare Register Low Byte bit 0

#define OCR1BL0 0

OCR1BL1 - Timer/Counter1 Output Compare Register Low Byte bit 1

#define OCR1BL1 1

OCR1BL2 - Timer/Counter1 Output Compare Register Low Byte bit 2

#define OCR1BL2 2

OCR1BL3 - Timer/Counter1 Output Compare Register Low Byte bit 3

#define OCR1BL3 3

OCR1BL4 - Timer/Counter1 Output Compare Register Low Byte bit 4

#define OCR1BL4 4

OCR1BL5 - Timer/Counter1 Output Compare Register Low Byte bit 5

#define OCR1BL5 5

OCR1BL6 - Timer/Counter1 Output Compare Register Low Byte bit 6

#define OCR1BL6 6

OCR1BL7 - Timer/Counter1 Output Compare Register Low Byte bit 7

#define OCR1BL7 7

ICR1H - Timer/Counter1 Input Capture Register High Byte

sfrb ICR1H = $87;

ICR1H0 - Timer/Counter1 Input Capture Register High Byte bit 0

#define ICR1H0 0

ICR1H1 - Timer/Counter1 Input Capture Register High Byte bit 1

#define ICR1H1 1

ICR1H2 - Timer/Counter1 Input Capture Register High Byte bit 2

#define ICR1H2 2

ICR1H3 - Timer/Counter1 Input Capture Register High Byte bit 3

#define ICR1H3 3

ICR1H4 - Timer/Counter1 Input Capture Register High Byte bit 4

#define ICR1H4 4

ICR1H5 - Timer/Counter1 Input Capture Register High Byte bit 5

#define ICR1H5 5

ICR1H6 - Timer/Counter1 Input Capture Register High Byte bit 6

#define ICR1H6 6

ICR1H7 - Timer/Counter1 Input Capture Register High Byte bit 7

#define ICR1H7 7

ICR1L - Timer/Counter1 Input Capture Register Low Byte

sfrb ICR1L = $86;

ICR1L0 - Timer/Counter1 Input Capture Register Low Byte bit 0

#define ICR1L0 0

ICR1L1 - Timer/Counter1 Input Capture Register Low Byte bit 1

#define ICR1L1 1

ICR1L2 - Timer/Counter1 Input Capture Register Low Byte bit 2

#define ICR1L2 2

ICR1L3 - Timer/Counter1 Input Capture Register Low Byte bit 3

#define ICR1L3 3

ICR1L4 - Timer/Counter1 Input Capture Register Low Byte bit 4

#define ICR1L4 4

ICR1L5 - Timer/Counter1 Input Capture Register Low Byte bit 5

#define ICR1L5 5

ICR1L6 - Timer/Counter1 Input Capture Register Low Byte bit 6

#define ICR1L6 6

ICR1L7 - Timer/Counter1 Input Capture Register Low Byte bit 7

#define ICR1L7 7

GTCCR - General Timer/Counter Control Register

sfrb GTCCR = $23;

PSRSYNC - Prescaler Reset Timer/Counter1 and Timer/Counter0

#define PSRSYNC 0

When this bit is one, Timer/Counter1 and Timer/Counter0 prescaler will be Reset. This bit is normally cleared immediately by hardware, except if the TSM bit is set. Note that Timer/Counter1 and Timer/Counter0 share the same prescaler and a reset of this prescaler will affect both timers.

TSM - Timer/Counter Synchronization Mode

#define TSM 7

Writing the TSM bit to one activates the Timer/Counter Synchronization mode. In this mode, the value that is written to the PSR2 and PSR10 bits is kept, hence keeping the corresponding prescaler reset signals asserted. This ensures that the corresponding Timer/Counters are halted and can be configured to the same value without the risk of one of them advancing during configuration. When the TSM bit is written to zero, the PSR2 and PSR10 bits are cleared by hardware, and the Timer/Counters start counting simultaneous

AD CONVERTER

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 Noi

ADMUX - The ADC multiplexer Selection Register

sfrb ADMUX = $7C;

MUX0 - Analog Channel and Gain Selection Bits

#define MUX0 0

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).

MUX1 - Analog Channel and Gain Selection Bits

#define MUX1 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).

MUX2 - Analog Channel and Gain Selection Bits

#define MUX2 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).

MUX3 - Analog Channel and Gain Selection Bits

#define MUX3 3

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).

ADLAR - Left Adjust Result

#define ADLAR 5

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.

REFS0 - Reference Selection Bit 0

#define REFS0 6

These bits select the voltage reference for the ADC, as shown in Table 91. 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.

REFS1 - Reference Selection Bit 1

#define REFS1 7

These bits select the voltage reference for the ADC, as shown in Table 91. 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.

ADCSRA - The ADC Control and Status register

sfrb ADCSRA = $7A;

ADPS0 - ADC Prescaler Select Bits

#define ADPS0 0

These bits determine the division factor between the XTAL frequency and the input clock to the ADC.

ADPS1 - ADC Prescaler Select Bits

#define ADPS1 1

These bits determine the division factor between the XTAL frequency and the input clock to the ADC.

ADPS2 - ADC Prescaler Select Bits

#define ADPS2 2

These bits determine the division factor between the XTAL frequency and the input clock to the ADC.

ADIE - ADC Interrupt Enable

#define ADIE 3

When this bit is set (one) and the I-bit in SREG is set (one), the ADC Conversion Complete Interrupt is activated.

ADIF - ADC Interrupt Flag

#define ADIF 4

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.

ADATE - ADC Auto Trigger Enable

#define ADATE 5

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.

ADSC - ADC Start Conversion

#define ADSC 6

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

ADEN - ADC Enable

#define ADEN 7

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.

ADCH - ADC Data Register High Byte

sfrb ADCH = $79;

ADCH0 - ADC Data Register High Byte Bit 0

#define ADCH0 0

ADCH1 - ADC Data Register High Byte Bit 1

#define ADCH1 1

ADCH2 - ADC Data Register High Byte Bit 2

#define ADCH2 2

ADCH3 - ADC Data Register High Byte Bit 3

#define ADCH3 3

ADCH4 - ADC Data Register High Byte Bit 4

#define ADCH4 4

ADCH5 - ADC Data Register High Byte Bit 5

#define ADCH5 5

ADCH6 - ADC Data Register High Byte Bit 6

#define ADCH6 6

ADCH7 - ADC Data Register High Byte Bit 7

#define ADCH7 7

ADCL - ADC Data Register Low Byte

sfrb ADCL = $78;

ADCL0 - ADC Data Register Low Byte Bit 0

#define ADCL0 0

ADCL1 - ADC Data Register Low Byte Bit 1

#define ADCL1 1

ADCL2 - ADC Data Register Low Byte Bit 2

#define ADCL2 2

ADCL3 - ADC Data Register Low Byte Bit 3

#define ADCL3 3

ADCL4 - ADC Data Register Low Byte Bit 4

#define ADCL4 4

ADCL5 - ADC Data Register Low Byte Bit 5

#define ADCL5 5

ADCL6 - ADC Data Register Low Byte Bit 6

#define ADCL6 6

ADCL7 - ADC Data Register Low Byte Bit 7

#define ADCL7 7

ADCSRB - ADC Control and Status Register B

sfrb ADCSRB = $7B;

ADTS0 - ADC Auto Trigger Source 0

#define ADTS0 0

ADTS1 - ADC Auto Trigger Source 1

#define ADTS1 1

ADTS2 - ADC Auto Trigger Source 2

#define ADTS2 2

ADASCR

#define ADASCR 3

ADAP

#define ADAP 4

DIDR0 - Digital Input Disable Register 0

sfrb DIDR0 = $7E;

ADC0D - ADC0 Digital input Disable

#define ADC0D 0

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.

ADC1D - ADC1 Digital input Disable

#define ADC1D 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.

ADC2D - ADC2 Digital input Disable

#define ADC2D 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.

ADC3D - ADC3 Digital input Disable

#define ADC3D 3

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.

ADC4D - ADC4 Digital input Disable

#define ADC4D 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.

ADC5D - ADC5 Digital input Disable

#define ADC5D 5

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.

ADC6D - ADC6 Digital input Disable

#define ADC6D 6

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.

ADC7D - ADC7 Digital input Disable

#define ADC7D 7

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.

USART

UDR - USART I/O Data Register

sfrb UDR = 0xC6;

UDR0 - USART I/O Data Register bit 0

#define UDR0 0

UDR1 - USART I/O Data Register bit 1

#define UDR1 1

UDR2 - USART I/O Data Register bit 2

#define UDR2 2

UDR3 - USART I/O Data Register bit 3

#define UDR3 3

UDR4 - USART I/O Data Register bit 4

#define UDR4 4

UDR5 - USART I/O Data Register bit 5

#define UDR5 5

UDR6 - USART I/O Data Register bit 6

#define UDR6 6

UDR7 - USART I/O Data Register bit 7

#define UDR7 7

UCSRA - USART Control and Status register A

sfrb UCSRA = 0xC0;

MPCM - Multi-processor Communication Mode

#define MPCM 0

U2X - Double USART Transmission Bit

#define U2X 1

UPE - USART Parity Error

#define UPE 2

DOR - Data Overrun

#define DOR 3

FE - Framing Error

#define FE 4

UDRE - USART Data Register Empty

#define UDRE 5

TXC - USART Transmitt Complete

#define TXC 6

RXC - USART Receive Complete

#define RXC 7

UCSRB - USART Control an Status register B

sfrb UCSRB = 0xC1;

TXB8 - Transmit Data Bit 8

#define TXB8 0

RXB8 - Receive Data Bit 8

#define RXB8 1

UCSZ2 - Character Size

#define UCSZ2 2

TXEN - Transmitter Enable

#define TXEN 3

RXEN - Receiver Enable

#define RXEN 4

UDRIE - USART Data Register Empty Interrupt Enable

#define UDRIE 5

TXCIE - TX Complete Interrupt Enable

#define TXCIE 6

RXCIE - RX Complete Interrupt Enable

#define RXCIE 7

UCSRC - USART Control an Status register C

sfrb UCSRC = 0xC2;

UCPOL - Clock Polarity

#define UCPOL 0

UCSZ0 - Character Size Bit 0

#define UCSZ0 1

UCSZ1 - Character Size Bit 1

#define UCSZ1 2

USBS - Stop Bit Select

#define USBS 3

UPM0 - Parity Mode Bit 0

#define UPM0 4

UPM1 - Parity Mode Bit 1

#define UPM1 5

UMSEL0 - USART Mode Select

#define UMSEL0 6

UBRRH - USART Baud Rate Register High Byte

sfrb UBRRH = 0xC5;

UBRR8 - USART Baud Rate Register Bit 8

#define UBRR8 0

UBRR9 - USART Baud Rate Register Bit 9

#define UBRR9 1

UBRR10 - USART Baud Rate Register Bit 10

#define UBRR10 2

UBRR11 - USART Baud Rate Register Bit 11

#define UBRR11 3

UBRRL - USART Baud Rate Register Low Byte

sfrb UBRRL = 0xC4;

UBRR0 - USART Baud Rate Register bit 0

#define UBRR0 0

UBRR1 - USART Baud Rate Register bit 1

#define UBRR1 1

UBRR2 - USART Baud Rate Register bit 2

#define UBRR2 2

UBRR3 - USART Baud Rate Register bit 3

#define UBRR3 3

UBRR4 - USART Baud Rate Register bit 4

#define UBRR4 4

UBRR5 - USART Baud Rate Register bit 5

#define UBRR5 5

UBRR6 - USART Baud Rate Register bit 6

#define UBRR6 6

UBRR7 - USART Baud Rate Register bit 7

#define UBRR7 7

SPI

The Serial Peripheral Interface(SPI) allows high-speed synchronous data transfer between the AT90S4414/8515 and peripheral devices or between several AVR devices. The AT90S4414/8515 SPI features include the following: ? Full-duplex, 3-wire Synchronous Data Transfer ? Master or Slave Operation ? LSB First or MSB First Data Transfer ? Four Programmable Bit Rates ? End of Transmission Interrupt Flag ? Write Collision Flag Protection ? Wakeup from Idle Mode (Slave Mode Only)

SPCR - SPI Control Register

sfrb SPCR = $2C;

SPR0 - SPI Clock Rate Select 0

#define SPR0 0

These two bits control the SCK rate of the device configured as a master. SPR1 and SPR0 have no effect on the slave.

SPR1 - SPI Clock Rate Select 1

#define SPR1 1

These two bits control the SCK rate of the device configured as a master. SPR1 and SPR0 have no effect on the slave.

CPHA - Clock Phase

#define CPHA 2

Refer to Figure 36 or Figure 37 for the functionality of this bit.

CPOL - Clock polarity

#define CPOL 3

When this bit is set (one), SCK is high when idle. When CPOL is cleared (zero), SCK is low when idle. Refer to Figure 36 and Figure 37 for additional information.

MSTR - Master/Slave Select

#define MSTR 4

This bit selects Master SPI mode when set (one), and Slave SPI mode when cleared (zero). If SS is configured as an input and is driven low while MSTR is set, MSTR will be cleared, and SPIF in SPSR will become set. The user will then have to set MSTR to re-enable SPI master mode.

DORD - Data Order

#define DORD 5

When the DORD bit is set (one), the LSB of the data word is transmitted first. When the DORD bit is cleared (zero), the MSB of the data word is transmitted first.

SPE - SPI Enable

#define SPE 6

When the SPE bit is set (one), the SPI is enabled. This bit must be set to enable any SPI operations.

SPIE - SPI Interrupt Enable

#define SPIE 7

This bit causes the SPI interrupt to be executed if SPIF bit in the SPSR register is set and the global interrupts are enabled.

SPSR - SPI Status Register

sfrb SPSR = $2D;

SPI2X - Double SPI Speed Bit

#define SPI2X 0

When this bit is written logic one the SPI speed (SCK Frequency)will be doubled when the SPI is in master mode .This means that the minimum SCK period will be 2 CPU clock periods.When the SPI is configured as Slave,the SPI is only guaranteed to work at f osc /4orlower. The SPI interface on the ATmega162 is also used for program memory and EEPROM downloading or uploading.

WCOL - Write Collision Flag

#define WCOL 6

The WCOL bit is set if the SPI data register (SPDR) is written during a data transfer. The WCOL bit (and the SPIF bit) are cleared (zero) by first reading the SPI Status Register when WCOL is set (one), and then accessing the SPI Data Register.

SPIF - SPI Interrupt Flag

#define SPIF 7

When a serial transfer is complete, the SPIF bit is set (one) and an interrupt is generated if SPIE in SPCR is set (one) and global interrupts are enabled. If SS is an input and is driven low when the SPI is in master mode, this will also set the SPIF flag. SPIF is cleared by hardware when executing the corresponding interrupt handling vector. Alternatively, the SPIF bit is cleared by first reading the SPI status register when SPIF is set (one), then accessing the SPI Data Register (SPDR).

SPDR - SPI Data Register

sfrb SPDR = $2E;

SPDR0 - SPI Data Register bit 0

#define SPDR0 0

SPDR1 - SPI Data Register bit 1

#define SPDR1 1

SPDR2 - SPI Data Register bit 2

#define SPDR2 2

SPDR3 - SPI Data Register bit 3

#define SPDR3 3

SPDR4 - SPI Data Register bit 4

#define SPDR4 4

SPDR5 - SPI Data Register bit 5

#define SPDR5 5

SPDR6 - SPI Data Register bit 6

#define SPDR6 6

SPDR7 - SPI Data Register bit 7

#define SPDR7 7

WATCHDOG

WDTCSR - Watchdog Timer Control Register

sfrb WDTCSR = $60;

WDP0 - Watch Dog Timer Prescaler bit 0

#define WDP0 0

WDP1 - Watch Dog Timer Prescaler bit 1

#define WDP1 1

WDP2 - Watch Dog Timer Prescaler bit 2

#define WDP2 2

WDE - Watch Dog Enable

#define WDE 3

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

WDCE - Watchdog Change Enable

#define WDCE 4

WDP3 - Watchdog Timer Prescaler Bit 3

#define WDP3 5

WDIE - Watchdog Timeout Interrupt Enable

#define WDIE 6

WDIF - Watchdog Timeout Interrupt Flag

#define WDIF 7

EXTERNAL INTERRUPT

The external interrupts are triggered by the INT7:0 pins. Observe that, if enabled, the interrupts will trigger even if the INT7:0 pins are configured as outputs. This feature provides a way of generating a software interrupt. The external inter-rupts can be triggered by a falling or rising edge or a low level. This is set up as indicated in the specification for the Exter-nal Interrupt Control Registers - EICRA (INT3:0) and EICRB (INT7:4). When the external interrupt is enabled and is configured as level triggered, the interrupt will trigger as long as the pin is held low. Note that recognition of falling or rising edge interrupts on INT7:4 requires the presence of an I/O clock, described in ?Clock Systems and their Distribution? on page 29. Low level interrupts and the edge interrupt on INT3:0 are detected asynchronously. This implies that these inter-rupts can be used for waking the part also from sleep modes other than Idle mode. The I/O clock is halted in all sleep modes except Idle mode. Note that if a level triggered interrupt is used for wake-up from Power Down Mode, the changed level must be held for some time to wake up the MCU. This makes the MCU less sensitive to noise. The changed level is sampled twice by the watchdog oscillator clock. The period of the watchdog oscillator is 1 µs (nominal) at 5.0V and 25°C. The frequency of the watchdog oscillator is voltage dependent as shown in the Electrical Characteristics section. The MCU will wake up if the input has the required level during this sampling or if it is held until the end of the start-up time. The start-up time is defined by the SUT fuses as described in ?Clock Systems and their Distribution? on page 29. If the level is sampled twice by the watchdog oscillator clock but disappears before the end of the start-up time, the MCU will still wake up, but no interrupt will be generated. The required level must be held long enough for the MCU to complete the wake up to trigger the level interrupt

EICRA - External Interrupt Control Register A

sfrb EICRA = $69;

ISC00 - External Interrupt Sense Control Bit

#define ISC00 0

ISC01 - External Interrupt Sense Control Bit

#define ISC01 1

ISC10 - External Interrupt Sense Control Bit

#define ISC10 2

ISC11 - External Interrupt Sense Control Bit

#define ISC11 3

ISC20 - External Interrupt Sense Control Bit

#define ISC20 4

ISC21 - External Interrupt Sense Control Bit

#define ISC21 5

EIMSK - External Interrupt Mask Register

sfrb EIMSK = $1D;

INT0 - External Interrupt Request 0 Enable

#define INT0 0

INT1 - External Interrupt Request 1 Enable

#define INT1 1

INT2 - External Interrupt Request 2 Enable

#define INT2 2

EIFR - External Interrupt Flag Register

sfrb EIFR = $1C;

INTF0 - External Interrupt Flag 0

#define INTF0 0

INTF1 - External Interrupt Flag 1

#define INTF1 1

INTF2 - External Interrupt Flag 2

#define INTF2 2