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

I can not communicate at 1000 Hz with SPI communication

Hi,

I am using nRF_SDK_15.0.0_a53641 and writing a program with keil.

I am now trying to write to the SD card at 1000 Hz (1 ms) by combining "fatfs example" and "app timer example".

However, communication is possible only at about 10 Hz.
Is there any cause?

const nrf_drv_timer_t TIMER_TWI = NRF_DRV_TIMER_INSTANCE(0);

/**
 * @brief Handler for timer events.
 */
void timer_twi_event_handler(nrf_timer_event_t event_type, void* p_context)
{

    switch (event_type)
    {
        case NRF_TIMER_EVENT_COMPARE0:
					
        
				flag = true;
					
            break;

        default:
            //Do nothing.
            break;
    }
}


/*************************************************************************************
 * main 
 *@brief Function for main application entry.
 *************************************************************************************/

int main(void)
{
    float time = 0.000;
	float t = 0.001;
	uint32_t time_ms = 1; //Time(in miliseconds) between consecutive compare events.
	uint32_t time_ticks;
	uint32_t err_code = NRF_SUCCESS;

	//SPI start condition
	SPI_start();
	
		
    bsp_board_init(BSP_INIT_LEDS);
	
	
    APP_ERROR_CHECK(NRF_LOG_INIT(NULL));
    NRF_LOG_DEFAULT_BACKENDS_INIT();

    NRF_LOG_INFO("FATFS example started.");
	
	//Configure TIMER_LED for generating simple light effect - leds on board will invert his state one after the other.
    nrf_drv_timer_config_t timer_cfg = NRF_DRV_TIMER_DEFAULT_CONFIG;
    err_code = nrf_drv_timer_init(&TIMER_TWI, &timer_cfg, timer_twi_event_handler);
    APP_ERROR_CHECK(err_code);

    time_ticks = nrf_drv_timer_ms_to_ticks(&TIMER_TWI, time_ms);

    nrf_drv_timer_extended_compare(
         &TIMER_TWI, NRF_TIMER_CC_CHANNEL0, time_ticks, NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK, true);

    nrf_drv_timer_enable(&TIMER_TWI);
		

    while (1)
    {
	    if(flag == true){
            fatfs_example(time);
		    flag = false;
	    }

    }
		
}

/** @} */

Related