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

SPI Prbolem , Clock dosen't work

Why the SPI clk doesn't work, i checked using an oscilloscope :/ I also don't get any SPI interrupt and no data change in the RX buffer although I have wired MISO and MOSI

void vSensor_eInitSensor_Exe()
{
   /*Config SPI PINs*/
	  nrf_gpio_pin_set(SCLK_PIN); /*Initial state of CLK is High*/

      NRF_GPIO->PIN_CNF[SCLK_PIN] =
    (GPIO_PIN_CNF_DIR_Output        << GPIO_PIN_CNF_DIR_Pos)
  | (GPIO_PIN_CNF_INPUT_Connect     << GPIO_PIN_CNF_INPUT_Pos)
  | (GPIO_PIN_CNF_PULL_Disabled     << GPIO_PIN_CNF_PULL_Pos)
  | (GPIO_PIN_CNF_DRIVE_S0S1        << GPIO_PIN_CNF_DRIVE_Pos)
  | (GPIO_PIN_CNF_SENSE_Disabled    << GPIO_PIN_CNF_SENSE_Pos);
  // - MOSI (optional) - output with initial value 0,
      nrf_gpio_pin_clear(MOSI_PIN);
    nrf_gpio_cfg_output(MOSI_PIN);
  /* - MISO (mandatory) - input*/
  nrf_gpio_cfg_input(MISO_PIN, NRF_GPIO_PIN_NOPULL);
  /*Init SPI*/
  nrf_spim_pins_set(&stSPI_iNRF_SPI_Type,(uint32_t )SCLK_PIN, MOSI_PIN,(uint32_t )MISO_PIN);
  nrf_spim_frequency_set(&stSPI_iNRF_SPI_Type,NRF_SPIM_FREQ_125K);
  nrf_spim_configure(&stSPI_iNRF_SPI_Type,NRF_SPIM_MODE_0,CstSPI_iNrfSpiBitOrder);
  nrf_spim_rx_buffer_set(&stSPI_iNRF_SPI_Type,ui8RxBuffer,SPI_RX_BYTES_NB);
  nrf_spim_tx_buffer_set(&stSPI_iNRF_SPI_Type,ui8TxBuffer/*NULL*/,SPI_RX_BYTES_NB);
  nrf_spim_int_enable(&stSPI_iNRF_SPI_Type,NRF_SPIM_INT_STOPPED_MASK|NRF_SPIM_INT_ENDRX_MASK|NRF_SPIM_INT_STARTED_MASK); /*get events when RX done*/
  nrf_spim_enable(&stSPI_iNRF_SPI_Type);
  nrf_drv_common_irq_enable(SPIM_IRQ ,SPIM_CONFIG_IRQ_PRIORITY); /*enable SPI0 interrupt */
	stSPI_iNRF_SPI_Type.POWER=1;
 /*Create Periodic task for reading*/ 
  vSensor_iCreateReadingTask_Exe();
}

Here is the periodic task of reading

static void vSensor_iPeriodicReadHandler_Exe(void * p_context)
{
	 if(false==nrf_drv_gpiote_in_is_set(MISO_PIN))
	 { 
		 /*Clear interrupt flags & Lunch read transaction*/
		 nrf_spim_event_clear(&stSPI_iNRF_SPI_Type,NRF_SPIM_EVENT_ENDRX);
		 nrf_spim_task_trigger(&stSPI_iNRF_SPI_Type,NRF_SPIM_TASK_START);
		 app_timer_start(m_conversion_read_timer_id, PERIODIC_READING_INTERVAL, NULL);
	 }
	 else
	 {
		 /*empty else*/
	 }
	 
}
Parents
  • Look waht I did : I am using the ble_app_hrs and I want to integrate SPI part. I took it from the project SPI in the examples. I just did my driver layer,, what I attached in the question it dosen't work. Now I used the driver elaborated by Nordic but dosen't work and I discovered that is related to bsp_btn config. I deleted this function and it works :

    //    bsp_btn_ble_on_ble_evt(p_ble_evt);
    

    Now after i discovered the source of the problem , I take back my driver layer,, which is the code i attached in the question and it dosen't work :/

Reply
  • Look waht I did : I am using the ble_app_hrs and I want to integrate SPI part. I took it from the project SPI in the examples. I just did my driver layer,, what I attached in the question it dosen't work. Now I used the driver elaborated by Nordic but dosen't work and I discovered that is related to bsp_btn config. I deleted this function and it works :

    //    bsp_btn_ble_on_ble_evt(p_ble_evt);
    

    Now after i discovered the source of the problem , I take back my driver layer,, which is the code i attached in the question and it dosen't work :/

Children
No Data
Related