- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have two psoc kits. I want these two kits to communicate with the SPI. I looked at the sample projects but I could not.
the first psoc will send information "A" to the second psoc.
After the second psoc receives "A" information, it will send "B" data to the first psoc and write it on the LCD.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Burak Tasci,
LCD port connection has been changed, please change the LCD port connections and please refer to the below screenshot and then try running the above code. The API LCD_PrintString("SPI MASTER:"); will print no matter your spi is running or not, so you can confirm the working of LCD by this.
For the second question, the API SPIM_WriteTxData(); supports only one argument and hence it is showing an error.
If you want to try then you have to pass an two data elements, one for position and another for the data.
SPIM_WriteTxData(0x35); //denotes position of the element
SPIM_WriteTxData(0x14); //actual element that has to be stored in the particular position
The slave has to read the data twice i.e once for position and other for data and then the processing must be done
pos = SPIM_ReadRxData(0x35);
data = SPIM_ReadRxData(0x14);
Finally the array of position should be equal to data.
array[pos] = data;
Regards
Alakananda
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Burak Tasci,
We checked the project which you have attached and it is working at our side and we are receiving the data as per required.
I have shared a screenshot of the ouput which we observed at our side.
Can you please probe it and observe the waveforms at your side and let us know the isuue you are facing.
Regards
Alakananda
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I want to see the information I sent on the LCD. but I cannot see it on lcds on the master or slave sides.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The LCD shows nothing. I checked the connections.
I also want to ask something else. What command should I use if I want to write 0x14h to the slave's register at 35h.
SPIM_WriteTxData(0x35,0x14); ==>I'm trying. it gives an error.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Burak Tasci,
LCD port connection has been changed, please change the LCD port connections and please refer to the below screenshot and then try running the above code. The API LCD_PrintString("SPI MASTER:"); will print no matter your spi is running or not, so you can confirm the working of LCD by this.
For the second question, the API SPIM_WriteTxData(); supports only one argument and hence it is showing an error.
If you want to try then you have to pass an two data elements, one for position and another for the data.
SPIM_WriteTxData(0x35); //denotes position of the element
SPIM_WriteTxData(0x14); //actual element that has to be stored in the particular position
The slave has to read the data twice i.e once for position and other for data and then the processing must be done
pos = SPIM_ReadRxData(0x35);
data = SPIM_ReadRxData(0x14);
Finally the array of position should be equal to data.
array[pos] = data;
Regards
Alakananda
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
if the slave c opposite is another module (eg RF module), rather than the pleasure psoc, can it detect address and data separately?
While komutunu silerken, köle "00" diyor.
silmezsem çalışmıyor.
// while (! (SPIS_ReadTxStatus () & SPIS_STS_SPI_DONE))
// {};
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Burak Tasci,
Can you please probe and send the waveforms so that we can see what is happening in the spi bus.
Regards
Alakananda
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Only the master logic output is as follows.
Only the slave logic output is as follows.
slave and master miso-->miso,mosi-->mosi,clk-->clk,en-->en connection logic output state is as follows.
The master writes 00. The slave writes 16. Doesn't the master have to type 42?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Alakananda;
I tried the file you sent. I made some changes. But SPIS does not work. I changed the PSoc to become a slave master. but again the same slave does not work.
I think we need to make changes for the slave?
/*******************************************************************************
* File Name: main.c
*
* Slave Code
*******************************************************************************/
#include <project.h>
void sendDataToMaster(){
SPIS_WriteTxDataZero(0x50);
SPIS_WriteTxData(0x53);
SPIS_WriteTxData(0x4F);
SPIS_WriteTxData(0X43);
SPIS_WriteTxData(0X20);
SPIS_WriteTxData(0X53);
SPIS_WriteTxData(0X4C);
SPIS_WriteTxData(0X41);
SPIS_WriteTxData(0X56);
SPIS_WriteTxData(0X45);
}
int main()
{
uint8 i = 0u;
CyGlobalIntEnable;
LCD_Start();
SPIS_Start();
LCD_ClearDisplay();
for(;;)
{
while(!(SPIS_ReadTxStatus() & SPIS_STS_SPI_DONE))
{};
LCD_Position(0u,0u);
LCD_PrintString("SPI Slave:");
LCD_Position(1u,0u);
LCD_PrintHexUint8(SPIS_ReadRxData());
sendDataToMaster();
}
}
/* [] END OF FILE */
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Burak,
We tried with your code and its working for us.
Can you please check the MISO coonection again and try sending single data and check if its working at your end.
Slave sends the data only when master sends out the data to the slave.
Regards
Alakananda
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Alakananda;
SPI worked after changing MISO, MOSI, CLK, SS pins.
thank you very much.
now I have to experiment with register.
" For the second question, the API SPIM_WriteTxData(); supports only one argument and hence it is showing an error.
If you want to try then you have to pass an two data elements, one for position and another for the data.
SPIM_WriteTxData(0x35); //denotes position of the element
SPIM_WriteTxData(0x14); //actual element that has to be stored in the particular position
The slave has to read the data twice i.e once for position and other for data and then the processing must be done
pos = SPIM_ReadRxData(0x35);
data = SPIM_ReadRxData(0x14);
Finally the array of position should be equal to data.
array[pos] = data; "
but I have a question. we have 1byte = 8 bits of data in a register. how to send them to registers.
Regards...
Burak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Burak,
Does the individual register mean you are using the control register?
Regards,
Alakananda
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Alakananda;
I have an RF transceiver module. this module has registers at certain addresses as in the picture.I want to load the values I want to these registers.
SPIM_WriteTxData(0x35,0x14); ==>when I try this way, it gives an error. (for example, this code works in arduino.) in this code address: 0x35 data: 0x14
" { pos = SPIM_ReadRxData(0x35);
data = SPIM_ReadRxData(0x14);
Finally the array of position should be equal to data.
array[pos] = data; } "==> rf module does not work when we do this way
Regards...
Burak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Burak,
You can try using this API void SPIM_PutArray(const uint8/uint16 buffer[], uint8 byteCount)
where buffer[0] will be your address and buffer[1] will be your data
Please try doing this if not send your waveforms we will recheck again.
Regards
Alakananda
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
MASTER CODE "PSOC MASTER "==>"50 53 4f 43 20 4d 41 53 54 45 52"
SPIM_WriteTxData(0x50);
SPIM_WriteTxData(0x53);
SPIM_WriteTxData(0x4f);
SPIM_WriteTxData(0x43);
SPIM_WriteTxData(0x4D);
SPIM_WriteTxData(0x41);
SPIM_WriteTxData(0x53);
SPIM_WriteTxData(0x54);
SPIM_WriteTxData(0x45);
SPIM_WriteTxData(0x52); "
When I write this code, I write the code below to the slave device.The slave device is not loading the first two data into the rfbuffer.if I change the code to "if (RFBuffer [0u] == (0x4f)"). lcd write "OSCMASTER" so the first character "p" is lost.
Slave code:
for(count=0; count < 10 ; count++)
{
RFBuffer[count] =SPIS_ReadRxData();
}
/* SPI communication is complete so we can display received data */
//LCD_ClearDisplay();
LCD_Position(0u,0u);
LCD_PrintString("SPI Slave:");
if(RFBuffer[0u]==(0x50) ){
LCD_Position(1u,0u);
LCD_PrintString(RFBuffer);
LED_Write(1u);
sendDataToMaster();}
else {
LCD_ClearDisplay();
// CyDelay(100);
LCD_Position(1u,0u);
LCD_PrintString("BILGI YOK");
LED_Write(0u);}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Burak,
Can you please refer to the below thread and let us know if it would help to solve your issue
Strange behavior of SPIS_PutArray()
Regards
Alakananda