ds3234 / sd / enet, spi messed up? [SOLVED]

Hello,

I am noticing that whenever the ethernet shield is accessed, read accesses to the ds3234 RTC are corrupted (its internal data is maintained, however). The 3234 is selected by pin 49, set as output and initialized high.
I am using 3234 the library from Petre Rodan and it works perfectly well.

I also tried to digitalWrite(RTC_SEL_PIN, HIGH) just after reading the time upon power up but the issue persists.

Any idea?

Thanks for your time

Any idea?

I have an idea that there is a problem in the code you failed to post.

I'm not going to google "the library from Petre Rodan". You are. Post a link to the library, and any other non-standard libraries.

The most likely issue is that different devices on the SPI bus expect/require different SPI settings.

Thank you PaulS,
Rodan's ds3234 RTC library
here is my code. The loop is reduced to the bare minimum. Using the ui command #8 one can read the RTC. If from power up I stay in ui, ill get the epoch ok. If I press go and continue to the second part of the setup then to the loop and then I break again to ui the epoch returned by #8 is zero or complete nonsense. The interesting part in the second part of the setup involves accesses to the enet / sd chips. If all are commented then #8 returns correct time. If one is uncommented #8 returns garbage. The monitor output below in italic

I can not imagine how different devices can conflict on the spi. As long as a device is deselected it is supposed to float and ignore the transactions with any other device(?)

starting
C:\Users\Guy\Google Drive\arduino sw_12_12.ino
fname:_12
version #:12
version string:12
clock seems ok
epoch= 1527100114 epoch local= 1527100114
spare3 spare2 irrigate autorun | persHalt away armed NightOnly | alamEnable Log2Eeprom CLOUD SMS | email checkInet hasEnet synClock
18:28:34 version 12
next synch hour 19; exist stored args true; pir index 0; density 0; latchedDensityIndex 0
next record 96; arg record 95; args 2; old sensor word 3FFFF; sensor assembler3FFFF; sensor open 0; InetOK true
free eeprom ----------- 423/500
Q local time dhmse----- wednsday 18:28:35 1527100114
K syncClock ----------- false
T has Enet ------------ true
I do Check Inet is ---- false
E do email is --------- false
M do SMS is ----------- false
C do log2cloud is ----- false
L do log to eeprom is - false
A alarmEnable is ------ false
N night only ---------- false
R armed --------------- false
P away ---------------- false
H persistant halt is -- false
U AUTORUN ------------- false
Y irrigate is---------- false
G Go execute - unless exceptions
W valvesSetup
D dump Eeprom
V Erase Eeprom to virgin state (0xff)
1 ping SMS server, 2 ping Inet, 3 simulate mouvement, 4 sync time, 5 log, 6 write args, 7 read args, 8 get RTC, 9 poke eeprom
S siren is false
Current uiLoops=1
got '8'
epoch 1527100770
spare3 spare2 irrigate autorun | persHalt away armed NightOnly | alamEnable Log2Eeprom CLOUD SMS | email checkInet hasEnet synClock
18:39:25 version 12
next synch hour 19; exist stored args true; pir index 0; density 0; latchedDensityIndex 0
next record 96; arg record 95; args 2; old sensor word 3FFFF; sensor assembler3FFFF; sensor open 0; InetOK true
free eeprom ----------- 423/500
Q local time dhmse----- wednsday 18:39:26 1527100765
K syncClock ----------- false
T has Enet ------------ true
I do Check Inet is ---- false
E do email is --------- false
M do SMS is ----------- false
C do log2cloud is ----- false
L do log to eeprom is - false
A alarmEnable is ------ false
N night only ---------- false
R armed --------------- false
P away ---------------- false
H persistant halt is -- false
U AUTORUN ------------- false
Y irrigate is---------- false
G Go execute - unless exceptions
W valvesSetup
D dump Eeprom
V Erase Eeprom to virgin state (0xff)
1 ping SMS server, 2 ping Inet, 3 simulate mouvement, 4 sync time, 5 log, 6 write args, 7 read args, 8 get RTC, 9 poke eeprom
S siren is false
Current uiLoops=2
got 'g'
18:39:36 storing args..
18:39:36 write args: args/record/room = 2 95 423
18:39:36 same args, not writing
18:39:36 running...
18:39:36 Logging startup message to phant
18:39:36 Log to cloud disallowed, not logging - ignore any success report. Below preamble and log
GET /input/G2OjZV83y9S7orN77l3Y?private_key=NWDewMdKNjiBM61BBqAl&log=18:39:36_
Starting_version_12
18:39:36 posted to phant ok
>>>>>Setup ended<<<<<
spare3 spare2 irrigate autorun | persHalt away armed NightOnly | alamEnable Log2Eeprom CLOUD SMS | email checkInet hasEnet synClock
18:39:40 version 12
next synch hour 19; exist stored args true; pir index 0; density 0; latchedDensityIndex 0
next record 96; arg record 95; args 2; old sensor word 3FFFF; sensor assembler3FFFF; sensor open 0; InetOK true
free eeprom ----------- 423/500
Q local time dhmse----- wednsday 18:39:41 1527100780
K syncClock ----------- false
T has Enet ------------ true
I do Check Inet is ---- false
E do email is --------- false
M do SMS is ----------- false
C do log2cloud is ----- false
L do log to eeprom is - false
A alarmEnable is ------ false
N night only ---------- false
R armed --------------- false
P away ---------------- false
H persistant halt is -- false
U AUTORUN ------------- false
Y irrigate is---------- false
G Go execute - unless exceptions
W valvesSetup
D dump Eeprom
V Erase Eeprom to virgin state (0xff)
1 ping SMS server, 2 ping Inet, 3 simulate mouvement, 4 sync time, 5 log, 6 write args, 7 read args, 8 get RTC, 9 poke eeprom
S siren is false
Current uiLoops=3
got '8'
epoch 1293939602
spare3 spare2 irrigate autorun | persHalt away armed NightOnly | alamEnable Log2Eeprom CLOUD SMS | email checkInet hasEnet synClock
18:40:01 version 12
next synch hour 19; exist stored args true; pir index 0; density 0; latchedDensityIndex 0
next record 96; arg record 95; args 2; old sensor word 3FFFF; sensor assembler3FFFF; sensor open 0; InetOK true
free eeprom ----------- 423/500
Q local time dhmse----- wednsday 18:40:2 1527100801
K syncClock ----------- false
T has Enet ------------ true
I do Check Inet is ---- false
E do email is --------- false
M do SMS is ----------- false
C do log2cloud is ----- false
L do log to eeprom is - false
A alarmEnable is ------ false
N night only ---------- false
R armed --------------- false
P away ---------------- false
H persistant halt is -- false
U AUTORUN ------------- false
Y irrigate is---------- false
G Go execute - unless exceptions
W valvesSetup
D dump Eeprom
V Erase Eeprom to virgin state (0xff)
1 ping SMS server, 2 ping Inet, 3 simulate mouvement, 4 sync time, 5 log, 6 write args, 7 read args, 8 get RTC, 9 poke eeprom
S siren is false
Current uiLoops=4
got '8'
epoch 0
spare3 spare2 irrigate autorun | persHalt away armed NightOnly | alamEnable Log2Eeprom CLOUD SMS | email checkInet hasEnet synClock
18:40:05 version 12
next synch hour 19; exist stored args true; pir index 0; density 0; latchedDensityIndex 0
next record 96; arg record 95; args 2; old sensor word 3FFFF; sensor assembler3FFFF; sensor open 0; InetOK true
free eeprom ----------- 423/500
Q local time dhmse----- wednsday 18:40:6 1527100805
K syncClock ----------- false
T has Enet ------------ true
I do Check Inet is ---- false
E do email is --------- false
M do SMS is ----------- false
C do log2cloud is ----- false
L do log to eeprom is - false
A alarmEnable is ------ false
N night only ---------- false
R armed --------------- false
P away ---------------- false
H persistant halt is -- false
U AUTORUN ------------- false
Y irrigate is---------- false
G Go execute - unless exceptions
W valvesSetup
D dump Eeprom
V Erase Eeprom to virgin state (0xff)
1 ping SMS server, 2 ping Inet, 3 simulate mouvement, 4 sync time, 5 log, 6 write args, 7 read args, 8 get RTC, 9 poke eeprom
S siren is false
Current uiLoops=5
got '8'
epoch 1294659690
spare3 spare2 irrigate autorun | persHalt away armed NightOnly | alamEnable Log2Eeprom CLOUD SMS | email checkInet hasEnet synClock
18:40:10 version 12
next synch hour 19; exist stored args true; pir index 0; density 0; latchedDensityIndex 0
next record 96; arg record 95; args 2; old sensor word 3FFFF; sensor assembler3FFFF; sensor open 0; InetOK true
free eeprom ----------- 423/500
Q local time dhmse----- wednsday 18:40:11 1527100810
K syncClock ----------- false
T has Enet ------------ true
I do Check Inet is ---- false
E do email is --------- false
M do SMS is ----------- false
C do log2cloud is ----- false
L do log to eeprom is - false
A alarmEnable is ------ false
N night only ---------- false
R armed --------------- false
P away ---------------- false
H persistant halt is -- false
U AUTORUN ------------- false
Y irrigate is---------- false
G Go execute - unless exceptions
W valvesSetup
D dump Eeprom
V Erase Eeprom to virgin state (0xff)
1 ping SMS server, 2 ping Inet, 3 simulate mouvement, 4 sync time, 5 log, 6 write args, 7 read args, 8 get RTC, 9 poke eeprom
S siren is false
Current uiLoops=6

as for library guy_lib it contains mainly passwords and a livelock to halt the machine

realizing I could upload the code to this server :frowning:

_12.ino (94.8 KB)

The solution in minimal words, pasted from Uno, official Ethernet shield and RTC1306 using SPI not working togheter - Networking, Protocols, and Devices - Arduino Forum

// change to mode 1 for RTC
SPI.setDataMode(SPI_MODE1);

// do your RTC SPI stuff

// then change back to mode 0 for w5100 and SD
SPI.setDataMode(SPI_MODE0)

SurferTim - You are the man!

It is bizarre though that the programmers need to be concerned with such incantations, Shouldn't this be part of the libraries/device drivers?