timer bug stm32f411VE

Moderator: Benj

Alkaline
Posts: 143
Joined: Mon Aug 20, 2018 11:04 am
Has thanked: 42 times
Been thanked: 41 times
Contact:

timer bug stm32f411VE

Post by Alkaline »

Hello

I'm trying to implement a timer inside the program but when I go to compile it gives me the following error
Project LCD_2
Device STM32F411xE


Z:\>arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Os -DSTM32 -DSTM32F4 -DSTM32F411xE -DUSE_HAL_DRIVER -DHSE_VALUE=16000000 -IC:\PROGRA~2\Flowcode\Common\COMPIL~1\starm\batch\..\stm32cubeF4\Drivers\CMSIS\Include -IC:\PROGRA~2\Flowcode\Common\COMPIL~1\starm\batch\..\stm32cubeF4\Drivers\CMSIS\Device\ST\STM32F4xx\Include -IC:\PROGRA~2\Flowcode\Common\COMPIL~1\starm\batch\..\stm32cubeF4\Drivers\STM32F4xx_HAL_Driver\Inc -IC:\PROGRA~2\Flowcode\Common\COMPIL~1\starm\batch\..\stm32cubeF4\Drivers\STM32F4xx_HAL_Driver\Inc\Legacy -IC:\PROGRA~2\Flowcode\Common\COMPIL~1\starm\batch\..\inc -fmessage-length=0 -fdata-sections -ffunction-sections -w -c "LCD_2.c" -o "LCD_2_STM32F411xE_16000000\LCD_2.o"
LCD_2.c:7350:2: error: expected '=', ',', ';', 'asm' or '__attribute__' at end of input
Error(s) in build

C:\Program Files (x86)\Flowcode\Common\Compilers\starm\batch\stm32comp.bat reported error code 1

If I try to use an interrupt associated with a timer, I compile without errors but the interrupt event never occurs

any suggestions?

Regards

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: timer bug stm32f411VE

Post by LeighM »

Hi,
Could you post the program? Or an example that gives the error?
Thanks

Alkaline
Posts: 143
Joined: Mon Aug 20, 2018 11:04 am
Has thanked: 42 times
Been thanked: 41 times
Contact:

Re: timer bug stm32f411VE

Post by Alkaline »

Hi LeighM
Attachments
LCD_3.fcfx
(18.73 KiB) Downloaded 176 times

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: timer bug stm32f411VE

Post by LeighM »

Hi,
The issue is coming from the Timer component (on the Dashboard)
You can remove it, as it looks like it is not yet compatible with STM32 devices.

As a work around you could use the HAL_GetTick() function which returns the number of milliseconds elapsed since startup
So for example if you have a global ULong variable TIME_NOW you can get a snapshot of the counter with a C icon code

Code: Select all

FCV_TIME_NOW = HAL_GetTick();
 
I will have a chat with Ben sometime and see if we can do anything with the Timer component.

Alkaline
Posts: 143
Joined: Mon Aug 20, 2018 11:04 am
Has thanked: 42 times
Been thanked: 41 times
Contact:

Re: timer bug stm32f411VE

Post by Alkaline »

Hi LeighM

but what can you tell me about the interrupt associated with the timer?

As explained in the mail, the interrupt associated with the timer does not occur.

I also tried to change the timer but it doesn't change the result.

The compilation does not give any errors

Regards

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: timer bug stm32f411VE

Post by LeighM »

The Timer component measures the passage of time. It uses a device timer to do that.
However, it looks like the Timer component is not currently supported by us on the STM32 devices.
I will have a chat with Ben and see if between us we can get this fixed.
I suggested that you remove it from your program because it does not yet work on STM32
and also you are not actually using any functions of the Timer component anyway.

In your program you have enabled a Timer Interrupt.
This is a separate functionality and nothing to do with the Timer component.
So, as you have it, the Timer Interrupt can be used to call your macro1 periodically.
You don’t need the Timer component.

In theory, to do something periodically, you could either do this on a timer interrupt
OR measure time and compare with an elapse period to then call the periodic process.

Hope that helps
Leigh

edit:
If you have now removed the Timer component and are just using the Timer Interrupt, then the next issue is working out the timer properties (prescale and rollover) to give you the required period. The Flowcode dialog box does not calculate these correctly for STM, for lots of reasons.
Also, I would suspect that you are unlikely to get a low enough interrupt rate for the time consuming display code in macro1. So you are likely to need a counter within macro1. Better still, just set a flag (or counter) within the interrupt, then test the flag in your main loop and call the display code from there.
If you need any more help with the timer values, let me know.

Having said all that, for slow periodic functions such as updating the display, you would likely be best reading the Systick timer value in your main and calculating elapsed time.

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: timer bug stm32f411VE

Post by LeighM »

Oh, forgot to mention, the continuous loop in the interrupt macro1 needs removing :wink:

Here is an example of using GetTick ...
Attachments
LCD_4.fcfx
(16.45 KiB) Downloaded 174 times

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: timer bug stm32f411VE

Post by LeighM »

Hi,
I've created a new STM32 Timer component, now in the update system.
Here is an example of how to use it ...
Attachments
LCD_5.fcfx
(16.48 KiB) Downloaded 170 times

Alkaline
Posts: 143
Joined: Mon Aug 20, 2018 11:04 am
Has thanked: 42 times
Been thanked: 41 times
Contact:

Re: timer bug stm32f411VE

Post by Alkaline »

Thanks for the quick support.

In the coming weeks I will try to bring a project currently developed for pic32 on this new microcontroller.

If you have other problems I will let you know.

Regards

Alkaline
Posts: 143
Joined: Mon Aug 20, 2018 11:04 am
Has thanked: 42 times
Been thanked: 41 times
Contact:

Re: timer bug stm32f411VE

Post by Alkaline »

Hi LeighM
I'm finishing the schematic of the pcb.
The peripherals that I will use are i2c master, I have seen that it works in software mode and for me it is ok.
The hardware peripherals that I will have to use are the following
PWM (PA0 port) ( to control the backlight of an LCD display)
USART1 (PA9-PA10) ( Bootloader)
USART 2 (PA2-PA3) ( to control external HW)
Do you see any problems with these pins?
From flowocode they are all selectable so theoretically I should be able to use them!
I also discovered that the STM32F411RCT6 mcu it is pintopin compatible with mcu STM32F030RCT6 also supported by flowcode.
I have tried the uart bootloader and it works perfectly.
I will implement a circuit with FT234XD-R chip to allow programming via USB!

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: timer bug stm32f411VE

Post by LeighM »

Hi,
Yes, that should all be fine :D
The USART bootloader is a very useful feature, I’ve used this myself on several projects.
Just don’t forget to add a selection link to the BOOT0 pin :wink:

Alkaline
Posts: 143
Joined: Mon Aug 20, 2018 11:04 am
Has thanked: 42 times
Been thanked: 41 times
Contact:

Re: timer bug stm32f411VE

Post by Alkaline »

Finally I managed to have the pcb and I am testing the new MCU.

uart bootloader ok!
I2c ok!

I'm having an anomaly regarding the display. The speed with which the clearDisplay performs is slow compared to the others macro.

Can you do anything to improve the cleardisplay speed?

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: timer bug stm32f411VE

Post by LeighM »

The gLCD ILI9341 ClearDisplay?
Ben is the gLCD wiz, might have some thoughts on that

edit: I've checked your system clock settings and they look OK, the 411 is running near max speed

Alkaline
Posts: 143
Joined: Mon Aug 20, 2018 11:04 am
Has thanked: 42 times
Been thanked: 41 times
Contact:

Re: timer bug stm32f411VE

Post by Alkaline »

the loading of bitmap images is fast,
the clear display instead is a little slower, just as if I have to fill the whole area with a rectangle of color.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: timer bug stm32f411VE

Post by Benj »

Hello,

Turning off toggle CS property should help a little bit.

I can see another potential optimisation we could do. I'll have a crack at it for you and see how I get on.

Alkaline
Posts: 143
Joined: Mon Aug 20, 2018 11:04 am
Has thanked: 42 times
Been thanked: 41 times
Contact:

Re: timer bug stm32f411VE

Post by Alkaline »

Another question.
I2c Works at around 100Khz. Is it possible to somehow bring it to 400Khz or 1Mhz?

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: timer bug stm32f411VE

Post by LeighM »

For the software mode we get the state delay from an internal clock counter with a resolution of ~1uS
So around 400KHz should be achievable, but not 1MHz
Did you try the component baud selector?

Alkaline
Posts: 143
Joined: Mon Aug 20, 2018 11:04 am
Has thanked: 42 times
Been thanked: 41 times
Contact:

Re: timer bug stm32f411VE

Post by Alkaline »

LeighM wrote:For the software mode we get the state delay from an internal clock counter with a resolution of ~1uS
So around 400KHz should be achievable, but not 1MHz
Did you try the component baud selector?
Yes, I tried to change but it doesn't change the speed.
I am seeing that the problem is present both on the STM32f411VE chip and on the chip STM32F030RC

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: timer bug stm32f411VE

Post by LeighM »

Strange, I tested on a Nucleo 446 and got close to 400KHz.
I’ve had a look at the datasheet and found that the device hardware I2C does not support 1MHz either.
So even if we put the effort into writing a hardware driver it is not going to achieve much improvement.

Alkaline
Posts: 143
Joined: Mon Aug 20, 2018 11:04 am
Has thanked: 42 times
Been thanked: 41 times
Contact:

Re: timer bug stm32f411VE

Post by Alkaline »

I'm currently going with an stm32f030rc.
I can't go beyond 119Khz. If I could reach 400 Khz it would be great
Attachments
Test_i2c.fcfx
(90.91 KiB) Downloaded 107 times

Alkaline
Posts: 143
Joined: Mon Aug 20, 2018 11:04 am
Has thanked: 42 times
Been thanked: 41 times
Contact:

Re: timer bug stm32f411VE

Post by Alkaline »

Hi LeighM

any updates regarding I2c?

Kind Regards

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: timer bug stm32f411VE

Post by LeighM »

In software mode we are limited by the resolution of the systick timer.
I will try and find some time to get more progress for hardware support

Alkaline
Posts: 143
Joined: Mon Aug 20, 2018 11:04 am
Has thanked: 42 times
Been thanked: 41 times
Contact:

Re: timer bug stm32f411VE

Post by Alkaline »

Thanks for the update.

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: timer bug stm32f411VE

Post by LeighM »

I’ve now completed some code to support hardware I2C, initially for your 32F030RC
Files that have been updated are:
STARM_CAL_I2C.c (C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\STARM)
32F030RC.fcdx (C:\ProgramData\MatrixTSL\FlowcodeV8\FCD\ARM)
cal_i2c.fcpx (C:\ProgramData\MatrixTSL\FlowcodeV8\Components)
I will ask Ben to push these into the auto update system.

Due to the way that ARM I2C is implemented, the interface is via transactions.
These are currently only available with the CAL I2C component, namely:
Transaction_Initialise
Transaction_Read
Transaction_Write
Transaction_Unint

Please give it a try once it is available.

Nb. Most of the Flowcode components that are built on I2C currently do not support transactions, hence are not supported for ARM hardware I2C.
One exception is the LM75B Temperature sensor.

Alkaline
Posts: 143
Joined: Mon Aug 20, 2018 11:04 am
Has thanked: 42 times
Been thanked: 41 times
Contact:

Re: timer bug stm32f411VE

Post by Alkaline »

i2c_HW.jpg
i2c_HW.jpg (66.23 KiB) Viewed 8698 times
Hi LeighM

I make a couple of tweaks by connecting the right pins and try the i2C HW support.

Thanks for the update!

Update:
this is the screen of the i2c CAL component
I'm trying to send transactions but it doesn't seem to work.
I am using channel 1 port PB10 and PB11
Attachments
Test_i2c_HW.fcfx
(10.01 KiB) Downloaded 98 times

Post Reply