Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs

SPIM3 not work standalone.

nRF52804 SPIM3 not work.
(SCLK/MOSI not output)

However, if I debug it using jlink, it works. 

My environment is
nRF52840-DK(PCA10056/v1.0.0)
nRF52 SDK 17.0.2

My program is

	/* SCK */
	nrf_gpio_pin_clear(SPIM_CLK_PIN);
	nrf_gpio_cfg(SPIM_CLK_PIN,
						NRF_GPIO_PIN_DIR_OUTPUT,
						NRF_GPIO_PIN_INPUT_CONNECT,
						NRF_GPIO_PIN_NOPULL,
						NRF_GPIO_PIN_S0S1,
						NRF_GPIO_PIN_NOSENSE);
	/* MOSI */
	nrf_gpio_pin_clear(SPIM_MOSI_PIN);
	nrf_gpio_cfg_output(SPIM_MOSI_PIN);
	/* MISO */
	nrf_gpio_cfg_input(SPIM_MISO_PIN, (nrf_gpio_pin_pull_t)NRFX_SPIM_MISO_PULL_CFG);
	/* SS */
	nrf_gpio_pin_set(SPIM_SS_PIN);
	nrf_gpio_cfg_output(SPIM_SS_PIN);

	/**/
    NRFX_IRQ_DISABLE(TARGET_SPIM_IRQ);
	SpimReg.ENABLE = SPIM_ENABLE_ENABLE_Enabled << SPIM_ENABLE_ENABLE_Pos;
	SpimReg.TASKS_STOP = 1;
	SpimReg.PSEL.SCK = SPIM_CLK_PIN;
	SpimReg.PSEL.MOSI = SPIM_MOSI_PIN;
	SpimReg.PSEL.MISO = SPIM_MISO_PIN;
	SpimReg.FREQUENCY = SPIM_FREQUENCY_FREQUENCY_K125;
	SpimReg.RXD.PTR = uint32_t(m_recv_buff),
	SpimReg.RXD.MAXCNT = 2;
	SpimReg.RXD.LIST = 0;
	SpimReg.TXD.PTR = uint32_t(m_send_buff),
	SpimReg.TXD.MAXCNT = 2;
	SpimReg.TXD.LIST = 0;
	SpimReg.CONFIG = 0; /* active-high / Leading / MsbFirst */
	SpimReg.ORC = 0x00;
	
	SpimReg.EVENTS_END = 0;
	SpimReg.TASKS_START = 1;
	while ( SpimReg.EVENTS_END == 0);

EVENT_END is done.(Maybe the process is finished )
But SCLK and MOSI not output.

Parents
  • In the debug mode the high speed clocks are forced and kept ON by the debugger. When you say that it seems to work with debugger only, the first suspect we should check are how you are managing the SPI peripheral clocks? In you code it does not look like you have initialized or used any nrfx spi drivers so probably you need to start the clocks manually if you are not using any drivers from the sdk. Can you give me your whole init file so that i can see how you are initializing the whole thing?

Reply
  • In the debug mode the high speed clocks are forced and kept ON by the debugger. When you say that it seems to work with debugger only, the first suspect we should check are how you are managing the SPI peripheral clocks? In you code it does not look like you have initialized or used any nrfx spi drivers so probably you need to start the clocks manually if you are not using any drivers from the sdk. Can you give me your whole init file so that i can see how you are initializing the whole thing?

Children
Related