This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Simple SPI Usage on TMS570LS04

Other Parts Discussed in Thread: HALCOGEN

Hi again everyone.

I'm continuing to write my Road Test review on the TMS570LS04 LaunchPad. It's a great bit of kit, by the way! I'm currently trying to do the most basic SPI bus communication -- simply writing values to an SPI EEPROM. I've used HALCoGen to set up SPI2 with all the correct values. I've imported all the code it generated into CCS, and I've started to write sys_main.c. I've found all the functions pre-written for SPI in spi.c. So I've called spiInit() and now I want to send a bunch of 8-bit values down the line to my EEPROM.

I clearly want to use the polling method (at least I think so) so the function is spiTransmitData() but I'm unclear on what the parameters are supposed to be. I'm fairly good with C but I've never programmed for an ARM (or any 32-bit micro, so far) so some of the code feels a bit foreign so far. I'm assuming I just create an array (it seems uint32 is the right format for the variable?) for all the bytes I want to send, and then call spiTransitData and plug in the array that I want to send.

I've tried to find a tutorial or any info at all, really, on SPI with this micro. Perhaps I'm looking in the wrong direction? I read the whole SPI section in the Technical Manual but that only helps if I'm writing my own functions for a custom header file, which I will probably do -- but at this point I just want to get it working with the HALCoGen functions.

Also, after sending the write enable bit to the EEPROM I need to latch the CS pin (pull it high and then low). Is there a simple way to do this?

It seems my learning curve with CCS and Hercules is quite steep... Thanks!

  • Alexander,

    If you have HalCoGen installed then open it and assuming you are at 3.0.6 there is an example app called example_spi_Master_Slave.c that shows how to use the APIs.  Uses one SPI w. interrupts and the other with polling.

    Eventually - I'd suggest understanding the data format concept for the Hercules SPI - you'll see it's one of the parameters.  The hercules SPI has multiple chip selects and you can preset 4 different data format registers in case the different slaves have different data formats.   Then when you trasnmit you select which of the four presets to use by writing the format to the upper part of the SPI data word.  

    This is a time saver if you are using one SPI fo multiple devices.

    You should only need one format to talk to a single device like an EEPROM but later if you share the SAME SPI with something like a display controller or an accelerometer .. these formats can make talking to all the devices a lot quicker.