4 Replies Latest reply on Mar 21, 2018 7:19 AM by user_109981545

    How do I send data block from SPIS to SPIM?

    user_109981545

      I am designing a system with 4 PSoC 5LP boards acting as Slaves and one more acting as a Master. They will be connected using SPI (with separate CS’s). The slaves will run A/D converters and the Master will request the data in blocks of 6 kBytes. I estimate that one block will require a few hundred milliseconds and that would be fast enough.

      I have prototyped a system with two PSoC  5LP CY8CKIT - 059 Kits, one with an SPIM and one with an SPIS component. I have a UART on the Master to control it through a serial port on the PC and, for now, a UART on the Slave to help with debugging. The only other devices are an output pin on each to control the on board LED and an ISR on the slave board connected to the SPIS RX Interrupt (because I cannot figure out how to make the internal interrupt work).

      I can send bytes from the Master to the Slave but have not succeeded in reading a block of bytes sent back by the Slave. I have pared the programs down to the bare minimum and include them here. (I hope the attach worked).

      As you can see, I handle the UART in the the foreground and send a lower case b or v to blink the led or send  a version string for testing. If I send an upper case character to the Master, it sends, it via SPI, to the Slave.  That works and I can blink or output the version message on the Slave by sending  a B or V  to the Master. So my SPI interconnection does work. I am using a full duplex connection with both MOSI and MISO. For now, I do not have a CS, I just leave the Slave selected all the time.

      But I have not succeeded in transferring a block of bytes back from the Slave. I make a small block (of letters to make the testing easier) and put them in a TX buffer in the Slave. (I made the Slave TX buffer 40 bytes long.) Then,when I clock any data in from the Master, the Slave sends them out on MISO. I can see them on my oscilloscope. But the Master does not read them properly.  It gets some correctly but not all. I am not sure when or how I can read them from the SPIM RX . I tried waiting for SPI done before reading the RX buffer. That put a few microseconds delay between transmitted bytes but still does not make it work properly.

      Please answer the following questions

      1. How do I make SPIM read the data that SPIS sends out

      2. For SPIS internal Interrupt, what is the ISR name and how do I init it?

      3. What is the difference between SPIS_WriteByte and SPIS_WriteTXData()

      4. Does mode really matter if I am building both sides? Is one better?

      5. Is this a sensible way to transfer a 6 kByte block? DMA is too complicated for me.

      thanks

      Dave