Skip to main content
PYong.2
Associate
Apr 21, 2020 6:14 PM UTC
Question

How to use timer1 for pwm input

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.

5 replies

waclawek.jan
Super User
Apr 21, 2020 6:47 PM UTC

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
Apr 22, 2020 2:13 AM UTC

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
Apr 29, 2020 7:27 PM UTC

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

PYong.2
PYong.2Author
Associate
May 9, 2020 10:59 AM UTC

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

hendrikk
Associate
Oct 7, 2020 8:13 PM UTC

And did you try a Cube configuration like this?

0693W000004J2VeQAK.png