Question about the ICU module

Discussions and support about ChibiOS/HAL, the MCU Hardware Abstraction Layer.
orion
Posts: 17
Joined: Sun Nov 12, 2017 7:56 pm
Has thanked: 4 times
Been thanked: 3 times

Question about the ICU module

Postby orion » Sat Nov 18, 2017 2:39 pm

I have a question on the ICU module. In its documentation page there is a figure depicting its state machine which doesn't show the icuEnableNotifications() and icuDisableNotifications() functions. The documentation for these functions doesn't say much either, only that the function enables or disables notifications (which I assume are the calling of the callback functions). My question then is whether these functions changes the current state (ICU_WAITING, ICU_ACTIVE, etc) of the module or not. I guess if they don't change the state they merely suppress the calling of callback functions but continue to keep track of the width and period of the square wave on the input. But if they do change state, what is the final state?

I hope I was sufficiently clear in the question. Thanks for your replies.

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: Question about the ICU module

Postby Giovanni » Sat Nov 18, 2017 2:48 pm

Hi,

Those functions don't change the driver state, it is just about enabling/disabling callbacks at runtime.

Giovanni

orion
Posts: 17
Joined: Sun Nov 12, 2017 7:56 pm
Has thanked: 4 times
Been thanked: 3 times

Re: Question about the ICU module

Postby orion » Sat Nov 18, 2017 9:08 pm

Sorry if I'm being nitpicky but I just want to see if I understand correctly how the ICU module works.

Suppose the ICU module is configured to be in the ICU_INPUT_ACTIVE_HIGH mode. I call icuStartCapture() and two or more activation edges occur, meaning the ICU state machine is in the ICU_ACTIVE state. After some time, I call icuDisableNotifications() and let a few periods of the square wave on the capture pin pass by. I then call icuEnableNotifications() when the capture pin signal is not in the active state (i.e., it is low). I assume the ICU module is still in the ICU_ACTIVE state at this time. This means that the first activation edge (a rising edge) after I call icuEnableNotifications() triggers a call to the period callback and measures correctly the period, right?

In other words, the function icuDisableNotifications() only disables the callbacks, but it doesn't disable the width and period measurements.

Is that correct?

Thanks.

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: Question about the ICU module

Postby Giovanni » Sun Nov 19, 2017 6:49 am

It does not affect measurements, you can wait for edges in polled mode too.

Giovanni


Return to “ChibiOS/HAL”

Who is online

Users browsing this forum: No registered users and 3 guests