flash.initialize() fails when powered from vIn... What ???

Started by VdesmedT, October 12, 2015, 06:33:56 AM

VdesmedT

Hey guys,

My sketched was working fine when powered up from the FTDI board but fails when powered up by a Lipo connected to vIn...  After investigation, it turns out that the code that fails is the flash.initialize() !  That makes absolutely no sens to me but it seems to be the problem so far.  As anyone experienced something similar ?

those are the lines that were removed :

//SPIFlash flash(8, 0xEF30); //EF30 for 4mbit  Windbond chip (W25X40CL)
//flash.initialize();

Felix

So you have a Moteino with FLASH MEM right?
There were some threads about this.
Your D8 may be floating, causing the FLASH MEM chip to not respond. You probably need a 10K pullup to 3.3v on D8. Give that a try and let us know if it's still an issue.

VdesmedT

Thanks Felix,

I'll give it a try but why would that only be the case when FTDI is disconnected ?

TomWS

@VdesmedT, have you tried to go back to the FTDI (with flash initialize enabled) after trying the LiPo?  My thought was that the LiPo accidentally touched 3.3V pin and fried the flash chip.  I'm struggling to find another potential cause.  Felix's suggestion might be necessary if you weren't using flash initialize.


Felix

Quote from: VdesmedT on October 12, 2015, 08:39:52 AM
Thanks Felix, I'll give it a try but why would that only be the case when FTDI is disconnected ?

You have an earth ground insted of a floating ground which can be influenced by static a lot more.

VdesmedT

Quote from: TomWS on October 12, 2015, 08:41:15 AM
@VdesmedT, have you tried to go back to the FTDI (with flash initialize enabled) after trying the LiPo?

I have switched from one to the other many times as my mind couldn't settle on this :-)  Often happens to me..  I have to experience things many times before I actually start to believe it..... 

Thanks though

TomWS

Quote from: VdesmedT on October 12, 2015, 08:56:10 AM
Quote from: TomWS on October 12, 2015, 08:41:15 AM
Often happens to me..  I have to experience things many times before I actually start to believe it..... 
LOL!  I hear ya!
Good luck, if I think of anything I'll let you know.  Is it safe to assume that you've checked that the LiPo is charged and you're getting 3.3V at the 3.3V pin?

Tom

VdesmedT

Quote from: TomWS on October 12, 2015, 09:10:59 AM
Is it safe to assume that you've checked that the LiPo is charged and you're getting 3.3V at the 3.3V pin?

That also went through my poor mind 8)

VdesmedT

Quote from: Felix on October 12, 2015, 08:34:22 AM
Your D8 may be floating, causing the FLASH MEM chip to not respond. You probably need a 10K pullup to 3.3v on D8.

Gave it a try..  same problem, despite the pullup, D8 remains LOW and flash.Initialize does not passes.  I have noticed something strange : while doing my tests, I noticed that if I connect the FTDI in a way that GND is connected first, the same problems happens (and D8 is low) while if I connected the FTDI in away that DTR is connected first, it works (and D* is HIGH)....  rings a bell ?

UPDATE : Seems that connecting the battery then reseting the moteino by pulling DTR down solves the problem

Felix

Take a look at this issue. It's not the same situation since you do have a SPI FLASH chip (OEM from LowPowerLab).
But it's strikingly similar in behavior. If you have a logic analyzer and/or scope you could start digging into this a lot better than guessing what could be wrong. I have not seen this type of behavior. If you have other SPI devices and libraries that could be a cause. Can you try a stock example sketch that only initializes the SPIFLASH without any other SPI device attached and observe any difference?
PS. also ensure you got the latest lib code.

VdesmedT

Interesting...  I uploaded the stock example sketch, disconnected the moteino from all external circuit and...  same issue :-) I also tried on a bunch of moteino just to check that nothing was wrong with the one I was using..  green test !

So, simply loading the stock example sketch on a moteino and trying different ways to connect the FTDI module (from left to right or from right to left) shows the problem. Also, not using the FTDI to power up the moteino but using the GND/VIN pins from a 3.7 Lipo shows it even better... 

I'll try to debug SPI using my BitScope when I can....

Thanks,

Felix

Ok, I have updated the SPIFlash example sketch, I added a fast blinking sequence when flash.initialize() succeeds:

SPIFlash flash(FLASH_SS, 0xEF30);
void setup(){
  Serial.begin(SERIAL_BAUD);
  Serial.print("Start...");

  if (flash.initialize())
  {
    Serial.println("Init OK!");
    Blink(LED, 20, 10);             <------ blinks every time, so initialize() does not fail
  }
  else
    Serial.println("Init FAIL!");
  
  delay(1000);
}


I have tested with a bran new Moteino with FLASHMEM, and the blinking is always presend, no matter how I power it, through FTDI or just through GND-VIN, from battery or from PC etc.

So I cannot replicate the issue you are describing. Until you submit a full analysis and demonstration and point out the code where it fails and why, I will assume there is no issue. In fact if there was such a initialize() issue this would have been raised long ago since the FLASHMEM is essential for several features of Moteino.

VdesmedT

Hey there, Sorry Felix, I never meant to suggest that there was a problem with he moteino. It has always be clear to me that I was doing something wrong.  I've created this video to show you what I'm doing.

https://youtu.be/B9eJ-Ckye0M

The first time, the fast blinking does not appears while it does on the second part of the clip.  If you see something obvious that I do wrong, please let me know.

kindest regards,

Valery

Felix

Valery,
I thought you said that it works with FTDI and not when powered from VIN+GND. So can you please load my sketch (updated last night) and try again. There is a fast blinking at start of the sketch, then the normal blinking.

VdesmedT

Hey felix,

The same problem indeed happens when powering up from Vin. The sketch that you see running is your latest version with the fast blinking that you can berly see happening on the second run (the video fps make it so that you only see a bit longer blink). Have you notice the two different way to plug the FTDI ?