Shop OBEX P1 Docs P2 Docs Learn Events
WAITPNE running at RCSLOW — Parallax Forums

WAITPNE running at RCSLOW

Mag748Mag748 Posts: 269
edited 2012-04-23 19:51 in Propeller 1
Hello,

I have a project that requires low power consumption, as well as being always on and ready to spring to action.

I have figured out that I must have the prop running at all times as the boot up period is too long.

Currently, I have the prop go into RCFAST and then run a WAITPNE command until a user presses a button, at which point the prop uses the CLOCK object to speed up to XTAL + PLL mode.. The prop consumes about 740uA during the waitpne command. This is still a little high for my runtime requirements.

When I try switching to RCSLOW during the WAITPNE command, the consumption goes down to 20uA! (very good!) Unfortunately, there is an issue running at this slow speed. The prop does not recognize the button being pressed until many hundreds of milliseconds after the fact, at which point the prop speeds up and does its task.

Is this delay due to the extremely slow clock cycle as well as the many commands that must be executed in order to switch to the high clock freq?

Is there any way to obtain the 20uA power consumption while reducing the time the prop comes back to life?

I have attached the code I am using for this test for your reference.

Sincerely,
Marcus.

RCSlowTest.spin

P.S. My current measurements are taken from a 6V supply before being regulated to 3.3V with the Microchip MCP1702.

Comments

  • pjvpjv Posts: 1,903
    edited 2012-04-23 12:08
    Hi Mag748

    I too have very low power requirements. Typically I can get the prop's consumption down to about 10 uA, with a single cog running and in one of the WAIT states. To get down to that level, it is also important to have all your I/O settings properly dealt with, and none of them floating.

    I suspect you are operating a Spin program, and, while the change on the pin is immediately acted on, the Spin interpreter takes many cycles to execute its functions. I believe you will find the assembly approach much more responsive to switching back to the higher speed oscillator.

    Cheers,

    Peter (pjv)
  • pedwardpedward Posts: 1,642
    edited 2012-04-23 12:23
    If you can afford the COG space, I highly recommend using a COG running PASM for this purpose. The procedure for adjusting the clock is fairly simple and can be implemented in PASM easily.
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2012-04-23 14:31
    If you are going to do this in Spin, the instruction immediately after the waitpne should be a clockset to run on RCfast. No calling other objects--cut out any and all fancy stuff. The delay will then be imperceptible where buttons are concerned.
    [FONT=courier new][SIZE=1]  clkset(%0_00_00_001, 20_000)  ' drop to RCSLOW at  ~20 KHz
    [/SIZE][/FONT][FONT=courier new][SIZE=1]  waitpne(0, |<myPin, 0] ' wait for myPin=0
      clkset(0_00_00_000, 12_000_000)   ' operating on RCfast at ~12MHz[/SIZE][/FONT]
    
    The switchover to operate on RCfast can also turn on the xtal oscillator, so that the program can change over a few milliseconds later again to an accurate timing mode if need be.
  • KyeKye Posts: 2,200
    edited 2012-04-23 19:51
    Here's what I use for example:
      _SERIAL_TX_PIN = 30 ' Asynchronous serial bus pins.
      _SERIAL_RX_PIN = 31 '
    
      _PROPELLER_PORT_A = 0 ' Propeller chip port references.
      _PROPELLER_PORT_B = 1 '
    
      _CLKSEL_MASK = (%111 << 0) ' Propeller chip clock register masks.
      _OSCM_MASK = (%11 << 3) '
      _OSCENA_MASK = (%1 << 5) '
      _PLLENA_MASK = (%1 << 6) '
      _RESET_MASK = (%1 << 7) '
      
      _PLL_OSC_OSCM_MASK = (_PLLENA_MASK | _OSCENA_MASK | _OSCM_MASK) ' Combined mask for setup.
    
      _RC_SLOW_FREQUENCY = 20_000 ' Propeller chip RC frequencies.
      _RC_FAST_FREQUENCY = 12_000_000 '
    
      _PLL_STABILIZE_TIME = 10_000 ' Resolves into (clkfreq / timeout) seconds of timeout.  
      _OSC_STABILIZE_TIME = 100 '
    
    
        clkmodeBuffer := clkmode ' Backup clock mode.
        clkfreqBuffer := clkfreq ' Backup clock frequency.
    
        clkset(_RC_SLOW_MODE, _RC_SLOW_FREQUENCY) ' Switch to very low power mode.
    
        waitpeq(0, constant(|<_SERIAL_RX_PIN), _PROPELLER_PORT_A) ' Wait for serial low.
        waitpne(0, constant(|<_SERIAL_RX_PIN), _PROPELLER_PORT_A) ' Wait for serial high. 
    
        clkset((clkmodeBuffer & _PLL_OSC_OSCM_MASK), _RC_FAST_FREQUENCY) ' Setup PLL and OSC circuits.  
        waitcnt((clkfreq / _OSC_STABILIZE_TIME) + cnt) ' Wait for PLL and OSC to stabilize.
    
        clkset(clkmodeBuffer, clkfreqBuffer) ' Switch clock mode and clock frequency.
    
    
Sign In or Register to comment.