SAM4L8 XPlained Pro USART2 not working

Go To Last Post
2 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi all

I'm using the SAM4L XPlained pro board and I'm trying to get the UART2 to work. I have been successful at getting UART0 and UART1 to work just fine but not UART2. Not sure what it is I'm missing. Here are the code snippets I'm using to enable the UART2.

 

conf_board.h:

#ifndef CONF_BOARD_H_INCLUDED
#define CONF_BOARD_H_INCLUDED

/** Enable Com Port. */
#define CONF_BOARD_COM_PORT
#define CONF_BOARD_USART0
#define CONF_BOARD_EIC
#endif

 

main.c:

    const sam_usart_opt_t usart_console_settings = {
        baud,
        USART2_SERIAL_CHAR_LENGTH,
        USART2_SERIAL_PARITY,
        USART2_SERIAL_STOP_BIT,
        US_MR_CHMODE_NORMAL
    };
    
    #if SAM4L
    sysclk_enable_peripheral_clock(USART2_SERIAL);
    #else
    sysclk_enable_peripheral_clock(USART2_SERIAL_ID);
    #endif
    usart_init_rs232(USART2_SERIAL, &usart_console_settings,
    sysclk_get_main_hz());
    usart_enable_tx(USART2_SERIAL);
    usart_enable_rx(USART2_SERIAL);

 

usart_enable_interrupt(USART2, US_IER_RXRDY); 
NVIC_EnableIRQ(USART2_IRQn);

 

 

Any help is greatly appreciated,

 

Thanks

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

To get UART2 on header EXT3 add these lines of code:

	ioport_set_pin_peripheral_mode(EXT3_PIN_UART_RX, EXT3_UART_RX_MUX);
	ioport_set_pin_peripheral_mode(EXT3_PIN_UART_TX, EXT3_UART_TX_MUX);

To get UART2 on header EXT4 add these lines of code:

	ioport_set_pin_peripheral_mode(EXT4_PIN_UART_RX, EXT4_UART_RX_MUX);
	ioport_set_pin_peripheral_mode(EXT4_PIN_UART_TX, EXT4_UART_TX_MUX);