ambiot / ambpro2_arduino

AmebaPro2 Arduino third-party package SDK
https://www.amebaiot.com/en/ameba-arduino-summary/
MIT License
42 stars 18 forks source link

Cant set PWM frequency #249

Open nsmith1024 opened 3 days ago

nsmith1024 commented 3 days ago

Boards

AMB82-Mini

External Hardware

NONE

Hardware Configuration

Using PWM

Version

latest dev (checkout manually)

IDE Name

Arduino IDE 2.3.2

Operating System

Windows

Auto Flash Mode

Disable

Erase All Flash Memory (16MB)

Disable

Standard Lib

Arduino_STD_PRINTF

Upload Speed

2000000

Description

How do i change the PWM frequency?

I tried using standard the Arduino functions

ledcAttach(PWM_PIN, FREQ, RESOLUTION); ledcWrite(PWM_PIN,pwm_value);

Both are undefined.

Please tell me how to set the PWM frequency, resolution, and duty cycle.

Thanks

Sketch

ledcAttach(PWM_PIN, FREQ, RESOLUTION);
 ledcWrite(PWM_PIN,pwm_value);

Error/Debug Message

undefined

Reproduce remarks

No response

I have checked online documentation, FAQ, GitHub Wiki and existing/closed issues.

github-actions[bot] commented 3 days ago

Hello, hope this message finds you well. Congrats to your first Issue! We will review it as soon as possiable. Feel free to have a look at https://www.amebaiot.com/en/ameba-arduino-summary/ for more information

nsmith1024 commented 3 days ago

There is no example for PWM itself, It shows a tone generator example, and servo example, but those doesnt allow direct control of the PWM.

The proper PWM functions ledcAttach(PWM_PIN, FREQ, RESOLUTION); and ledcWrite(PWM_PIN,pwm_value); are undefined in arduino.

Im trying to control a DC motor (not a servo, and not a stepper) just a regular DC motor using the PWM, where i need to change both the frequency and duty cycle.