mumblepins / arduino

Automatically exported from code.google.com/p/arduino
Other
0 stars 0 forks source link

Initialization failure on Mega #796

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. load demo code for the W5100 that uses the SDcard (Blinkled from 
simplewebserver)
2. Power OFF/ remove USB connector from Mega board
3. Re-apply power

What is the expected output? What do you see instead?
The demo should work from cold start, but the SDcode hangs internally after 
supplying one file.
However If a warm start (press reset button on mega) is issued then there is no 
problem.

There is also no problem if you 'upload' a file to the SDcard before 
downloading a file, then it functions correctly after a cold start.

What version of the Arduino software are you using? On what operating
system?  Which Arduino board are you using?
 1.0IDE OSX mega V2

Please provide any additional information below.

The SD and ethernet libraries need to be cleaner, leaving the  SPI state 
'clean' after exiting and not assuming they are the sole owners, the SDcode 
should also NOT be disabling system interrupts whilst it is performing actions.

Original issue reported on code.google.com by practica...@gmail.com on 17 Jan 2012 at 10:33

GoogleCodeExporter commented 9 years ago
This was eventually traced by using a logic analyzer on the SPI.
Basically since the Arduino design is 'clean' and the CPU does not initialize 
any I/O unless the user code specifically performs it , situations can arise 
where the entry conditions os libraries are not known.

In the above case, it appears that the 'entry' conditions for power reset & 
reset button are different, when the SD card is in place, this caused 'chatter' 
on the SPI bus. 
The solution is better documentation, and a requirement to turn OFF BOTH W5100 
AND SDCARD before calling the libraries, this then completely solved any issues 
related to the above problem.

Original comment by practica...@gmail.com on 18 Feb 2012 at 10:43

Attachments:

GoogleCodeExporter commented 9 years ago
Hi,

I do not understand what you mean by "turn OFF BOTH W5100 AND SDCARD before 
calling the libraries"

-> setup W5100 AND SDCARD cs pin to "LOW" before calling the librairies or 
other things ?

Original comment by philipp...@gmail.com on 13 Aug 2012 at 2:05

GoogleCodeExporter commented 9 years ago
It's a relatively common problem in a system with complex peripherals, that 
resetting the main cpu does not necessarily reset the peripherals.  So you 
would turn on interrupts, and there would suddenly be an ethernet interrupt, 
even though the ethernet driver hadn't been initialized to the point where it 
was ready to deal with interrupts.  The details obviously vary...

Original comment by wes...@gmail.com on 14 Aug 2012 at 12:17

GoogleCodeExporter commented 9 years ago
ok well but how ?

Original comment by philipp...@gmail.com on 14 Aug 2012 at 7:53

GoogleCodeExporter commented 9 years ago
I do not understand what you mean by "turn OFF BOTH W5100 AND SDCARD before 
calling the libraries"

It is simple and not difficult to understand.......

lets say you have an Ethernet adapter and an SD card, but you decide to write a 
script for the SD card.
Since you do not touch the ethernet card, its state is undefined by the startup 
condition, and therefore by default so is its behavior.

By turning "OFF" both, we put them BOTH into a defined and known state,we can 
then safely use the one we want without the other interfering in the 
communication process.

Original comment by practica...@gmail.com on 14 Aug 2012 at 11:31