Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 21:24 12 Jul 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : PAUSE or CPU SLEEP ...

Author Message
Taipan
Newbie

Joined: 02/01/2025
Location: Australia
Posts: 8
Posted: 04:13am 04 Jan 2025
Copy link to clipboard 
Print this post

I am confused about the use of PAUSE and CPU SLEEP as they each seem to achieve the same/similar result.

Reading "between the lines" it looks like interrupts will be recognised during a PAUSE, but not during a CPU SLEEP?  Is that correct?

But, given that "the CPU does not have a true low power sleep so the power saving is limited", then I wonder at the point of CPU SLEEP.
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2611
Posted: 07:26am 04 Jan 2025
Copy link to clipboard 
Print this post

  Quote   I wonder at the point of CPU SLEEP.
The Pico is a recent addition to the MMBasic supported range of chips.
The PIC32MX chips for example do have proper sleep modes. To maximize portability of code that command has been retained.
Edited 2025-01-04 17:27 by phil99
 
Taipan
Newbie

Joined: 02/01/2025
Location: Australia
Posts: 8
Posted: 08:27pm 04 Jan 2025
Copy link to clipboard 
Print this post

  phil99 said  To maximize portability of code that command has been retained.

So, for a Raspberry Pi Pico W, I should just use PAUSE as the Pico W does not have true low power sleep?

And, interrupts will not be recognised during a CPU SLEEP?
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 7870
Posted: 08:58pm 04 Jan 2025
Copy link to clipboard 
Print this post

You aren't the only one that's confused!

PAUSE n waits for n milliseconds. During this time interrupts are still processed.

The RP2040 has a condition called SLEEP:
  Quote  RP2040 enters the SLEEP state when all of the following are true:
• Both processors are asleep (e.g. in a WFE or WFI instruction)
• The system DMA has no outstanding transfers on any channel
RP2040 exits the SLEEP state when either processor is awoken by an interrupt.

The manual states that both processors are put into a sleep state for n seconds, So I think it may be that no *normal* interrupts will be processed by MMBasic during this time, but internal interrupts may still wake one or both processors which will then sleep again. MMBasic needs things doing regularly.
.
Edited 2025-01-05 07:02 by Mixtel90
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2611
Posted: 09:02pm 04 Jan 2025
Copy link to clipboard 
Print this post

Your assumption is correct, this test program shows a Tick interrupt won't wake a Pico.
Dim integer n

Sub wake
 Inc n
 Print "wake",n,Timer
End Sub

SetTick 2000, wake, 1

Timer = 0

Do
 CPU sleep 5
 Print "woken",n
Loop
And the output
wake     1       5000.185
woken    1
wake     2       10000.499
woken    2
wake     3       15000.788
woken    3
wake     4       20001.047

but if 'CPU Sleep 5' is replaced with 'Pause 5000' it does get interrupted.
Edited 2025-01-05 07:12 by phil99
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025