My Arduino works for several hours with the ethernet shield and then the ethernet shield seems to stop working. The other functions work fine, but the ethernet parts just seem to stop working. My code is at www.russdraper.com (search for the arduino posts) if you wish to look at it. Is this a known issue? It works fine after I push the button to reset it.
I have an ethernet shield associated to a freeduino board,can you help me how to connect a temperature sensor (DALLAS 18B20) and how to view the temp on the internet (i mean the full code needed)
thanks in advance.
Can this have something to do with the millis rollover? approx 9h30 on
older software 49 days on release 0012
I don't have any hardware yet, but I would try something like
uint8_t oldSREG = SREG;
// disable interrupts while we write timer0_millis or we might get an
// inconsistent value (e.g. in the middle of the timer0_millis++)
cli();
timer0_millis = 0xF800;
SREG = oldSREG;
You can read the millis function and find the time for rollower.
If it takes too long time to rollower, you can increase the 0xF800 constant.
You will find the millis() function in wiring.c
Magnus
Magnus's technique for testing whether your application is "rollover-proof" is a good one. However, since timer0_millis is a 32-bit unsigned long, you should really change
timer0_millis = 0xF800;
to
timer0_millis = 0xFFFFF800;
This will start your sketch at about 0x800 = 2048 ms (about 2 seconds) before the rollover.
Mikal
To test "rollover-proof", it's not a good idea to adding the line
timer0_millis = 0xFFFFF800;
to the millis() function in wiring.c.
This modification resets the timer value to 0xFFFFF800 every time the function is called.
To test rollover, the following modification at variable definition in wiring.c may be better.
//volatile unsigned long timer0_millis = 0;
volatile unsigned long timer0_millis = 0xFFFFF800;
My code has passed the test
tasasaki, I don't think anyone was suggesting setting timer0_millis inside the millis() function itself. I think the idea was just to set it wherever in the sketch it is most crucial to test rollover.
Mikal
mikal, can you set the variable timer0_millis to a value in the sketch code (*.pde file)?
When I assign a value to the timer0_millis in a *.pde file, compile error occurs like this;
In function 'void loop()':
error: 'timer0_millis' was not declared in this scope
How can I change the time0_millis in a sketch?
tasasaki,
If you simply declare it "extern" in your sketch like this:
extern volatile unsigned long timer0_millis;
then later in your sketch you can just do:
timer0_millis = 0xFFFFF800;
wherever you want!
Mikal
Oh I see. It's a common way of the C-like languages.