London, UK
Offline
Full Member
Karma: 4
Posts: 179
|
 |
« on: April 05, 2012, 09:15:24 am » |
Hi, I am trying to run an SD Card and the WIZ820io Ethernet interface on an Arduino Mega 2560 Both work separately but as soon as I add pinMode(10, OUTPUT); digitalWrite(10, LOW);
the ethernet interface stops working
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Boston area, metrowest
Offline
Brattain Member
Karma: 242
Posts: 16485
Available for Design & Build services
|
 |
« Reply #1 on: April 05, 2012, 09:52:33 am » |
Each device needs its own Slave Select line. Typically these seem to D10 and D4 on shields. Check what each device is using.
|
|
|
|
|
Logged
|
|
|
|
|
London, UK
Offline
Full Member
Karma: 4
Posts: 179
|
 |
« Reply #2 on: April 05, 2012, 11:05:38 am » |
Hi With just ethernet device plugged in I enabled the SS pin as an output even if i put it low it stops working, does the ethernet library control this because I had a look on an oscilloscope without mentioning the SS pin and it seemed to output 3.3V but drop it to low whenever there was communication between the two.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Sr. Member
Karma: 6
Posts: 398
|
 |
« Reply #3 on: April 05, 2012, 12:47:36 pm » |
So what is a slave select pin supposed to do in your opinion?
I think it's supposed to go low whenever there is communication to let that particular slave know that it is supposed to be the recipient. Then by high when the slave is not being selected.
|
|
|
|
|
Logged
|
|
|
|
|
Germany
Offline
God Member
Karma: 69
Posts: 802
If you believe something is right, you won't see what's wrong (David Straker).
|
 |
« Reply #4 on: April 05, 2012, 03:07:52 pm » |
When I recently attached two SPI devices (SD Card and LCD) i noticed, that the chip select is not the only problem. Both devices (i mean their libs) did use a different and incompatible SPI setup. And both libs did this setup only during their lib startup phase. This forces me to save the SPI state of both libs and restore the settings, depending which device i want to access next.
Oliver
|
|
|
|
|
Logged
|
|
|
|
|
nr Bundaberg, Australia
Offline
Tesla Member
Karma: 71
Posts: 6815
Scattered showers my arse -- Noah, 2348BC.
|
 |
« Reply #5 on: April 05, 2012, 04:26:56 pm » |
By "incompatible" do you mean that for example they use different clock edges or something?
If so you could re-run their .begin() funcs each time but that's a bit of a crappy way to do it. As you say you could remember the port state and change back and forth.
But the LCD is a slow device, why not use shiftOut() to talk to it or are you reading data from it as well?
______ Rob
|
|
|
|
|
Logged
|
|
|
|
|
Germany
Offline
God Member
Karma: 69
Posts: 802
If you believe something is right, you won't see what's wrong (David Straker).
|
 |
« Reply #6 on: April 05, 2012, 05:53:52 pm » |
Indeed the LCD (16x2, doglcd lib) uses Software SPI (something like shiftout). But SdFat makes use of the HW SPI. On the board both devices are connected to the same SPI pins (with different chip select signals). To use the doglcd lib, I had to disable the SPI subsystem. To use SdFat I had to restore the HW SPI .
Oliver
|
|
|
|
|
Logged
|
|
|
|
|
nr Bundaberg, Australia
Offline
Tesla Member
Karma: 71
Posts: 6815
Scattered showers my arse -- Noah, 2348BC.
|
 |
« Reply #7 on: April 05, 2012, 06:04:44 pm » |
On the board both devices are connected to the same SPI pins This doesn't make sense if one device is using software SPI. Just move the LCD to different pins if you have spare ones. ______ Rob
|
|
|
|
|
Logged
|
|
|
|
|
London, UK
Offline
Full Member
Karma: 4
Posts: 179
|
 |
« Reply #8 on: April 05, 2012, 06:27:57 pm » |
It turns out that if I set the SS pins for the SD.h lib and the Ethernet.h lib (4 and 10 respectively) then they don't work. However if I don't mention anything in the setup they work fine. And the oscilloscope confirms that all the selections seem to be done automatically. Aaaaannnnddd everything works together. 
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Tesla Member
Karma: 71
Posts: 6603
Arduino rocks
|
 |
« Reply #9 on: April 05, 2012, 06:31:40 pm » |
A good SPI library would change the SPI settings (clock mode, clock speed) automatically whenever necessary - not sure I've seen one that does this. You also have to ensure every device has its CS line high before any SPI transfers are performed.
The more fundamental problem with SPI libraries is when you want to use SPI in an interrupt routine (not unusual with RF transceivers for instance) - you then need to inhibit interrupts around other calls to the SPI primitives, or some other anti-collision scheme.
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Boston area, metrowest
Offline
Brattain Member
Karma: 242
Posts: 16485
Available for Design & Build services
|
 |
« Reply #10 on: April 05, 2012, 07:56:10 pm » |
Find a better LCD library that uses real SPI.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 3
|
 |
« Reply #11 on: June 15, 2012, 09:28:53 am » |
I am trying to run [...] the WIZ820io Ethernet interface on an Arduino Mega 2560 Both work separately [...]
Hello mrjonny2 Can you tell me, please, in detail how you ran WIZ820io on Mega 2560? WIZ820io is R1.0 ?! What version of the IDE, Mega, WIZ, libraries, etc... Pins to pins connection, plz Thanks!!!
|
|
|
|
|
Logged
|
|
|
|
|
London, UK
Offline
Full Member
Karma: 4
Posts: 179
|
 |
« Reply #12 on: June 17, 2012, 09:58:33 am » |
Hi Sorry for sporadic replies, exam period and all ;( I am using the module with a 2560 at the moment. The pinout I am using is: MISO - 50 MOSI - 51 SCLK - 52 nSS - 10 I am using an arduino mega pro (3.3V version from spark fun) Version 1.0 of the IDE Make sure you give it 3.3V Power Make sure you have the updated libraries - http://www.wiznettechnology.com/sub_modules/en/product/Product_Detail.asp?cate1=5&cate2=42&cate3=0&pid=1161#tabI can't remember if there were any other changes I had to make to the library, because I had some error messages thrown up but I can't remember what they were. Let me know if you have any other problems.
|
|
|
|
|
Logged
|
|
|
|
|
|