ToPi 0 Posted April 2, 2013 Share Posted April 2, 2013 Hi! First of all, thank you for creating this great project. I am thinking about switching to Arduino/Energia from mbed (and Arduino before). However, I have a question: My project requires communicating with at least two SPI devices at once (read data from a sensor, put data into a circular buffer, write it then on SD-Card). It is not possible to use a single SPI with different CS-lines. How would the code look for this? In this forum, I found "SPI.setModule(0)", but in Arduino, I have only a single SPI object... Thank you for any hint in advance, Tobias Quote Link to post Share on other sites
roadrunner84 466 Posted April 2, 2013 Share Posted April 2, 2013 Except for the MSP430G2955 or MSP430F... the usual launchpad chips do not support more than one SPI port at once. This limitation can be overcome by using software SPI, I guess there are people who made a library for this, since SPI isn't that complicated at all. If you fail to find one, I can write one up for you if required, though I'd like to know how timing etc. should be handled in this case. ToPi 1 Quote Link to post Share on other sites
gwdeveloper 275 Posted April 2, 2013 Share Posted April 2, 2013 The g2553 has 2 spi ports. I don't think it's possible to use any them absolutely simultaneously though. There will always be a minimal but countable cycle delay. Just figure out if it is faster to R/W to different ports or to just use different CS pins. ToPi 1 Quote Link to post Share on other sites
roadrunner84 466 Posted April 2, 2013 Share Posted April 2, 2013 TS stated that using CS to alternate isn't possible (for some obscure reason), but he didn't state that absolute parallelism is required. I think you can write to one SPI port without it affecting anything else, but the code to communicate with the SPI peripheral itself takes some cycles. ToPi 1 Quote Link to post Share on other sites
ToPi 0 Posted April 2, 2013 Author Share Posted April 2, 2013 Hi, thank you for the suggestions and the quick response! I plan to use the Stellaris LaunchPad Evaluation board (EK-LM4F120XL) which carries the Stellaris LM4F120H5QR. According to the pinout map of the board and to the Datasheet of the MCU it has four SPI ports. Unfortunately, my application really requires two independent SPI ports. I managed to et this up with the mbed (NXP Arm Cortex M3 processor, higher price, two SPI) without issues. Therefore I am shure that it will work with the TI chip as well. But my big question now is: How would it work? Can I do it with the Arduino/Energia SPI-Class, or will I need to copy&rename the SPI-class, e.g. SPI2, and assign pins of another hardware SPI port? Again, my question relates to use of Energia IDE. Thank you everybody for suggestions, Tobias Edit: Working synchroneus is not necessary Quote Link to post Share on other sites
roadrunner84 466 Posted April 2, 2013 Share Posted April 2, 2013 Erm... Energia does only work with the MSP430, which is a totally different processor than the Stellaris. They just happen to both be made by Texas Instruments. Never mind me, Energia does support the stellarpad. Quote Link to post Share on other sites
Rei Vilo 695 Posted April 2, 2013 Share Posted April 2, 2013 You can use software SPI, which comes standard in Energia implementation.. Learn more about shiftIn() and shiftOut(). Speeds are lower than with hardware SPI but match perfectly SD card. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.