Hi All
STM32 Timers have a lot of useful hardware features that are not directly accessible on Flowocode, like Hal-sensor and encoder mode.
I know is possible to implement o create a new component, starting from the supplementary code as describe on this article https://www.matrixtsl.com/blog/146/
But I found very hard to do and I can't fined a way to make it properly since their is no in depth tutorial and require a
certain amount of knowledge of C
Surely enable those features from CubeMX is very easy and it will create the code, but then I can't menage to link all the library ecc...
Or, I found e code that work on Mbed Compiler but also I'm not able to create a component from it.
So in the end I give up to use flowcode and also to complete my project just because of the lack of those features... Recently I tried again but with out success.. I created a similar Topic on 2018 but no much as changed since then.
I would defenetly pay to have an extra module with all this feature even if we pay for the specific compiler already
Can anyone help me to create this Macro ?
Thank you
Best !
Sacha
Access to the hardware features in STM32 timers
Moderator: Benj
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
- Contact:
Re: Access to the hardware features in STM32 timers
Hi Sacha,
It's difficult to give a general/generic answer to this.
It is possible to call the HAL functions from Flowcode, using a C icon within Flowcode macros.
We could probably best help by taking one example, can you give an exact example of what you want to do?
Please give all information that you can, such as actual device used, datasheet page and generated CubeMX code.
It's difficult to give a general/generic answer to this.
It is possible to call the HAL functions from Flowcode, using a C icon within Flowcode macros.
We could probably best help by taking one example, can you give an exact example of what you want to do?
Please give all information that you can, such as actual device used, datasheet page and generated CubeMX code.
-
- Posts: 22
- Joined: Tue Jul 03, 2018 12:21 pm
- Location: Southam UK
- Has thanked: 4 times
- Been thanked: 2 times
- Contact:
Re: Access to the hardware features in STM32 timers
I LeighM
Thank you for your reply !
So this is the Example ...
I want to reed a value from 2 Encoders , store the 32 Bit Value and print it.
I'm Using a Nucleo 64 F446RE, The Encoders will be the heds-5605 and the H9740
This board like I believe every F4 series have 2 32 Bit Timer, the TIM2 and TIM5 , and they are capable to directly reed the encoder in quadrature mode.
On the document you can find information at page 33, I also attached the datasheet of the 2 encoders
I hope this is enough....
Thank you for your help
Sacha
Sacha
Thank you for your reply !
So this is the Example ...
I want to reed a value from 2 Encoders , store the 32 Bit Value and print it.
I'm Using a Nucleo 64 F446RE, The Encoders will be the heds-5605 and the H9740
This board like I believe every F4 series have 2 32 Bit Timer, the TIM2 and TIM5 , and they are capable to directly reed the encoder in quadrature mode.
On the document you can find information at page 33, I also attached the datasheet of the 2 encoders
I hope this is enough....
Thank you for your help
Sacha
Sacha
- Attachments
-
- overview-stmicroelectronics.pdf
- (667.44 KiB) Downloaded 150 times
-
- hedm-55xx_2014-11-20.pdf
- (461.89 KiB) Downloaded 144 times
-
- H9740.pdf
- (216.31 KiB) Downloaded 144 times
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
- Contact:
Re: Access to the hardware features in STM32 timers
Hi,
Here is some C code to get us started,
It uses Port A pins 0 and 1 for the encoder signals,
this is the initialisation ...
Then use this in a macro to read the counter value ...
I've not had chance to test this, so hope I've not missed anything.
If this works then I will see if I can get the time to convert it into a Flowcode component.
(As I realise you are trying to avoid C)
Here is some C code to get us started,
It uses Port A pins 0 and 1 for the encoder signals,
this is the initialisation ...
Code: Select all
// Setup Port A0 as TIM2 CH1 input
// Alternate function mode
GPIOA->MODER |= 2;
// Set to AF1
GPIOA->AFR[0] |= 0x0001;
// Setup Port A1 as TIM2 CH2 input
// Alternate function mode
GPIOA->MODER |= 8;
// Set to AF1
GPIOA->AFR[0] |= 0x0010;
// Timer 2 setup
// TIM2 clock enabled
RCC->APB1ENR |= 1;
// Timer 2 Reload register to maximum
TIM2->ARR = 0xFFFFFFFF;
// Connect TI1 and TI2
TIM2->CCMR1 |= 0x0101;
// Set to Encoder mode 1
TIM2->SMCR |= 1;
// Enable the counter
TIM2->CR1 |= 1;
Code: Select all
FCR_RETVAL = TIM2->CNT;
If this works then I will see if I can get the time to convert it into a Flowcode component.
(As I realise you are trying to avoid C)
-
- Posts: 22
- Joined: Tue Jul 03, 2018 12:21 pm
- Location: Southam UK
- Has thanked: 4 times
- Been thanked: 2 times
- Contact:
Re: Access to the hardware features in STM32 timers
Hi LeighM
Thank you very much ! I will be busy on the next few days, as soon as I can I will check if it works, for sure I can compile it.
I really appreciate your help
Best
Sacha
Thank you very much ! I will be busy on the next few days, as soon as I can I will check if it works, for sure I can compile it.
I really appreciate your help
Best
Sacha