SAM4S Xplained Pro UART and USART (examples with Interrupts)

Posted By on Jun 18, 2016 | 2 comments

Recently I was in need to get two separate UARTS from the SAM4S Xpro board. It took me a while, but I finally figured out how to use the USART1 with interrupts; and since I already had working code for UART1, I decided to post examples for both.



UART1 is exposed in pins 13 and 14 in EXT3, and also in the Debug USB port. It requires the UART – Univ. Async Rec/Trans (driver) ASF module. For this example I’m using the code from here, without any modification.



USART1 is exposed in pins 13 and 14 in EXT1 and EXT2. It requires the USART – Univ. Synch Async Rec/Trans (driver) ASF module. Other modules that may be using it must be removed, or else you get a USART1_Handler redefined error. Most of the code for this example is from the ASF documentation, but it was missing  a configuration step of USART1 pins. Also it had what it seemed to be a mistake; in the call to usart_init_rs232, I replaced sysclk_get_main_hz() for sysclk_get_peripheral_hz(), and that fixed it. The working code is in the downloads.





UART1 Example


USART1 Example



  1. thanks it helpful for beginners

    Post a Reply


  1. Xbee MAC Interface SAM4S | Embedded Networks - […] Pro, you could use the pins labeled Rx, Tx, Gnd, and VTG in the IO1 board (Not sure why?…

Submit a Comment

Your email address will not be published. Required fields are marked *