SparkFun Forums 

Where electronics enthusiasts find answers.

Topics pertaining to the Arduino Core & software used with the Artemis module and Artemis development boards.
User avatar
By jugglerY2K
#207491
I need some help finding the pin mapping for interrupts on the Artemis ATP. It appears from the non-sequential pin labels on the Artemis boards (e.g not D0-D13 like a Mega) that these trace directly to the Apollo3 pads -- true?

I looked at the summary pinout you provided here, but it does not indicate the interrupt locations. https://cdn.sparkfun.com/assets/8/2/3/3 ... apping.pdf

I also searched through the full Apollo3 Blue data sheet, but could not decode interupt-t-pin/pad map from there.
https://ambiqmicro.com/static/mcu/files ... 349yoT.pdf

I'd appreciate some help. Thanks!
User avatar
By liquid.soulder
#207509
Your intuition is good - indeed the numbers on the ATP correspond to Apollo3 pads. As for interrupt mapping... the Apollo3 is interrupt capable on all its GPIO. Are you trying to use interrupts in Arduino or in the AmbiqSuite SDK?

In Arduino it is as simple as
Code: Select all
attachInterrupt(digitalPinToInterrupt( pin, isr, mode);
attachInterruptArg(digitalPinToInterrupt( pin, isrArg, arg, mode);
(isr is a function with signature void void, isrArg has a signature void void* and arg is a void* pointer that gets passed to isrArg when it is called)

In the SDK you will need to perform these steps:
- ensure that the pin configuration has interrupts enabled
- enable GPIO peripheral interrupts in the NVIC
- enable master interrupts

I guess that's all to say that there is no interrupt mapping like there may be on other microcontrollers - all GPIO interrupts get routed to
Code: Select all
void am_gpio_isr(void)
at which point you can determine which flags are set by
Code: Select all
    uint64_t gpio_int_mask = 0x00;
    am_hal_gpio_interrupt_status_get(true, &gpio_int_mask);
and clear flags once they are handled with
Code: Select all
am_hal_gpio_interrupt_clear(AM_HAL_GPIO_BIT(gpio_int_mask );
Does that help answer your question?
User avatar
By jugglerY2K
#207537
Great - thanks! That's the answer I was hoping for.

In the past, there have boards (different vendor) that said "any GPIO can be an interrupt" but then under the hood several pins share the same underlying IRQ, many multiple pins trip the same interrupt... This took a long time to determine and in the meantime led to much insanity.

I'm just using vanilla Arduino to code this, BTW. Thanks for the code snippets.
User avatar
By jugglerY2K
#207557
Hmm... looking further at the full Apollo3 data sheet, I'm confused again.

It seems to indicate 32 interrupts (see snipped below). But you mentioned that all 48 GPIO pins can be used as interrupts. That doesn't seem to agree. Or, perhaps I poorly worded what I want. I'll try again: What pins on the Artemis ATP can I utilize to get 20 unique (independent) interrupts? I plan to use with 10 hall-effect encoders, each of which require 2 interrupt channels.

From the Apollo3 datasheet (https://cdn.sparkfun.com/assets/learn_t ... v0_9_1.pdf):
"High-performance ARM Cortex-M4 Processor
- 48 MHz nominal clock frequency, with 96 MHz high performance “TurboSPOT” Burst Mode
- Floating point unit
- Memory protection unit
- Wake-up interrupt controller with 32 interrupts"