Greetings from Ukraine

The official STMicroelectronics Arduino core
Post Reply
ut2uz
Posts: 3
Joined: Sat Dec 09, 2017 12:08 am

Greetings from Ukraine

Post by ut2uz » Sat Dec 09, 2017 3:23 am

Hi everybody.

Just registered in order to report a bug in delayMicroseconds implementation. I need advice where to write some words regarding this issue.

A few words about myself. My name is Nick and I live in Kyiv. My hobbies are ham radio and astronomy.

I have a few std arduinos like uno, mega and leonardo. But they are too slow for my latest project. So, I've decided to try stm32f303RE nucleo64 board. I have some experince with EWARM, but it looks like stm32duino offers faster way to get the result.

So, I've inserted lcd & keys shield into the nucleo mb, wrote a simple sketch, which just prints time in hh.mm.ss format. And I was surprised that nothing special is required. The sketch prints and updates time as expected.

But... about an hour later the text at the LCD becomes distorted and frozen.

After some investigations the reason was found. The LiquidChristal library is sensitive to timings. But delayMicrosecond sometimes makes much shorter delay than requsted. Say, 1 us instead of 4500. The bug is found and fixed. So, the solution should be reported somewhere.

Thanks for reading,
Nick.

User avatar
RogerClark
Posts: 7537
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Greetings from Ukraine

Post by RogerClark » Sat Dec 09, 2017 3:50 am

Hi Nick

Which "Core" are you using.

If you are using a Nucleo board, are you using STM's own official core or are you using my LibMaple based "Arduino_STM32" repo ? (or perhaps @danielef's STM32_GENERIC core)

ut2uz
Posts: 3
Joined: Sat Dec 09, 2017 12:08 am

Re: Greetings from Ukraine

Post by ut2uz » Sat Dec 09, 2017 10:15 am

Hi,

The NUCLEO-F303RE is used as is from stock. The IDE is Arduino 1.8.2 with additional boards installed from https://github.com/stm32duino/BoardMana ... index.json.

User avatar
RogerClark
Posts: 7537
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Greetings from Ukraine

Post by RogerClark » Sat Dec 09, 2017 10:23 am

OK.

I moved the topic to this section for issues with the STM core

ut2uz
Posts: 3
Joined: Sat Dec 09, 2017 12:08 am

Re: Greetings from Ukraine

Post by ut2uz » Sat Dec 09, 2017 11:07 am

Original implementation from wiring_time.h:

Code: Select all

static inline void delayMicroseconds(uint32_t usec){
  uint32_t start = GetCurrentMicro();

  while((start+usec) > GetCurrentMicro());
}
Proposed solution is:

Code: Select all

static inline void delayMicroseconds(uint32_t usec){
  uint32_t end = GetCurrentMicro() + usec;

  while(((int32_t)(GetCurrentMicro()-end))<0);
}
Note that delays greater than 2147483647 (2147 sec = 35 min ) are handled incorrectly. I'm not familiar with compiler warnings in this IDE, so left the solution as is.

fpiSTM
Posts: 268
Joined: Fri Sep 16, 2016 12:33 pm
Location: Le Mans, France

Re: Greetings from Ukraine

Post by fpiSTM » Sun Dec 10, 2017 3:45 pm

Hi ut2uz,

Thanks for your feedback.
I've raised an issue:
https://github.com/stm32duino/Arduino_C ... issues/176

FYI, You could submit issue here:
https://github.com/stm32duino/Arduino_Core_STM32/issues

Post Reply