This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

SPI clock pin configuration for nRF52840.

Hi,

I am using nRF52840 on custom board. I am trying to configure SPI pins, but I am not getting anything on the clock pin. I can see the chip select pin going low and high which is good. But there is no clock on the pin. Following is the code snippet from my project.

#define MEM_CS                           NRF_GPIO_PIN_MAP(0,4)
#define MEM_SI                           NRF_GPIO_PIN_MAP(0,7)
#define MEM_SO                           NRF_GPIO_PIN_MAP(1,8)
#define MEM_SCK                          NRF_GPIO_PIN_MAP(0,13)

void memInit(void)
{
	    //GPIO configuration
        nrf_gpio_cfg_output(MEM_CS);
        nrf_gpio_cfg_output(MEM_SI);
        nrf_gpio_cfg_output(MEM_SCK);
        nrf_gpio_cfg_input(MEM_SO, GPIO_PIN_CNF_PULL_Pulldown);

                
        //SPI configuration
        nrf_drv_spi_config_t spi_config = NRF_DRV_SPI_DEFAULT_CONFIG;
        spi_config.ss_pin    = MEM_CS;
        spi_config.miso_pin  = MEM_SO;
        spi_config.mosi_pin  = MEM_SI;
        spi_config.sck_pin   = MEM_SCK;
        spi_config.bit_order = NRF_SPI_BIT_ORDER_MSB_FIRST;
        spi_config.frequency = NRF_SPI_FREQ_250K;
        spi_config.mode      = NRF_SPI_MODE_2;
        
        nrf_drv_spi_init(&spi, &spi_config, spi_event_handler, NULL);

}

uint32_t memId()
{
        __disable_irq();
        
        nrf_gpio_pin_clear(MEM_CS);         //Pin goes low now

        err  = nrf_drv_spi_transfer(&spi, p_tx_buffer, sizeof(tx_buffer), NULL, 0);  
        nrf_delay_ms(100);
        
        nrf_gpio_pin_set(MEM_CS);           //Pin goes high now

	    __enable_irq();
        return err;
}

For my custom board configuration I have set Preprocessor definitions to BOARD_CUSTOM. But for simplicity, I have defined the pins in the source code file. I am thinking to test it first and then I can define the pins for SPI in custom_board.h. On the custom board I have checked for the pins they are not connected to any other peripheral. 

For development, I am using SES with nRF SDK15.0.0 and Softdevice S140. 

Any insight would be appreciated.

Thanks!

Parents
  • Hi Einar,

    So you should at least remove the call to __disable_irq().

    I tried removing the line __disable_irq(). But it didn't help. I am still not able to see the clock on the pin. I tried the code with the board supplied by Fanstel. I have attached the document from them which has the schematic for the dev kit I am using. I will really appreciate if you can have a look on the document and let me know if there is anything I am doing wrong with the pin selection for the purpose.

    M2_LN60E40F+Product+Specifications.pdf

    The LN60E40F is a module based on nRF9160 and nRF52840. For the schematic you can go to the page no. 25 of this document. The schematic is not having good resolution and that is frustrating for me as well. 

    Thank you for your efforts.

    Regards,

    Shivek

Reply
  • Hi Einar,

    So you should at least remove the call to __disable_irq().

    I tried removing the line __disable_irq(). But it didn't help. I am still not able to see the clock on the pin. I tried the code with the board supplied by Fanstel. I have attached the document from them which has the schematic for the dev kit I am using. I will really appreciate if you can have a look on the document and let me know if there is anything I am doing wrong with the pin selection for the purpose.

    M2_LN60E40F+Product+Specifications.pdf

    The LN60E40F is a module based on nRF9160 and nRF52840. For the schematic you can go to the page no. 25 of this document. The schematic is not having good resolution and that is frustrating for me as well. 

    Thank you for your efforts.

    Regards,

    Shivek

Children
Related