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

strange behaviour of spi handler

Hi,

I'm using the SDK11 and SD130 on a custom board which has a nrf51822. I connected via SPI to a DSP that sends and receive audio. My handler of the SPI is as it follows

/**********************************
 * @brief SPI user event handler  *
 * @param event										*
 **********************************/
 void spi_event_handler(nrf_drv_spi_evt_t const * p_event)
 {
	 nrf_gpio_pin_toggle(WAKEUP_PIN);
	 uint8_t i = 0;
	 
	 NRF_LOG_PRINTF("[MAIN : SPI] Transfered : %s\r\n", spi_tx_buf);
	 memset(spi_tx_buf, 0, spi_length);
	 NRF_LOG_PRINTF("[MAIN : SPI] Received: %s\r\n", spi_rx_buf);
	 memcpy(spi_tx_buf, spi_rx_buf, spi_length);
	 if(spi_counter < ble_length)
	 {
			while(i < spi_length)
			{
				buffer_send_ble[i+spi_counter] = spi_rx_buf[i];
				i++;
			}
			spi_counter = spi_counter + i;
	 }
	 if(spi_counter>=ble_length)	//if there is no more
	 {
		 spi_counter = 0;
			#ifdef OVERBLE
				BLE_flag = true;	
			#endif	 
	 }
		 
 }

So as you can see I'm copying the data from the spi_rx to spi_tx. and then do another spi transfer on the main. The problem is that I only have clear sound when I have the NRF_LOG_PRINTF, if I comment one or both the sound just get worse.

Is this a meant thing? does it need a delay or something? I can't understand why it only works if I have them.

Thank you for the help,

Jorge Costa

Parents Reply Children
No Data
Related