ICU problem: last_width is always zero

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

Moderator: RoccoMarco

Post Reply
wapry
Posts: 3
Joined: Sun Nov 09, 2014 11:15 am

ICU problem: last_width is always zero

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

Re: ICU problem: last_width is always zero

Post 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
wapry
Posts: 3
Joined: Sun Nov 09, 2014 11:15 am

Re: ICU problem: last_width is always zero

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

Re: ICU problem: last_width is always zero

Post 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
wapry
Posts: 3
Joined: Sun Nov 09, 2014 11:15 am

Re: ICU problem: last_width is always zero

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

Re: ICU problem: last_width is always zero

Post by Giovanni »

No, that is all, look at the PWM-ICU demos under ./testhal/STM32

Giovanni
Post Reply