Author Topic: External Interrupt Callback function  (Read 1974 times)

0 Members and 1 Guest are viewing this topic.

Offline sangarTopic starter

  • Regular Contributor
  • *
  • Posts: 125
  • Country: in
External Interrupt Callback function
« on: June 13, 2017, 12:43:18 pm »
Hello,

I am working on Project which have ADC to measure temperature. As my project is time critical,I am using ADC interrupt to read samples from ADC. For example, if I set ADC to 50 samples/sec, ADC will interrupt MCU for every 20ms(1/50) via a pin to read sample from DATA register. I want to read it in ISR callback function itself instead rising flag in ISR and read  sample from main if flag is true. ADC have SPI interface to MCU.



Thanks,
Sangar
 

Offline alexanderbrevig

  • Frequent Contributor
  • **
  • Posts: 700
  • Country: no
  • Musician, developer and EE hobbyist
    • alexanderbrevig.com
Re: External Interrupt Callback function
« Reply #1 on: June 13, 2017, 12:48:42 pm »
You may want to, but you should not. What of SPI hangs and waits for a timeout or some such.
Btw actual adc and mcu will help us answer the question I'm guessing will come :)
 

Offline sangarTopic starter

  • Regular Contributor
  • *
  • Posts: 125
  • Country: in
Re: External Interrupt Callback function
« Reply #2 on: June 13, 2017, 12:53:45 pm »
Hi,
Thanks. I am using AD7124-8 from Analog devices and SAML21J18B from ATMEL.




Thanks,
Sangar
« Last Edit: June 13, 2017, 01:00:29 pm by sangar »
 

Offline voltsandjolts

  • Supporter
  • ****
  • Posts: 2359
  • Country: gb
Re: External Interrupt Callback function
« Reply #3 on: June 13, 2017, 01:52:53 pm »
You should not wait in the interrupt for the transfers from ADC.
Do something like:

ADC sample ready > Ext Interrupt - start ADC read sample (SPI or whatever), Disable Ext Interrupt then return from interrupt

SPI Interrupt > Receive byte from ADC

SPI Interrupt > Receive byte from ADC

SPI Interrupt > Receive byte from ADC - transfer complete, restart ADC, Enable Ext Interrupt
« Last Edit: June 13, 2017, 01:55:08 pm by voltsandjolts »
 

Offline sangarTopic starter

  • Regular Contributor
  • *
  • Posts: 125
  • Country: in
Re: External Interrupt Callback function
« Reply #4 on: June 13, 2017, 05:45:17 pm »
Hi,


Our actual project is acquiring samples from ADC and send it over RF module. I want to make this system as interrupt driven machine because it is very time critical. It means that both ADC and RF module will uses external interrupt to MCU. For example, Acquiring ADC samples in FIFO in ADC handler function as you said and handling this FIFO to RF MODULE handler function to send over air. Is it possible?.If so, what cares should I take when work  between handler functions?




Thanks,
Sangar

 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf