UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Observer creative1
Observer
567 Views
Registered: ‎04-05-2018

SPI Device Always Busy

 Hello,

I have an issue with SPI on Zybo Z7-20 board. I have configured PS and enabled SPI 1 block in it, which is connected to MIO pins.

Self test works fine but when i transfer data continuously with delay in loop, i always get XST_DEVICE_BUSY . Why is it so? I have included the code below,

 

#include <stdio.h>
#include "platform.h"
#include "xil_printf.h"
#include "xspips.h"
#include "xparameters.h"

 

    int main()
      {
            init_platform();

            print("Hello World\n\r");
            XSpiPs spi1;
            XSpiPs_Config *spi1_config;
            s32 status;

            u8 data[2]={0x55,0xaa};


            spi1_config=XSpiPs_LookupConfig(XPAR_PS7_SPI_1_DEVICE_ID);

            status=XSpiPs_CfgInitialize(&spi1, spi1_config,spi1_config->BaseAddress);
            if(status==0)
                {
                   print("success_inital");
                }
           else
              {
                  print("Error_init");
              }


          status= XSpiPs_SetOptions(&spi1,XSPIPS_MASTER_OPTION| XSPIPS_CLK_ACTIVE_LOW_OPTION |                 XSPIPS_CLK_PHASE_1_OPTION|XSPIPS_FORCE_SSELECT_OPTION);

          if(status==0)
             {
                print("success_assign");
             }
         else
         {
           print("error_assign");
         }

        XSpiPs_SetClkPrescaler(&spi1, XSPIPS_CLK_PRESCALE_8);
        XSpiPs_Enable(&spi1);
        status=XSpiPs_SelfTest(&spi1);

        if(status==0)
           {
              print("test");
           }
       else
         {
             print("error");

         }


        while(1)
        {

           XSpiPs_SetSlaveSelect(&spi1,0x00);
           status=XSpiPs_Transfer(&spi1, data, NULL, 2);

           if(status==0)
              {
                  print("succes");
              }
           else
            {
                print("Device Busy");

            }

          for(status=0;status<=900000;status++)
            {
            }

         
            }


       cleanup_platform();
      return 0;
}

0 Kudos
1 Reply
Observer creative1
Observer
531 Views
Registered: ‎04-05-2018

Re: SPI Device Always Busy

To add on the above post,when i connect the MOSI,SS and SCLK signal to CRO, i could only see SS signal coming down. 

Sclk remains at zero.

hope it could help to identify something wrong in my code.

 

Thanks.

0 Kudos