Use single periodic callback if possible
The problem with multiple callbacks is that the higher rate can interrupt a lower rate callback.
x
1
int number = 0;
2
3
void periodic_callback_10hz(uint32_t count) {
4
number++;
5
}
6
7
// This can interrupt the 10hz in the middle of its operations
8
void periodic_callback_100hz(uint32_t count) {
9
number++;
10
}
Use this instead:
14
1
int number = 0;
2
3
void periodic_callback_10hz(uint32_t count) {
4
//number++;
5
}
6
7
// This can interrupt the 10hz in the middle of its operations
8
void periodic_callback_100hz(uint32_t count) {
9
if (0 == (count % 10)) {
10
number++;
11
}
12
13
number++;
14
}