Using an interruption whit the SERCOM USART module

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

Hello everyone
I'm been using an atsaml10e16a for a while now, but I cannot get the grip on everything just yet
I have a simple question, I'm using an atsaml10e16a, microchip studio for debugging and I'm using the Lite:USART:USART_Async driver (I'm not using the HAL:Driver:USART_Async because it has gave me problems in the past), I would like to trigger and interruption when the reception begin (this is done by setting the RXS bit on the INTSET register to one), and then execute a simple function to wait for all the bytes to be received and the read them.
I know that I can set the RXS bit whit a hri_sercomusart function, but how I define which function will be called on the interruption, in the case that i cannot decide which function will be called, where is the function called?
Any help would be really helpful!
 

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

For anyone wondering I managed to solve this:

Microchip already has pre-defined pointers to the interrupts handlers (in my case in the startup_saml10e16a.c file), so I just needed to define in my main (or in another file) the interrupt handler whit the Interruption routine, in my case it was the SERCOM1_2_Handler  function, and it ended looking something like:

void SERCOM1_2_Handler(void)
{
	//interrupt routine here

}

But that wasn't enough, I also has to do some stuff whit the NVIC, so I made a project whit the  HAL:Driver:USART_Async driver and I studied how it managed the interruptions, then I just copy the function that I needed and I made a very little library (just 3 functions) whit those.
finally I just had to make a code like:

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

	config_USART_INT(SERCOM1); //Function from the library that I made

	while (1) {

	}
}

void SERCOM1_2_Handler(void)
{
	//interrupt routine here
}

the SERCOM1 pointer is defined in saml10e16a.h, and that's all! (don't forget to set to one the bytes in the  INTSET register)
I will upload the "library" that I made if anyone want to use it even tho is very very simple and short.

 

Attachment(s): 

Last Edited: Fri. Sep 23, 2022 - 05:24 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


Note that Cortex-M0+ parts (SAMD) have fewer interrupts, so there is only one interrupt per SERCOM (instead of 4), so you have to do further decoding yourself.

 

The breakout is a bit tough to figure out;  See section 11.2.2 "Interrupt Line Mapping" to see which bits map to which interrupts:

And then the individual sections of the SERCOM description to see what each bit actually means (eg for UART):

 

 

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

Yes!!

thanks for complementing my answer