You are here

SPIM_WriteTxData() Usage | Cypress Semiconductor

SPIM_WriteTxData() Usage

Summary: 3 Replies, Latest post by hli on 27 Sep 2015 02:02 PM PDT
Verified Answers: 1
Last post
Log in to post new comments.
mnauss_1472621's picture
21 posts

Hello, I am new to embedded code and PSoC Creator as well. I am embarrassed to ask such a basic question but I must as I am just not sure how to proceed. I am using the SPIM component from the library and I want to communicate over the SPI to a MPL115A Barometer.

The format of the write is address then data, such as (0x20, 0x00). Now the description for the SPIM write function is as follows:

SPIM_WriteTxData() Places a byte/word in the transmit buffer which will be sent at the next available bus time. So how do I perform an address then data write, would it be 2 writes such as, void SPIM_WriteTxData (uint8, 0x20) then void SPIM_WriteTxData (uint8, 0x00)? this seems like the long way to do something. I have some sample code for the adruino that shows: write (0x20, 0x00).

So I am sorta confused. Any suggestions/help would be appreciated. I hope my question made sense. Also one more question, do I have to declare a function prototype for each SPIM function I use?


user_365962704's picture
144 posts

xxx_WriteTxData have only 1 parameter (which can be uint8_t or uint16_t), that is the data value to transmit from the SPI, so you might use like this:

SPIM_WriteTxData (0x20);

SPIM_WriteTxData (0x00);

or you can put your data on a array and use xxx_PutArray(const uint8_t buffer[], uint8_t byteCount) function

parameter buffer[] is the name of your array, byteCount is the number of data to move to the transmit buffer

so you can do:

uint8_t data[2] = {0x20, 0x00};

xxx_PutArray(data, sizeof(data)); /* This function will place 0x20 and 0x00 on your trasmit buffer */

xxx is the name of your component on the schematic, when you place the component and configure, then you have to build the proyect, this will generate all the function available for the component, you can see them on the datasheet of each component or in the generated source files after the build process.

hope this help you

mnauss_1472621's picture
21 posts

That's a big help, thank you very much.

user_78878863's picture
2553 posts

One caveat though: when using the SPIM-controller slave select line, it will go low when you are not deliverinbg new data to send fast enough. WriteTxData just fill bytes into the SPI FIFO, and when the FIFO is empty SS goes low.

Log in to post new comments.