mike603
Posts: 7
Joined: Fri Jan 17, 2020 2:06 pm

Pico Multi Core and Interrupts

Mon Jun 21, 2021 6:51 pm

Please forgive me if this belongs in another forum. (Cross-posted in the C/C++ forum)

When using interrupts when both cores are active. Which core actually processes the interrupt?

Is there a way in the SDK to assign an interrupt to a specific core?

kilograham
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 742
Joined: Fri Apr 12, 2019 11:00 am
Location: austin tx

Re: Pico Multi Core and Interrupts

Mon Jun 21, 2021 8:13 pm

it occurs on whichever core you enabled it from (e.g. via irq_set_enabled)

Code: Select all

/*! \brief Enable or disable a specific interrupt on the executing core
 *  \ingroup hardware_irq
 *
 * \param num Interrupt number \ref interrupt_nums
 * \param enabled true to enable the interrupt, false to disable
 */
void irq_set_enabled(uint num, bool enabled);
You should generally not enable the same interrupt on both cores

mike603
Posts: 7
Joined: Fri Jan 17, 2020 2:06 pm

Re: Pico Multi Core and Interrupts

Mon Jun 21, 2021 9:19 pm

That is perfect. Thank you.

Are there re-entrant versions of the hardware drivers (like I2C or UART) or do I have to write my own mutex wrappers?

kilograham
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 742
Joined: Fri Apr 12, 2019 11:00 am
Location: austin tx

Re: Pico Multi Core and Interrupts

Mon Jun 21, 2021 11:16 pm

yeah most of the "drivers' are thin wrappers/syntatic sugar around register writes, so you need to protect that yourself if necessary (although pico_sync has mutexes etc. for you)

higher level printf aand stdio etc. are protected for you

mike603
Posts: 7
Joined: Fri Jan 17, 2020 2:06 pm

Re: Pico Multi Core and Interrupts

Tue Jun 22, 2021 12:57 am

Thank you. I read thought a large portion of the data sheet today so I'm ready to try some dual core stuff.

I almost never use printf/sprintf/scanf in embedded code. They are total pigs from a ram/rom and speed standpoint. I wrote my own string formatted output routines.

Thank you

Return to “SDK”