Running a Thread at 400Hz for sampling
Posted: Tue Jul 19, 2016 9:07 am
Im currently trying to get a thread to loop at 400Hz (need to sample at this frequency).
chconf is currently setup like this.
so the system tick only has a granularity of 1ms, and thus closest i can get to 400Hz is when using chThdSleepMilliseconds( 2 );
What is teh best way to achieve this ? can one just adjust the CH_CFG_ST_FREQUENCY to say 10000, this will give more granularity, and thus allow to achieve 400Hz ?
chconf is currently setup like this.
Code: Select all
/**
* @brief System time counter resolution.
* @note Allowed values are 16 or 32 bits.
*/
#define CH_CFG_ST_RESOLUTION 32//16
/**
* @brief System tick frequency.
* @details Frequency of the system timer that drives the system ticks. This
* setting also defines the system tick time unit.
*/
#define CH_CFG_ST_FREQUENCY 1000
/**
* @brief Time delta constant for the tick-less mode.
* @note If this value is zero then the system uses the classic
* periodic tick. This value represents the minimum number
* of ticks that is safe to specify in a timeout directive.
* The value one is not valid, timeouts are rounded up to
* this value.
*/
#define CH_CFG_ST_TIMEDELTA 0//2
so the system tick only has a granularity of 1ms, and thus closest i can get to 400Hz is when using chThdSleepMilliseconds( 2 );
What is teh best way to achieve this ? can one just adjust the CH_CFG_ST_FREQUENCY to say 10000, this will give more granularity, and thus allow to achieve 400Hz ?