Page 1 of 1

STM32F103 ICU not starting keeping the line low

Posted: Sun Dec 30, 2012 10:24 am
Hi,

I have bought very basic board with STM32F103C8T6 uC.
I am trying to make the icu to work w/o success.
The ICU seems not to start as the line is low after starting and enabling the ICU.
Very similar code works well on STM32F4 board.

Code: Select all

   DHT_icucfg.mode = ICU_INPUT_ACTIVE_HIGH;
   DHT_icucfg.frequency = DHT_ICU_FREQ;
   DHT_icucfg.width_cb = DHT_icuwidthcb;
   DHT_icucfg.period_cb = DHT_icuperiodcb;
   DHT_icucfg.overflow_cb = NULL;
   DHT_icucfg.channel = ICU_CHANNEL_1;

   DHT1122_data data;

   // REQUEST SAMPLE
   palSetPadMode(GPIOB, 6, PAL_MODE_OUTPUT_OPENDRAIN);
   palWritePad(GPIOB, 6, PAL_LOW);
   chThdSleepMilliseconds(20);

   palSetPadMode(GPIOB, 6, PAL_MODE_STM32_ALTERNATE_PUSHPULL);
   icuStart(&ICUD4, &DHT_icucfg);
   icuEnable(&ICUD4);


The code suppose to communicate with DHT22 sensor.

The B6 alternate function is default I2C1_SCL/TIM4_CH1.
I am not using I2C.

As I said before, the B6 line is low no matter to ICU_INPUT_ACTIVE_HIGH.

Should I do any splecial remaping or sth.?

Thanks in advance.

Greetings
Piotr Klimczak

Re: STM32F103 ICU not starting keeping the line low

Posted: Sun Dec 30, 2012 10:48 am
by Giovanni
If GPIOB 6 is supposed to be an ICU input then you should program it as input, not output.

Giovanni

Re: STM32F103 ICU not starting keeping the line low

Posted: Sun Dec 30, 2012 12:19 pm
Hi Giovanni!

Thanks for the answer.
The DHT22 needs a little trick to start transmittion.
It needs the line to be set HIGH to LOW for 20ms then back to HIGH.

HIGH to LOW is done by:

Code: Select all

   palSetPadMode(GPIOB, 6, PAL_MODE_OUTPUT_OPENDRAIN);
   palWritePad(GPIOB, 6, PAL_LOW);
   chThdSleepMilliseconds(20);

Then after 20ms:

Code: Select all

   palSetPadMode(GPIOB, 6, PAL_MODE_STM32_ALTERNATE_PUSHPULL);
   icuStart(&ICUD4, &DHT_icucfg);
   icuEnable(&ICUD4);


So the line is set as INPUT as I believe. Am I right?
Same code works on STM32F4, so what is wrong?

Please note that I have tried different TIMs, Channels, lines etc.

Thanks in advance!

Piotr

Re: STM32F103 ICU not starting keeping the line low

Posted: Sun Dec 30, 2012 12:26 pm
I have forgotten to say- I am using latest trunk.

Piotr

Re: STM32F103 ICU not starting keeping the line low

Posted: Sun Dec 30, 2012 12:53 pm
by Giovanni
The F4 has a different GPIO, the F1 requires that the alternate inputs to be normal inputs but I think that also output open drain should work. Just keep it PAL_MODE_OUTPUT_OPENDRAIN set to high.

Giovanni

Re: STM32F103 ICU not starting keeping the line low

Posted: Tue Jan 01, 2013 10:36 pm
Thanks a lot Giovanni!

As always you ware right! :)
Everything works well now!

BTW. Happy new year!

Greetings,
Piotr