PWM Frequency for Teensy board stuck at 490.2Hz

조회 수: 7 (최근 30일)
Judicael Aubry
Judicael Aubry 2024년 4월 14일
댓글: Judicael Aubry 2024년 5월 15일
Hello
It seems that the frequency of PWM signals is not configurable for Teensy boards. For all other boards, the achievable frequency is updated according to the desired frequency, but as soon as you choose the Teensy board, the achievable frequency remains stuck at 490.2Hz.

채택된 답변

Naren
Naren 2024년 5월 6일
Hello Judicael,
For Teensy boards, the PWM frequency can indeed be configured, but it requires a specific approach. Here’s how you can adjust the PWM frequency:
Use the analogWriteFrequency(pin, hz) Function: This function allows you to set the PWM frequency for a specific pin. By calling analogWriteFrequency(pin, desiredFrequency); you can change the frequency to your desired value. This is a straightforward method to adjust the frequency directly.
Note that changing the frequency with analogWriteFrequency() should always be preceded by analogWrite(0) and followed by a new analogWrite(newDutyCycle) to make sure that the duty cycle is recalculated depending on the new PWM frequency.
Regards.
  댓글 수: 1
Judicael Aubry
Judicael Aubry 2024년 5월 15일
I've created a custom block using the analogWriteFrequency(pin, hz) function. I wanted to be able to modify the PWM frequency during program execution.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 C2000 Microcontroller Blockset에 대해 자세히 알아보기

제품


릴리스

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by