STMF4 get frequency of a signal on a input pin.

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Joerg-SH
Posts: 29
Joined: Mon Feb 20, 2012 9:00 pm

Re: STMF4 get frequency of a signal on a input pin.

Post 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);

User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: STMF4 get frequency of a signal on a input pin.

Post by Giovanni »

On data sheet at page 57, row "PC6", column "AF2" there is your answer.

Giovanni
Joerg-SH
Posts: 29
Joined: Mon Feb 20, 2012 9:00 pm

Re: STMF4 get frequency of a signal on a input pin.

Post 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
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: STMF4 get frequency of a signal on a input pin.

Post by Giovanni »

Because you want to measure the width and the period, it right way to do that is in the callbacks.

Giovanni
Joerg-SH
Posts: 29
Joined: Mon Feb 20, 2012 9:00 pm

Re: STMF4 get frequency of a signal on a input pin.

Post 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?
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: STMF4 get frequency of a signal on a input pin.

Post 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
Joerg-SH
Posts: 29
Joined: Mon Feb 20, 2012 9:00 pm

Re: STMF4 get frequency of a signal on a input pin.

Post by Joerg-SH »

I visit that side, I think I have a generally problem understand the syntax
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: STMF4 get frequency of a signal on a input pin.

Post by Giovanni »

Which syntax? my English :)? the diagrams? or the general description of the functions?

Giovanni
Joerg-SH
Posts: 29
Joined: Mon Feb 20, 2012 9:00 pm

Re: STMF4 get frequency of a signal on a input pin.

Post 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) :oops:
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: STMF4 get frequency of a signal on a input pin.

Post 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
Post Reply