Jump to content
  • 0

RichardV

Question

Hello, I am trying to avoid all of those SPI commands with higher level abstractions. The low-level example seems to help, but it is incomplete. It doesn't show how to setup or toggle the slave select lines. I presume this is done automatically, but I want manual control.

I cannot find information on MicroBlaze registers. For example, let's look at XSpi_SetSlaveSelect. This is all I could find: file:///C:/Xilinx/SDK/2016.2/data/embeddedsw/XilinxProcessorIPLib/drivers/spi_v4_2/doc/html/api/group__spi__v4__1.html#ga162523a3e9b29f063701db303ac8cf17 . It's not very clear, or correct. Let me explain.

 

I only have one slave: here is my constraint file for the SPI signals:

set_property -dict { PACKAGE_PIN G17   IOSTANDARD LVCMOS33 } [get_ports { spi_0_ss_io[0]      }]; #CS   #IO_L5N_T0_D07_14 Sch=ja[1]
set_property -dict { PACKAGE_PIN G19   IOSTANDARD LVCMOS33 } [get_ports { spi_0_io0_io        }]; #MOSI #IO_L4N_T0_D05_14 Sch=ja[2]
set_property -dict { PACKAGE_PIN N18   IOSTANDARD LVCMOS33 } [get_ports { spi_0_io1_io        }]; #MISO #IO_L9P_T1_DQS_14 Sch=ja[3]
set_property -dict { PACKAGE_PIN L18   IOSTANDARD LVCMOS33 } [get_ports { spi_0_sck_io        }]; #SCK  #IO_L8P_T1_D11_14 Sch=ja[4]

I am using the CMOD-A7 module.These are pins on the PMOD connector.

 

My slave select is on JA-1, as you can see. Let me demonstrate with a code snippet:

while(1) {

XSpi_SetSlaveSelect  ( XPAR_SPI_0_BASEADDR, (u32)0x01); // This should have set my SS[0] pin to 1. It doesn't.

wait a time delay

XSpi_SetSlaveSelect  ( XPAR_SPI_0_BASEADDR, (u32)0x00); // This should have set my SS[0] pin to 0. It's always 0, so I don't know if this worked or not.

wait a time delay

}

This should just toggle the pin, but it doesn't. Can someone please provide a simple SPI example that is only 1 level deep (in file hierarchy)?

Please include example that sets up the SPI to use the correct slave pin, and then toggles it.

I included my main project file. This was originally from the Polled SPI example project, "xspi_polled_example.c", so everything else was generated by SDK. If you create a basic project with an SPI port, then you can just replace the contents of that file with that of this file and it will compile.

 

Thank you, Richard V

Temp.c

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

Hello!

I don't know the answer to your question at all, but if it's an option to you, it seems like a microcontroller based solution will be a lot easier to work with in terms of bit-banging SPI rather than working with Xilinx SDK which inherently has to use high level abstractions to control and rewrite the FPGA fabric to have it perform as you want it to. I'm guessing Digilent didn't create the SPI IP or the Microblaze, so I'm not sure anybody here on the forum could give you the internal details on how the IP works at a low level or what specific commands it uses; you'd probably have to ask on the Xilinx Forums for that since Xilinx made the IP.

I'm sorry that I don't really have anything useful to offer you otherwise though.

~Natsu

Link to comment
Share on other sites

Hello Natsu. I agree that it's not a good idea to big-bang the SPI port. I'm just trying to set the initial conditions. I plan on using regular SPI commands afterwards.

I'm mostly trying to verify if I'm actually writing to an SPI port. This is my first time using a SPI device. I'm new to Vivado and SDK, but I have worked with microcontrollers in the past. It's a bit harder with an FPGA and MicroBlaze, but I know the challenge is worth it.

Thank you, Richard V

Link to comment
Share on other sites

@RichardV

After skimming the documentation that Jon linked, it looks like manual control of the slave select is done through the SPI control register (see Table 2-5 on Page 26). I haven't attempted to control this IP directly (always through Xilinx's drivers) so I can't attest to how easy this will be to accomplish. My uninformed guess is that you will likely need to copy the xspi drivers into your project (don't forget to rename the files!) and edit the transfer function or others as appropriate in order to assume direct control of the slave select, likely through Xil_Out32.

Let us know how this goes!

Arthur

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...