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 Reply
  • Hi Hmolesworth,

    Thanks for your time to give it a look. I have tried using P0.13 from nRF52840 as normal GPIO, and I was able to control the state of the pin, i.e., toggle the pin after some time. So, that's why I am sure about pin P0.13 and on top of that I tested with multimeter there is a connection from M2 connector pin(the pin which is connected to nRF52840 P0.13 pin on the LN60E840E module) to the connector header on the dev kit. 

    Regards,

    Shivek

Children
No Data
Related