Author Topic: Lowpower library and ATmega1284P  (Read 588 times)

Uncle Buzz

  • Jr. Member
  • **
  • Posts: 96
  • Country: fr
Lowpower library and ATmega1284P
« on: December 15, 2017, 04:50:54 AM »
Hi,

in lowPower.h from lowPower library, shouldn't  idle function in code below deals with USART1 for ATmega1284P with a new #define block since ATmega1284P  has 2 hardware serial ?
Code: [Select]
class LowPowerClass
{
public:
#if defined (__AVR_ATmega328P__) || defined (__AVR_ATmega168__) || defined (__AVR_ATmega1284P__)
void idle(period_t period, adc_t adc, timer2_t timer2,
timer1_t timer1, timer0_t timer0, spi_t spi,
       usart0_t usart0, twi_t twi);
#elif defined __AVR_ATmega2560__
void idle(period_t period, adc_t adc, timer5_t timer5,
timer4_t timer4, timer3_t timer3, timer2_t timer2,
    timer1_t timer1, timer0_t timer0, spi_t spi,
       usart3_t usart3, usart2_t usart2, usart1_t usart1,
usart0_t usart0, twi_t twi);
#elif defined __AVR_ATmega32U4__
void idle(period_t period, adc_t adc, timer4_t timer4, timer3_t timer3,
timer1_t timer1, timer0_t timer0, spi_t spi,
       usart1_t usart1, twi_t twi, usb_t usb);
#else
#error "Please ensure chosen MCU is either 168, 328P, 32U4, 1284P, 1280 or 2560."
#endif
or USART are not linked to hardware serial ?

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 5699
  • Country: us
    • LowPowerLab
Re: Lowpower library and ATmega1284P
« Reply #1 on: December 15, 2017, 02:14:55 PM »
Perhaps it should. I added the 1284p to the existing define when I forked the lib.
Are you having issues getting the expected idle current?

Uncle Buzz

  • Jr. Member
  • **
  • Posts: 96
  • Country: fr
Re: Lowpower library and ATmega1284P
« Reply #2 on: December 15, 2017, 05:00:53 PM »
I made a moteino like with ATmega1284p since I was not able to put all the libraries I use in 328p, but my PCB was designed for genuine moteino and it's why I made a new one. I made a mistake by routing serial1 instead of serial0. I use idle fonction with forever period to shut down everything I don't use, like ADC and TIMER1 (TIMER2 also but curiously, without TIMER1 nor TIMER2, TIMER0 is very inaccurate), and in my case, USART0.
But I was wondering how could I stop USART1 if I had correctly route serial0...
I use an OLED screen on this application, so ľA are not my goal and I didn't check how much current I save, but just wondering if it was missing something or if I misunderstood how it works.

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 5699
  • Country: us
    • LowPowerLab
Re: Lowpower library and ATmega1284P
« Reply #3 on: December 18, 2017, 11:52:58 AM »
Not misunderstood, just probably overlooked by my fork. I haven't detected a problem with USART1 and I haven't had a need to look into it. I hardly ever used USART1 though :P

I don't think you need to worry much, unless you are stuck using USART1. By default the USARTs have to be enabled, otherwise they are off (and use no power?), I haven't dug up the datasheet for this but the sketches require a serial1.begin(baud) which implies they are off by default.

Any way to reroute your traces to USART0?

Uncle Buzz

  • Jr. Member
  • **
  • Posts: 96
  • Country: fr
Re: Lowpower library and ATmega1284P
« Reply #4 on: December 19, 2017, 07:07:19 AM »
Since it's working, I won't change anything on those already running, but if I build new ones, I'll redesign PCB to route correctly serial0.
So, no needs to stop USART if we haven't started it with "begin" command ?

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 5699
  • Country: us
    • LowPowerLab
Re: Lowpower library and ATmega1284P
« Reply #5 on: December 19, 2017, 10:24:37 AM »
So, no needs to stop USART if we haven't started it with "begin" command ?
No I don't think there is a reason to, but double check the datasheet to ensure the 1284p is no different.