Page 1 of 1

ICU problem: last_width is always zero

Posted: Sun Nov 09, 2014 11:22 am
by wapry
Hi,
I have a problem with ICU module. I have an Inemo board and an ultrasonic sensor and try to read a distance from the sensor using ICU Driver but the last_width callback is never called.

Furthermore the sensor is supplied with a voltage of 5 volts so I have connected VCC to V_EXT of iNemo.

Code: Select all

float readDistance( void ){
  static float width = 0;
  static float distance = 0;

  pwmStart(&PWMD2, &pwmcfg_us);
  palSetPad(GPIOA, 3);
  pwmEnableChannel(&PWMD2, 3, PWM_PERCENTAGE_TO_WIDTH(&PWMD2, 2));

  icuStart(&ICUD3, &icucfg);
  palSetPadMode(GPIOA, 11, PAL_MODE_INPUT);
  icuEnable(&ICUD3);

  chThdSleepMilliseconds(50);

  pwmDisableChannel(&PWMD2, 3);
  pwmStop(&PWMD2);
  icuDisable(&ICUD3);
  icuStop(&ICUD3);

  width =last_width;

  distance = ( (float) width * CONSTANT );

  return distance;
}

Re: ICU problem: last_width is always zero

Posted: Sun Nov 09, 2014 11:59 am
by Giovanni
Are you using 2.6 or 3.0? in 3.0 there is a function to call in order to enable callbacks (callbacks are disabled by default).

Giovanni

Re: ICU problem: last_width is always zero

Posted: Sun Nov 09, 2014 5:52 pm
by wapry
Hi Giovanni,
i'm using 2.6.5. Where can I find the version 3? In web thre is only the version 2.6.6

Re: ICU problem: last_width is always zero

Posted: Sun Nov 09, 2014 7:32 pm
by Giovanni
Hi,

Version 3 is only obtainable by taking it from the repository trunk, see the download page, there a subversion link there.

Giovanni

Re: ICU problem: last_width is always zero

Posted: Tue Nov 11, 2014 8:16 pm
by wapry
Hi Giovanni,
thanks for advice. I've another question: is there a way to run ICU DRIVER in version 2.6.5? What should I activate? I have activated icu in mcuconf.h and halconf.h. Do i forget something?

Thanks

Re: ICU problem: last_width is always zero

Posted: Tue Nov 11, 2014 8:28 pm
by Giovanni
No, that is all, look at the PWM-ICU demos under ./testhal/STM32

Giovanni