title: Atmel SAM4S Xplained UART
body: <p>I've a SAM4s Xplained and want to use the UART1 but can't find a example or help. I tried on my own but it doesn't work.</p>
  
  <p>Here is my code so far:</p>
  
  <p><strong>conf_uart.h</strong></p>
  
  <pre><code>#include "asf.h" //uart.h etc. included here
  #include &lt;sam4s_xplained.h&gt;
  
  #define UART_SERIAL_BAUDRATE        9600
  #define UART_SERIAL_CHANNEL_MODE   UART_MR_CHMODE_AUTOMATIC //UART_MR_CHMODE_NORMAL
  #define UART_SERIAL_MCK            240000000UL //CHIP_FREQ_CPU_MAX (tired both!)
  #define UART_SERIAL_MODE         UART_MR_PAR_NO
  
  void uart_custom_init(void);
  </code></pre>
  
  <p><strong>conf_uart.c</strong></p>
  
  <pre><code>#include "conf_uart.h"
  
  uint8_t received_byte;
  
  void uart_custom_init(void) {
      sysclk_init();
  
      const sam_uart_opt_t uart_console_settings = {
         UART_SERIAL_BAUDRATE,
         UART_SERIAL_CHANNEL_MODE,
         UART_SERIAL_MCK,
         UART_SERIAL_MODE
      };
  
      uart_init(UART1,&amp;uart_console_settings);      //Init UART1
  
      uart_enable_rx(UART1);                     //Enable RX (receiving)
      uart_enable_tx(UART1);                     //Enable TX (transmitting)
      uart_enable(UART1);                     //Enable UART1
  
      uart_enable_interrupt(UART1,UART_IER_RXRDY);   //Interrupt reading ready
      NVIC_EnableIRQ(UART1_IRQn);
  
  }
  
  void UART1_Handler() {
     uint32_t dw_status = uart_get_status(UART1);
  
     if(dw_status &amp; UART_SR_RXRDY) {
        uint8_t received_byte;
        uart_read(UART1, &amp;received_byte);
        uart_write(UART1, received_byte);
     }
  }
  </code></pre>
  
  <p>I tried different things. As Example I activated the automatic echo, but I don't recieve anything on my Computer and I don't receive anything at my SAM4s.</p>