narcoleptic library doesn't compile with Mega2560 or 1284p

Hello All,
The narcoleptic library for putting the micro into a low power mode has an example sketch whimsically titled MerlinTheCat. It complies OK with Arduino UNO and any other ATmega 328 boards I’ve tested but does NOT compile with a Mega 2560 or ATmega 1284P boards.

Is there something wrong with the board files or are the larger micros inherently incompatible with the narcoleptic library?

roger

Probably just incompatibility with hardcoded port usage, something like that.
Have you tried contacting the library creator about it?
Got a link to the library, preferably to source code?

MerlinTheCat compiles just fine for both micros here, 1.0.5 on Linux. What errors are you seeing?

I am using Windows with Arduino 1.0.5

I am getting many errors all of the form of:
NarcoleptClass :: xx()
all followed by
error: 'PRR' was not declared in this scope.

Roger

OldMicroGuy:
I am using Windows with Arduino 1.0.5

I am getting many errors all of the form of:
NarcoleptClass :: xx()
all followed by
error: 'PRR' was not declared in this scope.

Roger

PRR is the power reduction register. The larger MCUs have more peripherals and one register isn't enough, so they have PRR0 and PRR1 instead of just PRR.

PRR is the power reduction register. The larger MCUs have more peripherals and one register isn't enough, so they have PRR0 and PRR1 instead of just PRR.

Thanks Jack that explains why the Narcoleptic library doesn't work.

Can anyone recommend a sleep library for the ATmega1284P?

Roger

OldMicroGuy:

PRR is the power reduction register. The larger MCUs have more peripherals and one register isn't enough, so they have PRR0 and PRR1 instead of just PRR.

Thanks Jack that explains why the Narcoleptic library doesn't work.

Can anyone recommend a sleep library for the ATmega1284P?

Roger

What sort of sleeping do you want to do? Narcoleptic has a wide range of capabilities, sleep as well as power reduction while running.

Lowest power for longest battery life. Wake up every 20 seconds. Might even try 3V3 @ 8 MHz
Roger

Mega2560 won't do 8 MHz 3.3V, needs 4.5V:
ATmega2560/ATmega2561:
• 0 - 16MHz @ 4.5V - 5.5V

Need a 2560V to get that slow:
ATmega2560V/ATmega2561V:
• 0 - 2MHz @ 1.8V - 5.5V, 0 - 8MHz @ 2.7V - 5.5V

'1284P will do 8 MHz, 3.3V:
0 - 10MHz @ 2.7 - 5.5V

What would you have it do every 20S? Could it just wake on an interrupt instead?

What would you have it do every 20 S? Could it just wake on an interrupt instead?

I was only thinking of using a 1284p.

The app is a battery powered temperature and maybe humidity sensor. I wouldn't have any external device to generate an interrupt. Need to use internal timer.

Roger

Power-down mode is the deepest sleep mode, in which the MCU will only draw about 0.1µA. The watchdog timer (WDT) can be used to wake it. The WDT requires 4-5µA to run, which is still hardly anything. The watchdog is not terribly accurate, so if you want something very close to 20 sec, some calibration may be needed, which will be specific to each individual MCU chip. The watchdog is also not infinitely variable, it can generate interrupts (to wake the MCU) at roughly 8, 4, 2, 1 seconds, or at 500, 250, 125, 64, 32, 16ms. It's common to sleep for several WDT periods to effectively generate longer periods; this technique should add virtually nothing to power consumption. An external RTC can be used to generate interrupts more accurately at specified times but it doesn't sound like that's part of the plans.