Skip to main content
PYong.2
Associate
April 21, 2020
Question

How to use timer1 for pwm input

  • April 21, 2020
  • 4 replies
  • 1607 views

I use STM32F103c6 timer1 for pwm input . after right config in cubemx, and in simulink enable timer1 ch1 interrupt. Then auto code gen, but code in Keil the ch1 interrupt not enable, its callback not registered, the timer also not started. Want to know how to use timer1 pwm input in simulink, look forward to reply! Already Confused for one week ...

This topic has been closed for replies.

4 replies

waclawek.jan
Super User
April 21, 2020

I don't think you'll find much dedicated Simulink/Matlab support here.

Which STM32?

Make sure that the interrupts have the same name as listed in the vector table, usually in startup file. Note, that TIM1 is usually an exception, having several separate interrupts for different groups of signals (Update, CC, etc.) Read the Interrupts chapter in RM.

JW

PYong.2
PYong.2Author
Associate
April 22, 2020

Thx for your answer.

  1. It is F103C8.
  2. For time 1, in simulink it is GUI selection.i think there is no mistake. And after config in cubemx, auto code contain tim1-cc-irqhandler(). But no hal-Tim-irqhandler call. And in init, no cc-irq register and no timer start.
  3. So wonder whether the software don’t support auto-gen for timer1 pwm-input , or i did something wrong. But in demos,no such application. So please help!
hendrikk
Associate
April 29, 2020

Hi, @PYong.2​ did you enabled the IRQs for TIM1 under NVIC in CubeMX?

PYong.2
PYong.2Author
Associate
May 9, 2020

yes, already enabled the IRQs for TIM1. For no solution,I choose to ​add start code to fix it. Thx!

hendrikk
Associate
October 7, 2020

And did you try a Cube configuration like this?

0693W000004J2VeQAK.png