Clear Filters
Clear Filters

STM32F4xx Board Timer and Simulink Timers Does Not Provide Same Value

6 views (last 30 days)
Hi,
I am trying to read encooder with STM32F407G discovery board. I can run the code with build and deploy option so ı can see the data's with simulink data logging simultaneously. I can read the pulse count of the encoder correctly, but I have trouble reading the time. I activated TIM2 for the timer and selected "Clock source -Enable" from cubeMX and "TIM2 global interrupt" from NVIC settings. I also made the prescaler value 3359 because I wanted to get a timer with a value of 25kHz and I made the Counter period the highest value it can take because I want it to count continuously. Then I took the timer block in simulink, selected TIM2 and set the block frequency to 25kHz. Then I added the "Digital Clock" of the simulink itself and set it to 25kHz. Then I did data logging by taking the time difference with the previous time step with a delay block at 25kHz. I did this data logging for both TIM2 and digital clock. While the difference with the previous time step in the digital clock is 0.00004 s, it is constantly changing as 0.00004 and 0.00008 in the TIM2 block. What could be the reason for this?
  1 Comment
Goutham Varanasi
Goutham Varanasi on 17 Jul 2024
Hi
It is difficult to debug the issue from the description and requries a closer inspection of model and generated code.
Kindly contact Technical Support and provide the following information:
  • Reproduction steps
  • Reproduction model, ioc
  • Additional details, if any
Regards,
Goutham Varanasi

Sign in to comment.

Answers (0)

Categories

Find more on Deployment, Integration, and Supported Hardware in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!