IRQ, ISR and Mutex problems

Hi. I’m trying to use a Max11040K ADC with an IRQ data output with LPC1768, but am having problems.

Issue is, whenever I enable the ISR (to read the falling edge of the ADC’s data output ready signal), the ISR says I cannot use the ADC’s IRQ within the ISR because of mutex. But, I’m kinda stuck with both LPC1768 and MAX11040K. I’ve been trying to get a workaround that’ll let me get 2k samples per second, but to no avail. Can anyone help? I can post the code snippets if needed.

Hello,

about mutex you can do this

  • in the interrupt context just set a flag and make process in the main loop
  • use EventQueue and take it out of interrupt contex
  • if you don’t need RTOS features, then you can try - bare metal profile (No RTOS = no Mutex = no exceptions)

BR, Jan

Hi! Thanks for the answer. I used the flag trick, both with normal flags and EventFlags, but they kinda got too slow or were unstable. I wasn’t successful at using EventQueue,

I’ll try Bare Metal though, thanks!

I’m open to any other suggestions while I try this.

UPDATE: Sadly after some research I figured out I can’t use Bare Metal, I need to have an ethernet interface. Since NetworkInterface is not supported by Bare Metal, I can’t use it. Any help or pseudocodes would be appreciated.

First example on EventQueue page is what I meant.
But maybe you also need set nontrivial callbacks for that in mbed_app.json file.

{
    "target_overrides": {
        "*": {
            "platform.callback-nontrivial": true
        }
    }
}

BR, Jan