Page 1 of 1

2 ICU on one timer STM32F072C8

Posted: Mon Jun 01, 2015 6:13 pm
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

Re: 2 ICU on one timer STM32F072C8

Posted: Mon Jun 01, 2015 6:19 pm
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