Is there a reason a MightHat mote won't hold its sketch through a power outage?

Started by HeneryH, November 29, 2018, 01:47:52 PM

Felix

FYI - I just added SPI_transactions to the RFM69 library, can you please backup your local RFM69 lib, get this latest version, and try again, see if it makes a difference?
This was due to a reported issue: https://github.com/LowPowerLab/RFM69/issues/114

HeneryH

I dropped in the new lib and recompiled/uploaded but I'm still seeing the same behavior. 

thep33t

Felix, this is not a code - related issue, AFAIK. Here is the code I ran for one test, which didn't use any libraries.

Henry - Is it just the LCD that isn't working, or the entire sketch? For me it is just the LCD until RST. I want to make sure we are both experiencing the same issue and not confusing two similar but different issues.

#define CE  A1 //
#define DC  A0//
#define DIN  MOSI //
#define CLK  SCK //
void LcdWriteCmd(byte cmd)
{
  digitalWrite(DC, LOW); //DC pin is low for commands
  digitalWrite(CE, LOW);
  shiftOut(DIN, CLK, MSBFIRST, cmd); //transmit serial data
  digitalWrite(CE, HIGH);
}
void setup()
{
  pinMode(CE, OUTPUT);
  pinMode(DC, OUTPUT);
  pinMode(DIN, OUTPUT);
  pinMode(CLK, OUTPUT);
 
  LcdWriteCmd(0x21);  // LCD extended commands
  LcdWriteCmd(0xB8);  // set LCD Vop (contrast)
  LcdWriteCmd(0x04);  // set temp coefficent
  LcdWriteCmd(0x14);  // LCD bias mode 1:40
  LcdWriteCmd(0x20);  // LCD basic commands
  LcdWriteCmd(0x09);  // LCD all segments on
}

void loop()
{
}

HeneryH

It does seem like my MH Sketch is running despite the screen being blanked out.

Comforting to know the sketch is at least running in case it is intended to be used in a remote location.

thep33t

Pulled out a beer an my oscilloscope in order to close the loop on this. 

Looks like, as expected, no RST signal is sent to the LCD on initial boot after power loss. However, since the RST button, PIPIN22, and the RES on the LCD are tied together, this does indeed drop the pin to ground when pressed. This is important as the LCD requires a RST signal in order to initialize properly. Before this is received, it is in an uninitialized state, so only the LED back-light works, since that is a separate function all-together.

Per the datasheet:
"8.1 Initialization
Immediately following power-on, the contents of all internal registers and of the RAM are undefined. A RES pulse must be applied. Attention should be paid to the possibility that the device may be
damaged if not properly reset."

I am not too worried about the warning.damage portion, as I am mostly using this to debug/test.

I see two possible fixes:
1) HW redesign in V4
2) Might be able to at least alleviate the issue with a PI-based reset on powerup. As long as it is sure it is a fresh boot (maybe uptime is a decently high number...), PI will send a RST signal itself. Obviously, more design considerations in this one, but I think I will goo down this route, if I choose to do anything at all.