For a project, I need three PWM signals to be synchronous and in phase-correct mode. Furthermore, the frequency should be greater than 20khz (not in the audible range) and it should be 8 or 10 bit. Unfortunately, I have no experience with ARM based processors. Can somebody explain to me, how I can setup my Arduino Due to produce this kind of output?
Secondly I wonder if somebody can tell me how many PWM pins the Due has. I found different numbers varying between 4 and 27.
Thanks in advance
Josua
PS: I've got a working example on an Arduino Mega, but I need the better performance of the Due for my project.
Secondly I wonder if somebody can tell me how many PWM pins the Due has. I found different numbers varying between 4 and 27.
There are 2 types of PWM ... Timer/Counter based PWM available on pins D2-D13 (12 pins).
The Arduino IDE accesses these pins.
Then there's the PWM Controller (PWMC) ... very flexible and very powerful. However this requires directly programming the registers or using a custom library. There are 16 pins here PWMH 0-7 and PWML 0-7 (8-channels), but one or two of these pins are not broken on the Due. The first 4-channels have all pins broken out. Refer to Table 39-2 (pg 987) of the datasheet and to the Due Pinout Diagram for reference.
At 25kHz PWM, you could control the duty cycle from 0-3360 which is better than 11-bit. (84MHz/25kHz=3360).
Perhaps if you attached your Mega's working example, it would be a good reference and aid in providing help.
How do I use and setup the Timer/Counter based pins? When my prototype works, I'm probably going to need 3*3 PWM outputs, thus it would be nice if I had those 12 pins.
Edit: I just read a little in the sam3x8e's datasheet and I discovered that you have to assign the pwm channels to the GPIOs. So I could assign the PWMC channels to the pins myself?