Go Down

Topic: Bug with Ethernet Shield? (Read 1 time) previous topic - next topic

nosebreaker

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.

ata

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.

Magnus

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
Code: [Select]
     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
     

mikalhart

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

Code: [Select]
timer0_millis = 0xF800;
to
Code: [Select]
timer0_millis = 0xFFFFF800;

This will start your sketch at about 0x800 = 2048 ms (about 2 seconds) before the rollover.

Mikal

tasasaki

#4
Jan 08, 2009, 09:26 am Last Edit: Jan 08, 2009, 11:35 am by tasasaki Reason: 1
To test "rollover-proof", it's not a good idea to adding the line

Code: [Select]
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.

Code: [Select]
//volatile unsigned long timer0_millis = 0;
volatile unsigned long timer0_millis = 0xFFFFF800;


My code has passed the test :)

mikalhart

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

tasasaki

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;
Quote
In function 'void loop()':
error: 'timer0_millis' was not declared in this scope

How can I change the time0_millis in a sketch?

mikalhart

tasasaki,

If you simply declare it "extern" in your sketch like this:

Code: [Select]
extern volatile unsigned long timer0_millis;

then later in your sketch you can just do:

Code: [Select]
timer0_millis = 0xFFFFF800;

wherever you want!

Mikal

tasasaki

Oh I see. It's a common way of the C-like languages.

Go Up