2 ICU on one timer STM32F072C8

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

Moderator: RoccoMarco

Post Reply
halba
Posts: 18
Joined: Sun May 10, 2015 9:13 am

2 ICU on one timer STM32F072C8

Post by halba »

Hello Giovanni,

Is it possible to have two independent ICU from channel 1 and 2 on one timer? If I run ICU on one channel, it is working properly, but I am not able to run ICU on two channels on one timer. I thought that this implementation will not work, but just for illustration to be clear what I want to achieve:

Code: Select all

icucnt_t last_width, last_period;

static void icuwidthcb(ICUDriver *icup) {

  last_width = icuGetWidthX(icup);
}

static void icuperiodcb(ICUDriver *icup) {

  last_period = icuGetPeriodX(icup);
}

static void icuoverflowcb(ICUDriver *icup) {

  (void)icup;
}

icucnt_t last_width2, last_period2;

static void icuwidthcb2(ICUDriver *icup) {

  last_width2 = icuGetWidthX(icup);
}

static void icuperiodcb2(ICUDriver *icup) {

  last_period2 = icuGetPeriodX(icup);
}

static void icuoverflowcb2(ICUDriver *icup) {

  (void)icup;
}


static ICUConfig icucfg = {
  ICU_INPUT_ACTIVE_HIGH,
  100000,                                    /* 10kHz ICU clock frequency.   */
  icuwidthcb,
  icuperiodcb,
  icuoverflowcb,
  ICU_CHANNEL_1,
  0
};

static ICUConfig icucfg2 = {
  ICU_INPUT_ACTIVE_HIGH,
  100000,                                    /* 10kHz ICU clock frequency.   */
  icuwidthcb2,
  icuperiodcb2,
  icuoverflowcb2,
  ICU_CHANNEL_2,
  0
};

.
.
.

  icuStart(&ICUD2, &icucfg);
  icuStart(&ICUD2, &icucfg2);

  icuStartCapture(&ICUD2);
  icuEnableNotifications(&ICUD2);


Is there some way how to do something like this?

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

Re: 2 ICU on one timer STM32F072C8

Post by Giovanni »

Hi,

One ICU per timer only, there is a contributed driver that adds use for the extra comparators, see "eicu" in the 3.0 community overlay.

Anyway you cannot have fully independent ICUs using a single timer, that would require multiple independent counters (not different than having multiple timers...).

Giovanni
Post Reply