5.4.1 Addressing Registers from Header Files

In order to address registers in the supplied C header files, the following rules apply:

  1. A register is identified by <peripheral_instance_name>.<register_name>, e.g., CPU.SREG, USART2.CTRLA, or PORTB.DIR.
  2. The peripheral name is given in the “Peripheral Address Map” in the “Peripherals and Architecture” section.
  3. <peripheral_instance_name> is obtained by substituting any n or x in the peripheral name with the correct instance identifier.
  4. When assigning a predefined value to a peripheral register, the value is constructed following the rule:

    <peripheral_name>_<bit_field_name>_<bit_field_value>_gc

    <peripheral_name> is <peripheral_instance_name>, but remove any instance identifier.

    <bit_field_value> can be found in the “Name” column in the tables in the Register Description sections describing the bit fields of the peripheral registers.

Register Assignments

// EVSYS channel 0 is driven by TCB3 OVF event
EVSYS.CHANNEL0 = EVSYS_CHANNEL0_TCB3_OVF_gc;

// USART0 RXMODE uses Double Transmission Speed
USART0.CTRLB = USART_RXMODE_CLK2X_gc;
Note: For peripherals with different register sets in different modes, <peripheral_instance_name> and <peripheral_name> must be followed by a mode name, for example:
// TCA0 in Normal Mode (SINGLE) uses waveform generator in frequency mode 
TCA0.SINGLE.CTRL=TCA_SINGLE_WGMODE_FRQ_gc;