Hot answers tagged

12

Put it inside a critical section. ISRs won't run, so you don't run the risk of dont_sleep changing before WFI, but they will still wake the processor and the ISRs will execute as soon as the critical section ends. uint8 interruptStatus; interruptStatus = EnterCriticalSection(); if (!dont_sleep) WFI(); ExitCriticalSection(interruptStatus); Your ...


11

I don't know the details of this ST part, so I'll assume your description of it is correct. The processor should wake up very soon after either button is pressed. This should be especially true if it has a internal RC oscillator. Even if you need to run from a crystal eventually for accuracy reasons, perhaps you can have the part start from a internal RC, ...


9

There is usually some kind of hardware support for this case. E.g., the AVRs' sei instruction to enable interrupts defers enabling until the following instruction is complete. With it one can do: forever, interrupts off; if has_flag, interrupts on; process interrupt; else, interrupts-on-and-sleep; # won't be interrupted end ...


9

No, there is no such parameter. At most there will be off state current, ususally called "leakage current" or "cutoff current". The power has to do with applied voltage, which only you can know. However, the leakage currents of normal transistors are so low as to be irrlevant in virtually all cases. If the issue is switching 1 A LED lights on and off, ...


7

I can't put code in a comment, hence an answer. My 'framework' for simple embedded systems is the main loop with polling. To minimize current consumption the main loop can wait let's say 50 ms in idle mode. I don't know which uC you use, I am familiar with PICs, which can awake from a sleep by an interrupt. set up an interrupt to wake me from sleep each 50 ...


7

You have a small typo ;-) OPTION_REGbits.PS = 0x110; //postscaler 1:64 Should be: OPTION_REGbits.PS = 0b110; //postscaler 1:64 ^ | By setting to 0x110, you effectively chose a 1:1 prescaler, which meant that the watchdog would wake every 18ms by default.


7

Check if the SLEEPONEXIT bit in SCB->SCR is set. Setting that to 1 would cause exactly what you've described: Bit 1 SLEEPONEXIT Configures sleep-on-exit when returning from Handler mode to Thread mode. Setting this bit to 1 enables an interrupt-driven application to avoid returning to an empty main application. 0: Do not sleep when returning to Thread ...


6

Wilhelmsen and Chris were right - it was the circuit. However, it wasn't resistors, external IO, etc. It was the LD1117 Voltage Regulator which I hadn't really considered before. It turns out that pretty much all the 1A, 3.3v LDO voltage regulators I can find have a 5mA quiescent current. I've just soldered in a MIC5205 (which is rated for 150mA) and it ...


6

Use an RTC that supports an alarm line, eg. DS1375. The chip can drive an interrupt line at a given time/date. You do have to select the appropriate AVR sleep mode that 'listens' to the selected interrupt. No need to use the AVR timers.


6

The datasheet specifies a list of conditions under which those measurements will be valid. These conditions can include a range of things, including supply voltage, clock frequency, temperature, etc. You need to ensure that all of those conditions are met by your setup if you expect to achieve the promised results. Also, as others have mentioned, make sure ...


5

The answer was identified on the STM32 forum - happy days! I was failing to implement and enable the RTC interrupt correctly. This required the following steps: In stm32l0xx_hal_msp.c add the following to the HAL_RTC_MspInit(RTC_HandleTypeDef* hrtc) function: HAL_NVIC_SetPriority(RTC_IRQn, 0x0, 0); HAL_NVIC_EnableIRQ(RTC_IRQn); In stm32l0xx_it.c add the ...


5

It's not clear that making the resistor change you propose will be effective at solving your problem. The MCP160 requires that the enable input is taken below 20% of Vin to effectively switch the device off. If Vin is (say) 5 volts then 20% is 1.0 volts and, because the ULN2003 is a darlington, it may not reliably switch this low. However assuming it does ...


4

I had the same problem, it was caused by not waiting long enough after sending the message before re-asserting the sleep_rq pin. (@Dzarda got it). Experiment with different delays until it works. Edit: I know you have already set up SN and SP properly, but I'll leave this part of the answer in for others: The other thing to know is that you have to set SN ...


4

Yes, the WKUP pin works like that. If you really need standby state, you pretty much have no other choice left to wake up the device. You can, however, put a simple inverting transistor in front the the WKUP pin like this: simulate this circuit – Schematic created using CircuitLab Check the data sheet, you might be able to spare R2 if a proper pull-...


4

You can use the Watchdog timer to issue an interrupt instead of reseting the chip. The chip will wake up even from the deepest sleep mode on the watchdog interrupt. You will want to set the biggest prescaler for the Watchdog timer (8 seconds) and count interrupts. If the counter has not yet reached the predefined amount, immediately go back to sleep, ...


4

"Zero Power" is usually a buzz-word / marketing term. Zero power genuine occurs at zero current. This is not what you really want to know. The IEC 62301 standard for measuring standby power in household electrical appliances rounds power usage of 5 mW or less to zero. So, 13 uA or less in your case - see below. What matters depends on the source the ...


4

The asm instruction allows the entering of assembly directly; in this case, the AVR has an instruction explicitly for putting the microcontroller to sleep. You can't do this with a register - you have to do it by emitting the relevant assembly instruction. There's no need to do this yourself, however - sleep.h is not a library, but a header file that's part ...


4

According to this page, to wake it up, you need to send any AT command, which will be ignored by the module (so no response), followed (within 5 seconds) by AT+CSCLK=0 It took me all of one minute to find that by Googling "SIM800 sleep wake".


4

I'd run the sleep line directly into pin 2 of IC2A instead of adding another AND gate. That way you retain the Schmidt trigger and don't add a race to IC2A for the clock line. NOTE: You could also feed the /SLEEP signal to pin 6 on IC2B instead, but then the clock is still free running and when you wake it you can never know where you are in the clock cycle....


4

Well, sorry to revert my acceptance to the answer by Harry Svensson! And I shouldn't really be adding to a question that is 14 months old by now. However I just found the perfect software solution, which would have saved the tankful of gasoline I eventually burned (sorry, nature!). Instead of setting the pin to be pulled-up during deep sleep, you can use ...


4

A superhet receiver won't invent signal to the same degree but you still have the problem of power drawn by the receiver itself. Radio links that don't have one end mains powered typically need careful efforts to establish a schedule of check-in appointments and suffer a latency in that a message may not be able to be sent until the next scheduled ...


3

Many microcontrollers retain their pin output state when they go into sleep mode. The ATtiny85 certainly does (as does every AVR I've ever heard of). Usually the data sheet will say in its description of the low power modes.


3

On many microcontrollers, in addition to being able to enable or disable particular interrupt causes (typically within an interrupt controller module), there is a master flag within the CPU core that determines whether interrupt requests will be accepted. Many microcontrollers will exit sleep mode if an interrupt request reaches the core, whether or not the ...


3

Basically, the (internal) peripherals are shut off when the AVR goes to sleep. Which modules shut down depends on what sleep mode you enter into. The tinyx5 has three sleep modes: Idle, ADC Noice Reduction, and Power Down. Unless you need something to continue working while it sleeps, I would suggest the "Power Down Mode" which still allows the watch dog to ...


3

To switch something with a microcontroller such that it stays off when the microcontroller is off, one can use a "pull-down resistor", say 100 kOhms, on the MCU's output line. This line then drives the switching part, be it a BJT, MOSFET or something else. If the microcontroller asserts a value on the output (GPIO) pin, that overcomes the ground-ward pull ...


3

To save more data than 2 bytes accross a deep sleep: Redesign the application to require only two bytes (16 bits) accross deep sleep. Use a external battery-backed CMOS RAM. These take very little power when in standby, but still retaining their contents. A small coin cell can keep the contents alive for years. Use a external EEPROM. It can be ...


3

Unfortunately, there's really no good way to do this. When you call sleep, a system call is made and the OS goes off and runs other programs while you sleep. But the OS scheduler has a minimum timeslice it will do that on, and that's on the order of milliseconds, not microseconds. As a result, very small sleeps will tend to either not happen at all or take ...


3

I am working on a very similar project, that operates once every hour for about 15 seconds, and sleeps for the rest of the time. In an effort to conserve battery power (the device is deployed in the field for an average of 6 months at a time), using WDT interrupts was impractical because constantly counting interrupts was a huge battery draw. My system uses ...


3

This comment on reddit pointed me to this page, which says that clearing the ADEN bit in ADCSRA shed as many µA as are currently in excess in my test rigs. I am away from the lab right now, but when I get home tonight, that's the first thing I'll try. I'm optimistic. I do know that the ADEN bit gets set in init() in wiring.c... If it's confirmed, then the ...


3

The example circuit is given as this: The important factor here is the voltage which the \$\overline{MCLR}\$ pin sees, and when. Under normal operation the voltage should be high enough to register as a logic HIGH. When you want to reset, or wake up, the voltage must be low enough to register as a logic LOW. With SW1 open, the voltage at point \$A\$, ...


Only top voted, non community-wiki answers of a minimum length are eligible