usart_async_register_callback() hangs

1 post / 0 new
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


Thanks. I'm working with a atsamD20E15 and my code hangs at the usart_async_register_callback() function. This code is most generated from atmel start.


I have traced this 

hri_sercomusart_write_INTEN_DRE_bit()  - where it assigns((Sercom *)hw)->USART.INTENSET.reg = SERCOM_USART_INTENSET_DR

and then to an infinite loop in Dummy_Handler().

hw is 0 here and that doesn't seems right. Of course you can't make an assignment to a null pointer.

USART_1->device->hw = 0x42001000 at usart_async_register_callback.

But &descr->device->hw is 0. 


I suspect hw not getting set is the problem but can't figure why. Like I'm missing a step but I can't see it. Now io_write() works, the code only started to fail when I add the callback functions. It seems that descr->device->hw is not set when  usart_async_register_callback() is called.


/***********************main **********************************************/
int main(void)
	/* Initializes MCU, drivers and middleware */

	usart_async_register_callback(&USART_1, USART_ASYNC_TXC_CB, tx_cb_UART_1_COM);
	usart_async_register_callback(&USART_1, USART_ASYNC_RXC_CB, rx_cb_UART_1_COM);
	usart_async_register_callback(&USART_1, USART_ASYNC_ERROR_CB, err_cb);
	usart_sync_get_io_descriptor(&USART_1, &io1);

	while (1) {

		io_write(io1, (uint8_t *)"Hello World!\r\n", 14);


/**************This is to causes the hang. hw is equal to 0 here.
static inline void hri_sercomusart_write_INTEN_DRE_bit(const void *const hw, bool value)
	if (value == 0x0) {
	} else {
/*******where it fails*****************************/
 * \brief Default interrupt handler for unused IRQs.

void Dummy_Handler(void)
        while (1) {


Stay Calm and Listen to the Grateful Dead