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.
What is the difference between SPI chip select and SPI Pin select?
Also, we were trying to send three 8-bit data from the TMS570LC43x board to a daughter Board. The requirements are that the CS should be low throughout this operation. We are writing a value to a specific register and after that reading the same value from that register. There is transmit operation which takes uses 3 spiTransmit() API. Also in another function, there are 2 spiTransmit() API followed by a spiReceive() API. The code for the same is given below.
Transmit operation:
dataconfig1_t.CS_HOLD = TRUE;
dataconfig1_t.WDEL = FALSE;
dataconfig1_t.DFSEL = SPI_FMT_0;
dataconfig1_t.CSNR = SPI_CS_0;
dataconfig1_f.CS_HOLD = FALSE;
dataconfig1_f.WDEL = FALSE;
dataconfig1_f.DFSEL = SPI_FMT_0;
dataconfig1_f.CSNR = SPI_CS_0;
ack= spiTransmitData((spiBASE_t *)spiREG1,(spiDAT1_t *)&dataconfig1_t,1,(uint16 *)&op1);
ack1=spiTransmitData((spiBASE_t *)spiREG1,(spiDAT1_t *)&dataconfig1_t,1,(uint16 *)&op2);
spiTransmitData((spiBASE_t *)spiREG1,(spiDAT1_t *)&dataconfig1_f,1,(uint16 *)&value);
Receive Operation:
dataconfig1_t.CS_HOLD = TRUE;
dataconfig1_t.WDEL = FALSE;
dataconfig1_t.DFSEL = SPI_FMT_0;
dataconfig1_t.CSNR = SPI_CS_0;
dataconfig1_f.CS_HOLD = FALSE;
dataconfig1_f.WDEL = FALSE;
dataconfig1_f.DFSEL = SPI_FMT_0;
dataconfig1_f.CSNR = SPI_CS_0;
flag1=spiTransmitData((spiBASE_t *)spiREG1,(spiDAT1_t *)&dataconfig1_t,1,(uint16 *)&opcode1);
flag2=spiTransmitData((spiBASE_t *)spiREG1,(spiDAT1_t *)&dataconfig1_t,1,(uint16 *)&opcode2);
flag3=spiReceiveData((spiBASE_t *)spiREG1,(spiDAT1_t *)&dataconfig1_f,1,(uint16 *)&received_data);
The value which we are sending is 0x31 but what we are getting is 00. Can anyone help explain this?
Thanks in advance!
Hi Varikoti,
What is the difference between SPI chip select and SPI Pin select?
spiPinSelect:
Actually, SPI pins can also be operated as GIO, i mean we can SET or RESET the SPI pins values by making them as GIO output and similarly we can also make them as GIO input and can read the SPI pin values. The SPI "spiPinSelect" structure will be used in this case only.
For example, you can see the SPIPC3 register, once you configure any particular SPI pin into GIO output then you can use this register to SET or REST the output.
You can compare the "spiPinSelect" structure with above bit placements, they will match each other.
For example you can also see the above pic, in this example it try to control the output values of few SPI pins and here i used the values of "spiPinSelect" enum structure.
spiChipSelect:
This structure is used to activate the particular chip select pin during the SPI data transfer.
If you refer the "CSNR" field of the SPIDAT1 register, there it is explained about how to enable the particular chip select pin.
For example, if i want to activate the CS0 to low while transferring the data i have to write CSNR value to the 0xFE(SPI_CS_0), like as shown below:
The above code makes the only CS0 active low and other CS pins to active high while transferring the data.
You can also refer below thread for more details:
And here is the example SPI master code for TMS570LC4357:
5224.SPI_MASTER_TEST_LC4357.zip
--
Thanks & regards,
Jagadish.
We have worked and updated the code from the information you have given us.
The code didnt work, we are sending data of 8 bit but we are getting 0 as the received data
Can you please review our code and let us know where we went wrong ?
Thank you
Hi Varikoti,
You didn't provide details about what is the slave device you are using?
My suggestion would be first test master in loopback mode, and this will help you to make sure everything from master side is working fine.
Later try to implement the protocol slave suggesting for communication.
--
Thanks & regards,
Jagadish.
Hi Jagadish,
We have already tried loopback. It was working fine. We are using HOLT HI-3220 as the slave device.
Hi Varikoti,
We are using HOLT HI-3220 as the slave device.
This slave device is very new for me, and it would take time for me to explore it.
If you have a logic analyzer, then do the following things.
So, my suggestion is first making sure you are sending data properly by tapping MOSI line with logic analyzer. If you are sending data is correct, then again make a tap with MISO line and see weather slave is sending data properly or not. If this is doing correctly then we should receive the data to the receive buffer in the master controller.
--
Thanks & regards,
Jagadish.
Hi Jagadish
We are sure about the working for the slave device and how to configure it. The only thing which we are stuck at is the SPI for the TMS board if you could just check if all the things are initialized correctly, that will be really helpful.
Hi Varikoti,
Apologies for the delay i was stuck with some other issues.
Is your issue resolved or still do you need my support?
--
Thanks & regards,
Jagadish.