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

how to read samples while performing a long time consuming process without rtos ?

Hi,

I am reading some sensor data based on interrupt and i am string the data after read "n" bytes.

my store function takes around 300-400 ms but i have to  read samples every 30 ms (when interrupt comes). 

code hangs if i read data from inside the interrupt handler. 

my code looks like this

void intrhandler(){

    read_flag = true;
}

main_loop(){
  if(read_flag){
    read_samples();

    if(number_of_samples > threshold){
      store_data_to_flash();    //takes ~ 300ms
    }
  }
}

My sensor is based on SPI, does adding ppi would solve this issue ?

what is the best way to read samples without data loss?

Related