Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding hardwaret timer and fixing PWM pins errors #71

Merged
merged 2 commits into from
Mar 11, 2024

Conversation

TianpeiLee
Copy link
Collaborator

You can set pwmout like this :

 analogWriteFrequency(16000);                //you can set output frequency
 pinMode(PWM_OUT_5, OUTPUT);          //config pins
 analogWrite(PWM_OUT_5,2048);           // config duty, default 12bit

or you can config timer like this:

HardwareTimer *HardTim = new HardwareTimer(TIM2);
HardTim->setOverflow(1000, HERTZ_FORMAT); // 1000 Hz
HardTim->attachInterrupt(Update_IT_callback);
HardTim->resume();

void Update_IT_callback(void)
{
digitalWrite(LED_PIN, !digitalRead(LED_PIN));
}

image

@TianpeiLee TianpeiLee merged commit c40c5c8 into openwch:main Mar 11, 2024
wszeto9 added a commit to wszeto9/arduino_core_ch32 that referenced this pull request May 11, 2024
adding hardwaret timer and fixing PWM pins errors (openwch#71)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant