Skip to main content
Samuel1
Associate III
March 18, 2019
Question

is it possible to create a high clock rate counter for µc with Simulink ?

  • March 18, 2019
  • 2 replies
  • 1138 views

Hello everybody,

I need a counter with high Tacktfrequenz (eg 1 MHz) in Simulink. This allows me to turn a PIN on / off with the help of STM32 Nucleo board in μs range. In the lower model, I want to switch off the pin for 20 μs and then turn it on. The process repeats itself as you see by the counter. In order to reach the clock frequency of 1 MHz, the sample time of the free running Counter was set to 0.0000001. which slow and kill the calculation time. So to my question If I let this model run on the STM32 with External Mode in Simulink, would the pin really switched off for 20 μs? Unfortunately in Nucleo Support Package there are no timers and if so then I can not access the value in Simulink. For such application i use normally this function __HAL_TIM_GetCounter(&htim3).

#Matlab​ #Simulink​ #[STM32-Mat/Target]​ 

regards

This topic has been closed for replies.

2 replies

Tesla DeLorean
Guru
March 18, 2019

Well you definitely can't interrupt at such a rate. You'd need to configure the TIM in External Count mode, but the TIM->CNT is only 16-bit wide.

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
Samuel1
Samuel1Author
Associate III
March 18, 2019

@Community member​ i know that the problem i do not have access to the Timer in Simulink