EEVblog Electronics Community Forum

Electronics => Beginners => Topic started by: aep9690 on May 12, 2013, 02:07:43 am

Title: SPI Test Device
Post by: aep9690 on May 12, 2013, 02:07:43 am
The answer to this maybe on the internet somewhere, however the terminology I am using is kind of vague so it might not be showing up in my search results.  But anyway here it goes.

I am trying to build a battery management system for an electric vehicle, the battery management chip communicates via a 4 wire SPI bus.  I am using the MSP430G2253 to communicate with the chips and perform the cell balancing.  I am writing the code to send and receive data from the microcontroller, I would like to have some sort of dummy device that can receive data and then send something back, so I can make sure that the code I wrote is correct.

Does something like this exist, or does anyone have any ideas of what I could use?
Title: Re: SPI Test Device
Post by: Skimask on May 12, 2013, 02:18:11 am
Disclaimer:  I'm not MSP430 savvy...

Does the MSP430's SPI "read in" the SPI data at the same time it "writes out" the SPI data?  (The PIC's do it that way, but again, I don't do MSP430's)
Couldn't you just do a loop back?
Or if you're looking to fire out a 'command' and get back a 'response' (whether it's simulated or otherwise), set up another MSP430 as a slave SPI device and have it send back your dummy data.
Title: Re: SPI Test Device
Post by: c4757p on May 12, 2013, 02:21:14 am
Does the MSP430's SPI "read in" the SPI data at the same time it "writes out" the SPI data?  (The PIC's do it that way, but again, I don't do MSP430's)
Couldn't you just do a loop back?

Isn't this how bidirectional SPI is always supposed to work?
Title: Re: SPI Test Device
Post by: aep9690 on May 12, 2013, 02:28:58 am
I'm not very familiar with microcontrollers in the first place, but I believe the way it works is that once the GPIO pins are configured as MOSI ans MISO they have 8 bit buffers that you can write to to send data and read from the receive it.

The loop back idea is brilliant, I haven't thought of that.  I think I will try that and see if it works.  Thanks.
Title: Re: SPI Test Device
Post by: Skimask on May 12, 2013, 02:51:14 am
Isn't this how bidirectional SPI is always supposed to work?
Bidirectional, sure...
But simultaneously bidirectional, where you shift stuff in at exactly the same time as you shift stuff out, I've never had a need to use the SPI module in that way.
Title: Re: SPI Test Device
Post by: nuhamind2 on May 12, 2013, 03:26:52 am
Try buspirate
Title: Re: SPI Test Device
Post by: aep9690 on May 12, 2013, 06:08:05 am
I looked up buspirate, it seems like it could do the job.  But it seems like it is meant to act as a master.
Title: Re: SPI Test Device
Post by: amyk on May 12, 2013, 09:47:58 am
What do you need to test exactly? An SPI flash might be of some use.
Title: Re: SPI Test Device
Post by: kripton2035 on May 12, 2013, 10:14:09 am
buy any spi peripheral simple to use like a real time clock, a peripheral extension, or a temperature sensor
then you will have a simple spi device to talk to and try your code with that.