Page 2 of 2
Re: ICU driver and 32 bits timer
Posted: Thu Apr 30, 2020 1:17 am
by FXCoder
Hi Giovanni.
BTW for ARR handling the new ICU checks for zero since zero is invalid (stops timer) and users are likely to set zero expecting that to work as a normal full count overflow.
So in the case where .arr is 0 the driver will set 0xFFFF or 0xFFFFFFFF depending on TIM size (yes it a not necessary to differentiate but done anyway).
Otherwise the driver uses the value in config which then sets the configurable ICU wrap around count.
--
Bob
Re: ICU driver and 32 bits timer
Posted: Thu Apr 30, 2020 5:49 am
by FXCoder
An issue... if a configurable ARR is allowed then the scaling will need to be re-worked to handle variable sized overflow (currently just works on halfword, word, doubleword overflow).
Re: ICU driver and 32 bits timer
Posted: Thu Apr 30, 2020 6:12 am
by Giovanni
I will keep this on hold then, I need to proceed with releases.
Giovanni
Re: ICU driver and 32 bits timer
Posted: Thu Apr 30, 2020 6:25 am
by FXCoder
OK.
Thinking this over perhaps best to just remove .arr from the config and with the new driver just eliminate the setting of ARR to anything other than full count.
Anyway lets deal with the new driver in the next trunk iteration.
For the immediate release would be better to just set ARR = 0xFFFFFFFF in the current driver and remove the .arr from config.
Right now setting .arr will require existing projects to have updated config.
Re: ICU driver and 32 bits timer
Posted: Thu Apr 30, 2020 8:19 am
by alex31
Being able to set .arr is really handy, I and people of my team had take habit to set ARR after icuStart, so having .arr in the config would be a plus (your zero value of .arr handling is a good idea).
Nevertheless, if .arr is not in the config, that will not stop user to set ARR, and this should not trig buggy behavior in the ICU driver.
Alexandre
Re: ICU driver and 32 bits timer
Posted: Thu Apr 30, 2020 8:43 am
by Giovanni
Hi,
I think there is an use case for ARR setup, I added a check on zero (it becomes 0xFFFFFFFF) and fixed that typo.
Giovanni
Re: ICU driver and 32 bits timer
Posted: Thu Apr 30, 2020 2:16 pm
by FXCoder
OK.
I'll rethink the ICU driver overflow handling and factor in the variable ARR.
--
Bob
Re: ICU driver and 32 bits timer
Posted: Thu Aug 13, 2020 6:37 am
by FXCoder
Hi.
Here is the simple change in hal_icu.h to enable ICU scaling by using the overflow callback.
The overflow scaling is only available where a callback is set.
The callback is not called until edge sync is obtained.
If there is concern over legacy behavior a #define could be added (e.g.) #I2C_USE_OVERFLOW_SCALING with guard !defined(...) to FALSE.
--
Bob
Code: Select all
/**
* @brief Common ISR code, ICU timer overflow event.
* @note An overflow interrupt without a callback brings the driver
* back to the @p ICU_WAITING state.
*
* @param[in] icup pointer to the @p ICUDriver object
*
* @notapi
*/
#define _icu_isr_invoke_overflow_cb(icup) do { \
if ((icup)->config->overflow_cb != NULL && (icup)->state == ICU_ACTIVE) \
(icup)->config->overflow_cb(icup); \
else { \
(icup)->state = ICU_WAITING; \
} \
} while (0)