SAMD21 enable External IRQ causes USART to stop working

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

Hi All,

 

I was hoping someone could please help me.

 

I have a project using the SAMD21 and ASF4. The SAMD21 communicates to an external peripheral via USART.

 

I needed to add an External IRQ to listen for a button action. This IRQ also works.

 

The problem is when I added the IRQ to the project via Atmel start. The USART then fails on its first "io_write". If I disable the IRQ (uncomment from the driver_init.c file) the USART will start working again.

 

The both work stand alone but if I attempt to run both together (USART and IRQ) then the USART will always fail (as shown in attached callstack)

 

Would this be due to a clock configuraton? Im quite stuck on this issue for a few days now and am hoping someone could help even point me in the right direction.

 

Thank you in advance

Last Edited: Sun. May 8, 2022 - 10:19 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Call Stack wrote:

Dummy Handler

<Exception frame>

That's worthy of investigation. What's the exception and thrown at what line etc.

 

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

Hello and thank you for your response.

 

It seems when “_sercom_usart_interrupt_handler” within hpl_sercom.h is attempting to set:

 

device->usart_cb.tx_byte_sent(device);

 

it fails within the critical section of

 

static inline void hri_sercomusart_write_DATA_reg(const void *const hw, hri_sercomusart_data_reg_t data)

{

            SERCOM_CRITICAL_SECTION_ENTER();

            ((Sercom *)hw)->USART.DATA.reg = data;

            SERCOM_CRITICAL_SECTION_LEAVE();

}

 

I done two captures

  • one successful run with IRQ disabled
  • one unsuccessful run with IRQ enabled

 

 

Working(IRQ Disabled)

Non-Working (IRQ enabled)

 

I tried to capture the exception type but to no avail as the debugger just hangs after attempting to set above register = data.

 

I see that the dummy handler has the following error (if I have collected correctly)

 

As required " A generic clock (GCLK_EIC) is required to clock the peripheral. This clock must be configured and enabled in the Generic Clock Controller before using the peripheral. This generic clock is asynchronous to the user interface clock (CLK_EIC_APB). Due to this asynchronicity, writes to certain registers will require synchronization between the clock domains." - https://microchipdeveloper.com/3...

 

I configured where they are all on generic glock 0 derived from 8Mhz Internal Oscillator

 

 

 

 

 

Many thanks for your time

Last Edited: Sun. May 8, 2022 - 05:16 PM