Hi, I want to replace the waiting while loops in the ss_init_run function found in the single-sided ranging code on github with semaphore give and take statements implemented by freeRTOS. I am essentially replacing the tx_int_flag, rx_int_flag, to_int_flag, and er_int flag within their respective callback functions with giving a semaphore, and in place of the while loop in the ranging code, using a semaphore take. Then, whenever the int_flags are changed back to 1 in the ranging code, I give them again when done. But when I run this code, the range measurements I get are huge, like instead of 100 units, I get 1000000 units of distance, and it isn’t any multiple of the correct distance as far as I can tell.
for example,
while (!(rx_int_flag || to_int_flag || er_int_flag))
gets replaced with
if (((xSemaphoreTake(rx_wait,10) == pdTRUE ) || (xSemaphoreTake(to_wait,10) == pdTRUE) || (xSemaphoreTake(err_wait,10) == pdTRUE)))
where the semaphores rx_wait, to_wait, and err_wait are given in their respective callback functions.
Any ideas as to why this does not give the correct measurement?