cancel
Showing results for 
Search instead for 
Did you mean: 

How to use timer1 for pwm input

PYong.2
Associate II

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 ...

5 REPLIES 5

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
Associate II

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 III

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

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

hendrikk
Associate III

And did you try a Cube configuration like this?

0693W000004J2VeQAK.png