Wake avr from power save with signal on normal IO pins? ATmega324PB

Go To Last Post
11 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi everyone,

 

I am using ATmega324PB and the pins are configured this way. All the pins of PORTA , PORTB, PORTC, PORTD are defined as output and leaving me with PORTE, which is also being used for 5 inputs, PE2, PE3, PE4, PE5, PE6 are defined as input pins. Now pins of PORTE do not come under any interrupts, no external interrupts or pin change interrupt

 

Is it possible to wake the MCU from sleep with signal on all the PORTE pins? Any trick I can use?

 

I can't use the other PORTS for wake up cause they are being used in the OUTPUT circuitry. I can't make PORTE output, because I need full 4 output PORTs for the application (so that I can do operations on the PORT directly I.E 8 bits) and also 5 INPUTS pins. This MCU is ideal for the job, fits perfectly except the wake from sleep thing. 

 

Thanks.

“Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how will you ever debug it?” - Brian W. Kernighan
“Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.” - Antoine de Saint-Exupery

Last Edited: Fri. Aug 20, 2021 - 01:26 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Which Sleep Mode, please?

The answer is: yes on PE0/PE1 (unless busy with crystal) or other PE, check Datasheet Sleep Modes and also External interrupts.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well you could wake up using the WDT and poll your PORTE pins!  devil

 

Enable USART2 and enable start bit detection wake up PE2!

 

 

 

FF = PI > S.E.T

 

Last Edited: Fri. Aug 20, 2021 - 01:07 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


grohote wrote:
Which Sleep Mode, please?

 

This one. And yes PE0/PE1 are used by crystal.

 

 

 

“Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how will you ever debug it?” - Brian W. Kernighan
“Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.” - Antoine de Saint-Exupery

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ki0bk wrote:
Enable USART2 and enable start bit detection wake up PE2!

This one seems okay for one pin.

 

I need to know which pin wake up the MCU. Out of 5 pins. PE2-PE6. All the signals are simple on/off 12V signals from car.

ki0bk wrote:
Well you could wake up using the WDT and poll your PORTE pins!  devil

Okay, interesting.

 

So this will work like wake the MCU every 64ms, then read PORTE and determine which pins are high. If none are high immediately go back to sleep, and repeat.

 

Is waking up every 64ms sounds okay? (for fast response) Any idea how much impact it will have on current consumption when compared to proper sleep.

“Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how will you ever debug it?” - Brian W. Kernighan
“Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.” - Antoine de Saint-Exupery

Last Edited: Fri. Aug 20, 2021 - 01:23 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Heisen wrote:
This one seems okay for one pin.

Note start bit detection requires a high to low transition to trigger, so may not work for you.....

Polling may be your only choice, or swap with pins on another port with PC interrupt, handle port pin mapping like an arduino sad

 

 

FF = PI > S.E.T

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

grohote wrote:
The answer is: yes on PE0/PE1 (unless busy with crystal) or other PE

Mind, other PE are PCINT-useless as it can be read from the Table 6-1. PORT Function Multiplexing.

Choose between WDT, or other PE: USART, or TWI.

 

Edit: Why you did it, this Requirement for wake up must have priority. Now, you are inventing wakeup on a crippled device.

Last Edited: Fri. Aug 20, 2021 - 03:14 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

grohote wrote:
Edit: Why you did it, this Requirement for wake up must have priority. Now, you are inventing wakeup on a crippled device.

Lesson learned.

 

The atmega324PB is somewhat new and has the most number of IO pins in TQFP-44 package, I needed exactly 39 IO pins - 32 output pins (packed in four output ports) 5 input pins and 2 pins for crystal. 

 

But I missed the wake up from input pins requirement while choosing. Nothing can be done now (app is almost done). There is no choice except for going to TQFP-64 megaAVR (being in the same family), but that jump comes at significant price increase.

 

I have to make the crippled wake up thing work somehow.

 

“Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how will you ever debug it?” - Brian W. Kernighan
“Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.” - Antoine de Saint-Exupery

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


Heisen wrote:
There is no choice except for going to TQFP-64 megaAVR (being in the same family), but that jump comes at significant price increase.
fyi

Sleep Modes | SLPCTRL | AVR® DB Family

[bottom]

prices :

ATmega324PB, 1.49USD each for 100

AVR64DB64, 1.70USD each for 100

 


https://www.microchipdirect.com/product/search/all/ATmega324PB (lead time is 48 weeks to 52 weeks)

https://www.microchipdirect.com/product/search/all/AVR64DB64 (lead time is 18 weeks to 31 weeks)

 

Migration from the megaAVR® to AVR® Dx Microcontroller Families

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Update - I am looking at IO expander chip from microchip MCP23017. In ATmega324PB datasheet TWI Address match is mentioned as a wake up source from sleep. How exactly does that work? Will MCP23017 will keep on sending data when it's pin state changes? And MCU will be able to wake up? And what if, if I want to poll the pins of IO expander when MCU is not sleeping. Don't want any interrupts. Is it all possible?

“Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how will you ever debug it?” - Brian W. Kernighan
“Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.” - Antoine de Saint-Exupery

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Is it possible to wake the MCU from sleep 

Why exactly are you going to sleep?  Many times they think they are saving lots of power, but actually save nothing or very little---it is very circuit dependent.  One pulldown resistor or transistor can take more power than the entire AVR.

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!