AnsweredAssumed Answered

KL16 SPI Issue

Question asked by ren suiyi on Oct 10, 2016
Latest reply on Oct 10, 2016 by Kerry Zhou

my code :

I just want to use spi without interrupt and dma.I can not recieve the data and stucked.

Is the spi configured ok?

 

 gpio_pin_config_t pin_cfg;
    spi_master_config_t spi_config;
    uint32_t sourceclock;
    //config the spi
    
    SPI_MasterGetDefaultConfig(&spi_config);
    sourceclock = CLOCK_GetBusClkFreq();
    spi_config.outputMode = kSPI_SlaveSelectAsGpio;
    SPI_MasterInit(SPI1,&spi_config,sourceclock);
    SPI_EnableFIFO(SPI1,false);

 

    //config the cs pin
    pin_cfg.pinDirection = kGPIO_DigitalOutput;
    pin_cfg.outputLogic = 1;
    GPIO_PinInit(GPIOD,4U,&pin_cfg);
    
    
    while(1){
            SPI_WriteData(SPI1, 0x01);
            while (0==(kSPI_RxBufferFullFlag&SPI_GetStatusFlags(SPI1)));  //stop here ,never continue!!
    }

Outcomes