SPIM Fatal error

Hi,

   I'm using spim on nRF52810.After I init the spi driver and using APP_ERROR_CHECK(nrf_drv_spi_transfer(&spi, &Command, 1, m_rx_buf, 1)) ,  RTT Viewer showing FATAL ERROR.

I have enabled 

NRFX_SPIM_ENABLED  

NRFX_SPI_ENABLED 

SPI_ENABLED 

and added 

nrfx_spi.c

nrfx_spim.c

nrf_drv_spi.c

Parents
  • Hello,

    Please make sure to have DEBUG defined in your preprocessor defines, like shown in the included image:

    This will make your logger output a detailed error message whenever a non-NRF_SUCCESS error code is passed to an APP_ERROR_CHECK. Make sure to add this in the common configuration of the project.

    Try this, and let me know what this error message reads.

    Best regards,
    Karl

  • Thanks!

    I send a wrong type of the data, it doesn't happen now.

    But I cannot write or read data normally of CC1101, there is no problem of hardware beacause I can write the data normally by using SPI of software . 

    SPI software

    uint8_t CC1101_ReadWriteByte(uint8_t data)
    {
    	uint8_t i;
    	uint8_t temp = 0;
     
    	for(i = 0;i < 8;i ++)
    	{
    		if(data & 0x80)
    		{
    			CC1101_MOSI_H();
    		}
    		else
    		{
    			CC1101_MOSI_L();
    		}
    		data <<= 1;nrf_delay_us(10);
    		CC1101_SCLK_H();	      
    		temp <<= 1;nrf_delay_us(10);
    		if(CC1101_GetMISO()) temp ++;
    		CC1101_SCLK_L();	       
    	}
    	return temp;
    }
    uint8_t CC1101_Command(CC1101_CMD_TYPE Cmd)
    {
    	uint8_t status;
     
    	CC1101_CS_L();	                          
        while(CC1101_GetMISO());
    	status = CC1101_ReadWriteByte((uint8_t)Cmd);	   
        while(CC1101_GetMISO());
    	CC1101_CS_H();	                         
    	return status;
    }
    uint8_t CC1101_ReadReg(CC1101_REG_TYPE RegAddr)
    {
    	uint8_t data;
     
    	CC1101_CS_L();	                                
    	CC1101_ReadWriteByte((uint8_t)READ_SINGLE|RegAddr);	
    	data = CC1101_ReadWriteByte(0xff);				
    	CC1101_CS_H();	                             
    	return data;
    }
    uint8_t CC1101_WriteReg(CC1101_REG_TYPE RegAddr, uint8_t data)
    {
    	uint8_t status;
     
    	if(RegAddr > 0x80) return 0;		                        
    	CC1101_CS_L();	                                         
        while(CC1101_GetMISO());
    	status = CC1101_ReadWriteByte((uint8_t)WRITE_SINGLE|RegAddr);	
    	CC1101_ReadWriteByte(data);			                      
    	CC1101_CS_H();	                                         
    	return status;
    }

    SPI hardware

    void CC1101_Write_Cmd( uint8_t Command )
    {
    		spi_xfer_done = false;
    		CC1101_SET_CSN_LOW( );
    		APP_ERROR_CHECK(nrf_drv_spi_transfer(&spi, &Command, 1, NULL, 0));	
    		while (!spi_xfer_done)
    		{
    			__WFE();
    		}
    		CC1101_SET_CSN_HIGH( );
    }
    void CC1101_Write_Reg( uint8_t Addr, uint8_t WriteValue )
    {
    		spi_xfer_done = false;
    	
    		CC1101_SET_CSN_LOW( );
    		APP_ERROR_CHECK(nrf_drv_spi_transfer(&spi, &Addr, 1, NULL, 0));	
    		while (!spi_xfer_done)
    		{
    			__WFE();
    		}
    		spi_xfer_done = false;
    		APP_ERROR_CHECK(nrf_drv_spi_transfer(&spi, &WriteValue, 1, NULL, 0));	
    		while (!spi_xfer_done)
    		{
    			__WFE();
    		}
    		CC1101_SET_CSN_HIGH( );
    		
    }
    uint8_t CC1101_Read_Reg( uint8_t Addr )
    {
        uint8_t l_RegValue = 0;
    		uint8_t addr_single;
    		spi_xfer_done = false;
    		CC1101_SET_CSN_LOW( );
    		addr_single = Addr | READ_SINGLE;
    		APP_ERROR_CHECK(nrf_drv_spi_transfer(&spi, &addr_single, 1, &l_RegValue, 1));	
    		while (!spi_xfer_done)
    		{
    			__WFE();
    		}	
    		CC1101_SET_CSN_HIGH( );
        return l_RegValue;
    }

  • Hello again,

    Taylor said:
    I send a wrong type of the data, it doesn't happen now.

    I am glad to hear that you were able to resolve the initial issue.

    Taylor said:
    But I cannot write or read data normally of CC1101, there is no problem of hardware beacause I can write the data normally by using SPI of software . 

    Could you elaborate on what you mean by this? It seems that you are calling the SPI driver 'spi hardware', so I am not certain that I understand what you are trying to say.
    Does the writes and read succeed when you are using the nrfx SPIM driver, but not when you use the one you have implemented yourself?
    If so, what do you observe when you attempt to use your own driver, how does it fail? Could you also tell me why would you like to use your own implementation in favor of the nrfx SPIM driver, is there a particular concern or reason for this?

    Best regards,
    Karl

Reply
  • Hello again,

    Taylor said:
    I send a wrong type of the data, it doesn't happen now.

    I am glad to hear that you were able to resolve the initial issue.

    Taylor said:
    But I cannot write or read data normally of CC1101, there is no problem of hardware beacause I can write the data normally by using SPI of software . 

    Could you elaborate on what you mean by this? It seems that you are calling the SPI driver 'spi hardware', so I am not certain that I understand what you are trying to say.
    Does the writes and read succeed when you are using the nrfx SPIM driver, but not when you use the one you have implemented yourself?
    If so, what do you observe when you attempt to use your own driver, how does it fail? Could you also tell me why would you like to use your own implementation in favor of the nrfx SPIM driver, is there a particular concern or reason for this?

    Best regards,
    Karl

Children
Related