usart_async_register_callback() hangs

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

Hi,

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 

_usart_async_set_irq_state(),
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 */
	atmel_start_init();

	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);
	usart_sync_enable(&USART_1);

	while (1) {

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

 

/**************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) {
		((Sercom *)hw)->USART.INTENCLR.reg = SERCOM_USART_INTENSET_DRE;
	} else {
		((Sercom *)hw)->USART.INTENSET.reg = SERCOM_USART_INTENSET_DRE;
	}
}
/*******where it fails*****************************/
/**
 * \brief Default interrupt handler for unused IRQs.
 */

void Dummy_Handler(void)
{
        while (1) {
        }
}

 

Stay Calm and Listen to the Grateful Dead

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

Hi, I'm new to this Forum and to SAMD, I'm facing the same problem with SAMD20J18 Board and by debugging my project, I find out that the rx_callback function, I implemented, is not triggered which mean that the interrupt does not occur. I also find out that UART4->device->hw is pointing to the right device but I can't watch it's registers.

TonyS wrote:
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.

Is there anyone who can fix this problem.

 

UART4 live watch