USB + SPI

330 views
Skip to first unread message

Casten

unread,
Feb 18, 2012, 3:52:04 AM2/18/12
to toasted circuits lightuino
Hi Andrew & others,

I'm wondering if it is possible to use both the USB serial and also
the SPI interface for another component at the same time? I'm trying
to use a DeadOn RTC - DS3234 and as soon as I init the RTC, the serial
stops working. I've seen some other posts, but I thought one of the
benefits of SPI was being able to have multiple devices was possible.
Is the problem the USB and RTC both want to be masters?

Thanks in advance for your help with this.
-Casten

Andrew Stone

unread,
Feb 18, 2012, 9:30:26 PM2/18/12
to toasted-circu...@googlegroups.com
It ought to be, but I've never tried it.  I'll see if I can try something in the next few days...

Maw

unread,
Feb 22, 2012, 11:51:31 AM2/22/12
to toasted circuits lightuino
Same problem here with Ethernet shield.

Casten Riepling

unread,
Feb 27, 2012, 1:16:40 AM2/27/12
to toasted-circu...@googlegroups.com
Any update on multiple SPI devices?  If you can point me to any appropriate references, I can try to figure it out myself.  I just don't know where to start.  I suppose if I understood how the USB was integrated, I could dig around in SPI docs to see if the conflict can be resolved.  Where would I look for information on how the USB is integrated?  Looking in the libraries folder, LightuinoUSB.cpp,.h looks like what I'll need to dig into.

Maw

unread,
Feb 27, 2012, 9:40:00 PM2/27/12
to toasted circuits lightuino
If I include the Ethernet library in the example begin_here
( #include <Ethernet.h> )
I got this

/Applications/Arduino.app/Contents/Resources/Java/libraries/Ethernet/
utility/w5100.cpp: In member function 'void W5100Class::init()':
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ethernet/
utility/w5100.cpp:28: error: 'delay' was not declared in this scope
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ethernet/
utility/w5100.cpp:30: error: 'SPI' was not declared in this scope
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ethernet/
utility/w5100.cpp: In static member function 'static uint8_t
W5100Class::write(uint16_t, uint8_t)':
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ethernet/
utility/w5100.cpp:133: error: 'SPI' was not declared in this scope
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ethernet/
utility/w5100.cpp: In static member function 'static uint16_t
W5100Class::write(uint16_t, const uint8_t*, uint16_t)':
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ethernet/
utility/w5100.cpp:146: error: 'SPI' was not declared in this scope
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ethernet/
utility/w5100.cpp: In static member function 'static uint8_t
W5100Class::read(uint16_t)':
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ethernet/
utility/w5100.cpp:159: error: 'SPI' was not declared in this scope
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ethernet/
utility/w5100.cpp: In static member function 'static uint16_t
W5100Class::read(uint16_t, uint8_t*, uint16_t)':
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ethernet/
utility/w5100.cpp:172: error: 'SPI' was not declared in this scope

I'm using Arduino IDE 1.0 and 0022 and y get the shame error


On Feb 18, 8:30 pm, Andrew Stone <st...@toastedcircuits.com> wrote:

Andrew Stone

unread,
Feb 27, 2012, 9:41:15 PM2/27/12
to toasted-circu...@googlegroups.com
Yes that's the file.  I'm still working on getting another SPI device attached.  I have an ethernet shield that should do the trick...

If I could take a guess, it would be that I configure the SPI differently then the other user.  So while you'll never be able to use them quite at the same time, we might be able to let you switch back and forth.  The question is whether this switch can be implemented by calling "Usb.Begin()" to pop over to the L5 serial and then the other device's init to pop back, or whether we need to save the SPI state, pop to L5 SPI and then restore the SPI state.

Of course, you should have different SPI SS (chip select) lines for each device as well.

Cheers!
Andrew

Andrew Stone

unread,
Mar 12, 2012, 4:00:04 PM3/12/12
to toasted-circu...@googlegroups.com
Ethernet shield guys,

"Ping" is working but I'm getting complete garbage into my Arduino Duemlanove or Mega and (if I just ignore the input garbage and print stuff out) I am getting mostly garbage out.  And of course the same thing with the Lightuino... I've tried 2 V6 ethernet shields with the same result.  Anyone seen this?  Searches turn up nothing...

Cheers!
Andrew

Here's an example of the garbage I'm seeing on the output side.  This is using the web server example sketch...

TTP/1.1 200 OK
Content-Type: text/html

analog input 0 is 570<br />
analog input 1 is 500<br />
analog input 2 is 464<br />
analog input ��)�YR|9.Z ��n<�O��b�9��zs��o�> !
vxLR��&���c�
            C ����YU? _l� U�@u��F@ "bT$�N�#�.�FF �ɩE�Ga' F qP�I}�.��’ s&�}%v�6�?����p���AZp%Rթ���� ?<:�� Fl5�&ݲ�AS��r ���," 2Gj����swXF`G P���Sx8�\Xn �/,� s�<ݝ`.4!$i��L��
    "d�i�֯H�;�C4�lTKF��\a� 3�9V;; d�Y��`�=y�B��,���U䜐P���f L%�0�*3��ۅ
                                                                         ��b��@���AQI�- ��? ��EaIYwcN� ���Eڗ�ź}�� �E��U�AY
                                           �\ �� )� �jV�7�$�q�B �Ũ5������/ ��e�{�

Casten

unread,
Mar 23, 2012, 11:04:54 PM3/23/12
to toasted circuits lightuino
Any news on the SPI stuff? Also, I ordered an FTDI cable (from China,
now weeks in the mail!) and am wondering if I populate and use the
FTDI header will it interfere with SPI peripherals? Also unclear is
whether all serial + sketch uploading can be done over FTDI.

Thanks in advance for the info.

G. Andrew Stone

unread,
Mar 25, 2012, 12:09:05 AM3/25/12
to toasted-circu...@googlegroups.com
I ordered another SPI ethernet board; maybe that one will actually work (with Arduino)!  But it will take awhile to appear :-(.  You can use the FTDI it won't interfere since it uses the UART not the SPI.

But, what you have to do is use the existing USB to first upload a bootloader ROM.  Do you have the 20 or 16 mhz Lightuino board?  Then the FTDI will work to upload sketches (you may need to hit the reset button to upload the sketch though).  Then, to completely disable the existing USB (so you can use ethernet), you need to hold the USB chip in reset.  To do this, look for an unpopulated 3 pin header just above the USB connector.  The rightmost hole is labelled "reset".  You need to solder a jumper wire to that.  When you want to hold the USB chip in reset, connect that to 5v.

You could probably skip the FTDI for now and disconnect that jumper, upload your sketch, then connect it and hit reset to use the ethernet (but no serial).  Might get tedious but it should work :-)

Cheers!
Andrew

G. Andrew Stone

unread,
Apr 9, 2012, 11:07:00 AM4/9/12
to Casten Riepling, toasted-circu...@googlegroups.com
Yes, you can certainly use them simultaneously.  Just use the normal "Serial.xxx" function calls to access the FTDI serial.

Cheers!
Andrew

On Mon, Apr 9, 2012 at 3:18 AM, Casten Riepling <casten....@gmail.com> wrote:
Hi Andrew,

I got my FTDI cable and soldered on the header.

Is it possible to use USB & the FTDI simultaneously?  Or are they mutually exclusive?  I just want to be able to get serial io while I'm using SPI.  If I need to disable USB to get SPI to work, I guess that is not a deal breaker.  But I'm wondering where I should get a bootloader ROM to use FTDI?

Any help is appreciated.

-Casten




G. Andrew Stone

unread,
Apr 9, 2012, 12:23:57 PM4/9/12
to Casten Riepling, toasted-circu...@googlegroups.com
The most common cause of that error is if you have a 20mhz CPU but select 16mhz when uploading your sketch (or vice versa).
http://code.google.com/p/arduino-m5451-current-driver/source/browse/trunk/latest/libraries/lightuino5_lib_dev/INSTALL

Cheers!
Andrew

On Mon, Apr 9, 2012 at 11:46 AM, Casten Riepling <casten....@gmail.com> wrote:
Strange, I could see data coming across ftdi serial, but it was garbled at all bitrates.

Sent from my Windows Phone

From: G. Andrew Stone
Sent: 4/9/2012 8:07 AM
To: Casten Riepling
Cc: toasted-circu...@googlegroups.com
Subject: Re: [Lightuino] Re: USB + SPI

Casten

unread,
Apr 21, 2012, 12:58:48 AM4/21/12
to toasted circuits lightuino
Yes, this was the problem, thanks!

On Apr 9, 9:23 am, "G. Andrew Stone" <g.andrew.st...@gmail.com> wrote:
> The most common cause of that error is if you have a 20mhz CPU but select
> 16mhz when uploading your sketch (or vice versa).http://code.google.com/p/arduino-m5451-current-driver/source/browse/t...
>
> Cheers!
> Andrew
>
> On Mon, Apr 9, 2012 at 11:46 AM, Casten Riepling
> <casten.riepl...@gmail.com>wrote:
>
>
>
>
>
>
>
> > Strange, I could see data coming across ftdi serial, but it was garbled at
> > all bitrates.
>
> > Sent from my Windows Phone
> > ------------------------------
> > From: G. Andrew Stone
> > Sent: 4/9/2012 8:07 AM
> > To: Casten Riepling
> > Cc: toasted-circu...@googlegroups.com
> > Subject: Re: [Lightuino] Re: USB + SPI
>
> > Yes, you can certainly use them simultaneously.  Just use the normal
> > "Serial.xxx" function calls to access the FTDI serial.
>
> > Cheers!
> > Andrew
>
> > On Mon, Apr 9, 2012 at 3:18 AM, Casten Riepling <casten.riepl...@gmail.com
Reply all
Reply to author
Forward
0 new messages