SPI communication with periferal device

Hello,

I am new with this type of device, so I am sorry at advance if it is described somewhere else. My problem is as follows. I have ChipWhisperer-Lite Capture, CW308 board and custom SPI periphery device.

I would like to ask if it is possible to use 20 pin connector to communicate with custom peripheral through SPI interface. In documentation of CW-lite there is description of SPI interface and communication but I am not convicted, if it is possible to use for sending commands.

Thank you

Hi,

You can use the SPI object in chipwhisperer/software/chipwhisperer/hardawre/naeusb/spi.py to send SPI data over the 20-pin connector.

Alex

1 Like

Hi,
Is there any example to learn how to use spi.py to send/read SPI data over the 20-pin connector?
I also want to know about the usage of the commands.
self.sendCtrl(self.CMD_SPI, self.SPI_CMD_DATA, data)
Does it mean that will send both SPI_CMD_DATA = 0xA4 and data to the hardware which connects to the 20-pin connector? Otherwise, how the receiver know that should read or write and the length of data?
Thank you!

ZT

I think all we spi.py for currently is programming our iCE40 FPGA target.
You can see example code for writing/reading over the SPI interface here:

Hi,
In SPI, both master and slave need to use the same clock polarity and clock phase. In the examples, I have no way of knowing the clock polarity and clock phase settings for the LatticeICE40. I check the user guide of LatticeICE40, it seems the clock polarity and clock phase depend on register values (but did not find register default value). How do I know what type of settings chipwhisperer uses?
Also, I would like to know what is the frequency range of SCK pin? I find that it seems a variable in the example.


Does it meens the range is 1E6~20E6?
Thank you for your reply!

ZT

ChipWhisperer is the SPI master, so it will drive the clock at what speed you tell it to, within limits: the SPI interface is driven by Husky’s SAM3U processor, so in theory the max clock rate is 96 MHz, and possible rates are 96 MHz divided by integers from 1 to 255, so 376e3 - 96e6. As per our source code comments we’ve gotten it to work at up to ~20 MHz (19.2 MHz to be exact since 96/20 is not an integer).

How you set up your target is up to you!

Here’s a simple example that shows configuring the SPI link and sending data:

import chipwhisperer as cw
from chipwhisperer.hardware.naeusb.spi import SPI
scope = cw.scope()
scope.default_setup()
spi = SPI(scope._getNAEUSB())
spi.enable(speed=10e6)
spi.transfer(range(128), writeonly=True)

Connect a logic analyzer and you’ll see:

1 Like

Thank tour for your reply!! This reply is easy to understand :grin:. I would like to ask if there are any similar pictures and code which is about the chipwhisperer reading data from slave. Thank you!
ZT

No unfortunately I don’t have a slave device available.

Roger that! Thank you for your reply! :blush: