Page 2 of 3
Re: STMF4 get frequency of a signal on a input pin.
Posted: Mon Aug 12, 2013 10:26 am
by Joerg-SH
Yes but why I have to configure ICU with "lastwide" and lastperiod" ???
Code: Select all
static void icuwidthcb(ICUDriver *icup) {
last_width = icuGetWidth(icup);
}
static void icuperiodcb(ICUDriver *icup) {
last_period = icuGetPeriod(icup);
}
static ICUConfig icucfg = {
ICU_INPUT_ACTIVE_HIGH,
10000, /* 10kHz ICU clock frequency. */
icuwidthcb,
icuperiodcb,
NULL,
ICU_CHANNEL_1
};
And why channel 1 and not 3 witch is configured to C6
Code: Select all
icuStart(&ICUD3, &icucfg);
palSetPadMode(GPIOC, 6, PAL_MODE_ALTERNATE(2));
icuEnable(&ICUD3);
Re: STMF4 get frequency of a signal on a input pin.
Posted: Mon Aug 12, 2013 10:42 am
by Giovanni
On data sheet at page 57, row "PC6", column "AF2" there is your answer.
Giovanni
Re: STMF4 get frequency of a signal on a input pin.
Posted: Mon Aug 12, 2013 10:53 am
by Joerg-SH
Ok I think that did I understand.
and the other question?
why I have to configure ICU with "lastwide" and lastperiod" ???
Joerg
Re: STMF4 get frequency of a signal on a input pin.
Posted: Mon Aug 12, 2013 10:55 am
by Giovanni
Because you want to measure the width and the period, it right way to do that is in the callbacks.
Giovanni
Re: STMF4 get frequency of a signal on a input pin.
Posted: Mon Aug 12, 2013 11:07 am
by Joerg-SH
Ok i have ordered a book... I hope is good and coming soon... ChibiOS/RT - Lambert M. Surhone
Do You know that book?
Re: STMF4 get frequency of a signal on a input pin.
Posted: Mon Aug 12, 2013 11:12 am
by Giovanni
I am surprised, never heard of it, apparently it is extracted from Wikipedia so I don't know if it can be useful. I would be careful because it mentions another OS in the title "PLAN 9", is that even related to ChibiOS?
Why don't you visit the
ICU documentation page first?

Giovanni
Re: STMF4 get frequency of a signal on a input pin.
Posted: Mon Aug 12, 2013 11:28 am
by Joerg-SH
I visit that side, I think I have a generally problem understand the syntax
Re: STMF4 get frequency of a signal on a input pin.
Posted: Mon Aug 12, 2013 11:38 am
by Giovanni
Which syntax? my English

? the diagrams? or the general description of the functions?
Giovanni
Re: STMF4 get frequency of a signal on a input pin.
Posted: Mon Aug 12, 2013 11:51 am
by Joerg-SH
This all are ok, but for understanding is a sample / code snipe very helpful. I know that well from the Compiler i used fore Years
(Bascom) 
Re: STMF4 get frequency of a signal on a input pin.
Posted: Mon Aug 12, 2013 1:06 pm
by Giovanni
I recommend that you take your time to study the PWM-ICU example line by line until you get the meaning of everything, search in the documentation the meaning of each function, if you try to skip over details then you will not reach the objective.
After that try to make small changes to the example and see the effect.
Giovanni