Freertos Application Design Flow

Hi,
I want to use freertos in my application. The application is to read 50 analog sensors from ADCs for every 1 minute and store the data in flash memory. Later, the data has to be sent to a bluetooth device over UART.

How this can be done using freertos? Can any one frame an idea using freertos apis.

Thanks and Regards,
Kumar

If I understand correctly, you want to read 50 separate analog channels once a minute. Can you read one after the other, or do you need to have all 50 analog conversions start at the same time? If you can read one after the other there should be no problem reading all 50 within a minute so you can probably do something very simple such as:

#define NUMBER_OF_SENSORS 50
void ADCTask( void *pvParameters )
{
TickType_t xNextWakeTime;
int32_t i;
int16_t Readings[ NUMBER_OF_SENSORS ];

const TickType_t xCycleFrequency = pdMS_TO_TICKS( 60000UL ); //60000ms == 1m

    /* Initialise xNextWakeTime - this only needs to be done once. */
    xNextWakeTime = xTaskGetTickCount();

    for( ;; )
    {
        /* Place this task in the blocked state until it is time to run again. */
        vTaskDelayUntil( &xNextWakeTime, xCycleFrequency );
        
        for( i = 0; i < NUMBER_OF_SENSORS; i++ )
        {
            Readings[ i ] = ReadADCSensor[ i ];
        }
    
        /* Use whatever driver your hardware vendor provides for this part. */
        StoreReadingsToFlash( Readings );
    }
}

Of course you don’t say what else your application needs to do at the same time.

Do you have BLE working already?

Hi Richard,

Thank you for the idea. What if I want to read the data simultaneously. I have 5 adcs each adc is having 10 channels. Theybare configured in spi mode.

My application has to read all the channels simultaneously and send that data to Bluetooth. My bluetooth is working and it is receiving data.

The read loop Richard proposed reads all sensors at once.

and besides storing them (for logging purposes ?) you can send it via BLE. The interval of 1 minute should be more than enough time to do so before the next cycle starts.
A SPI-ADC is read one channel after another. IIRC some support an optimized protocol to minimize the SPI traffic by telling the next channel to read when reading a channel.
See the data sheet of the ADC for details.