nikk Posted November 29, 2022 Share Posted November 29, 2022 (edited) Trying to test SPI on J6 with the simple program: #include "xspi.h" #include "xparameters.h" #include "xil_printf.h" #include "sleep.h" int main() { xil_printf("Hello World!\r\n"); static XSpi device; XSpi_Config *pcfg; int status; pcfg = XSpi_LookupConfig(XPAR_SPI_0_DEVICE_ID); xil_printf("Spi_LookupConfig = %d\r\n", pcfg); status = XSpi_CfgInitialize(&device, pcfg, pcfg->BaseAddress); xil_printf("XSpi_CfgInitialize = %d\r\n", status); status = XSpi_SetOptions(&device, XSP_MASTER_OPTION | XSP_MANUAL_SSELECT_OPTION); xil_printf("XSpi_SetOptions = %d\r\n", status); status = XSpi_Start(&device); xil_printf("XSpi_Start = %d\r\n", status); XSpi_IntrGlobalDisable(&device); xil_printf("XSpi_IntrGlobalDisable = %d\r\n", status); status = XSpi_SetSlaveSelect(&device, 0b1); xil_printf("XSpi_SetSlaveSelect = %d\r\n", status); u8 bytes [4] = {0x01,0x02,0x03,0x04}; xil_printf("Before loop starts\r\n"); while (1) { xil_printf("loop...\r\n"); status = XSpi_Transfer(&device, bytes, NULL, 4); xil_printf("XSpi_Transfer = %d\r\n",status); usleep(1); } } Output: Hello World! Spi_LookupConfig = 9300 XSpi_CfgInitialize = 0 XSpi_SetOptions = 0 XSpi_Start = 0 XSpi_IntrGlobalDisable = 0 XSpi_SetSlaveSelect = 0 Before loop starts loop... on attached screenshot I see only two bytes are sent out and that is it, why? Edited November 29, 2022 by nikk Link to comment Share on other sites More sharing options...
0 artvvb Posted December 1, 2022 Share Posted December 1, 2022 Hi @nikk Based on the name of the IP in the block design, I would expect the Quad SPI's device ID xparameters macro to be XPAR_AXI_QUAD_SPI_0_DEVICE_ID, but I could be wrong. Where are you pulling XPAR_SPI_0_DEVICE_ID from? Have you tried stepping through the XSpi_Transfer function in the debugger to see where exactly it is getting stuck? Thanks, Arthur Link to comment Share on other sites More sharing options...
Question
nikk
Trying to test SPI on J6 with the simple program:
#include "xspi.h" #include "xparameters.h" #include "xil_printf.h" #include "sleep.h" int main() { xil_printf("Hello World!\r\n"); static XSpi device; XSpi_Config *pcfg; int status; pcfg = XSpi_LookupConfig(XPAR_SPI_0_DEVICE_ID); xil_printf("Spi_LookupConfig = %d\r\n", pcfg); status = XSpi_CfgInitialize(&device, pcfg, pcfg->BaseAddress); xil_printf("XSpi_CfgInitialize = %d\r\n", status); status = XSpi_SetOptions(&device, XSP_MASTER_OPTION | XSP_MANUAL_SSELECT_OPTION); xil_printf("XSpi_SetOptions = %d\r\n", status); status = XSpi_Start(&device); xil_printf("XSpi_Start = %d\r\n", status); XSpi_IntrGlobalDisable(&device); xil_printf("XSpi_IntrGlobalDisable = %d\r\n", status); status = XSpi_SetSlaveSelect(&device, 0b1); xil_printf("XSpi_SetSlaveSelect = %d\r\n", status); u8 bytes [4] = {0x01,0x02,0x03,0x04}; xil_printf("Before loop starts\r\n"); while (1) { xil_printf("loop...\r\n"); status = XSpi_Transfer(&device, bytes, NULL, 4); xil_printf("XSpi_Transfer = %d\r\n",status); usleep(1); } }
Output:
Hello World! Spi_LookupConfig = 9300 XSpi_CfgInitialize = 0 XSpi_SetOptions = 0 XSpi_Start = 0 XSpi_IntrGlobalDisable = 0 XSpi_SetSlaveSelect = 0 Before loop starts loop...
on attached screenshot I see only two bytes are sent out and that is it, why?
Edited by nikk
Link to comment
Share on other sites
1 answer to this question
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now