STM32F103 ICU not starting keeping the line low

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
[email protected]
Posts: 33
Joined: Sat Aug 25, 2012 9:53 pm
Been thanked: 1 time

STM32F103 ICU not starting keeping the line low

Post by [email protected] »

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

Re: STM32F103 ICU not starting keeping the line low

Post by Giovanni »

If GPIOB 6 is supposed to be an ICU input then you should program it as input, not output.

Giovanni
[email protected]
Posts: 33
Joined: Sat Aug 25, 2012 9:53 pm
Been thanked: 1 time

Re: STM32F103 ICU not starting keeping the line low

Post by [email protected] »

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
[email protected]
Posts: 33
Joined: Sat Aug 25, 2012 9:53 pm
Been thanked: 1 time

Re: STM32F103 ICU not starting keeping the line low

Post by [email protected] »

I have forgotten to say- I am using latest trunk.

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

Re: STM32F103 ICU not starting keeping the line low

Post 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
[email protected]
Posts: 33
Joined: Sat Aug 25, 2012 9:53 pm
Been thanked: 1 time

Re: STM32F103 ICU not starting keeping the line low

Post by [email protected] »

Thanks a lot Giovanni!

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

BTW. Happy new year!

Greetings,
Piotr
Post Reply