martinkooij
Posts: 54
Joined: Sun Feb 28, 2021 5:22 pm
Location: The Netherlands

SOLVED: sleep_ms() on core1

Thu Apr 22, 2021 4:25 pm

Hi,

I want core 1 on standby to do an independent action every 100ms.

(Use case: core 1 will read a requested status on shared memory and then lights a led strand, possibly with nicely timed effects depending on the requested status. Core 0 will do all the (USB) user interaction and contain the main program and do all the calculations and just write a request into memory --- relying on core 1 to do all the lighting effects on the led-pixel-strand in the background depending on what was written in memory).

I have a question on sleep_ms() on core 1. Before I will debug myself to death, maybe some help from more experienced people would do the trick....

Does sleep_ms(100) on core 1 works without further ado?

When I tried to find out in the SDK documentation I read "These functions allow the calling core to sleep..." in the sleep() documentation, but also I read "Lower powered sleep requires use of the default alarm pool", and that one is only set on core 0 and not useable by core 1 (if I understand the documentation on alarm pools right). I am confused, but the question is simple. Does sleep_ms() works on core 1 without extras? In the mean time I will use busy_wait_ms() and pay for the extra power needed to the power line company ;).
Last edited by martinkooij on Fri Apr 23, 2021 9:47 am, edited 1 time in total.

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

Re: sleep_ms() on core1

Thu Apr 22, 2021 6:40 pm

sleep_ms should work on either core; the default alarm pool fires any interrupts on core 0 as that is where it is initialized, but that doesn't affect that functionality, just something you might care about in advanced cases.

martinkooij
Posts: 54
Joined: Sun Feb 28, 2021 5:22 pm
Location: The Netherlands

Re: sleep_ms() on core1

Thu Apr 22, 2021 7:46 pm

Clear, thanks!

Return to “SDK”