ASF4 IRQ and SPI on SAMC21

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

Hi, I am using a SAMc21 and a ADC ADS1263.

An IRQ is generated by ADC by setting pin to 0 when data are ready on ADC side.

This is an input for MCU (PA24 in my design). The communication between ADC et SAMC21 is SPI (1Mhz).

 

With the following code it works:

 

IRQ_callback{

    dataready_flag = true;

}

 

main{

   while(1){

      if (dataready_flag){

         read_data_via_spi();

      }

   }

}

 

At the opposite by moving the function read_data_via_spi() in the interrupt, the SPI get stuck (busy all the time):

 

IRQ_callback{

   read_data_via_spi();

}

 

main{

   while(1){

      }

}

 

I used the same function and the SPI is no more working when it is called from IRQ. The EIC and SPI share the same clock (clock generator 0 @24Mhz).

I do not figure out what is the issue.

 

Any though about the issue?

Thanks

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

Hi,

 

maybe you have to clear the interupt flag inside the interrupt routine.

Surprise: As soon as one's doing it correctly - it works!