Skip to content

Commit 5163763

Browse files
authored
Merge pull request #26 from pennam/pwm_core
Use new HRTIM functionality included in the core
2 parents cd032c1 + b2049a5 commit 5163763

File tree

4 files changed

+40
-255
lines changed

4 files changed

+40
-255
lines changed

examples/analogWrite/analogWrite.ino

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
Portenta Breakout - analogWrite
3+
4+
The sketch shows how to use analogWrite API of the Portenta Breakout.
5+
6+
The circuit:
7+
- Portenta H7
8+
- Portenta Breakout
9+
10+
This example code is in the public domain.
11+
*/
12+
#include "Arduino_PortentaBreakout.h"
13+
14+
void setup() {
15+
Serial.begin(9600);
16+
while (!Serial);
17+
18+
//Default write resolution is 8bits
19+
Breakout.analogWriteResolution(8);
20+
21+
//PWM0 and PWM3 are using HRTIM peripheral and minimum frequency is 760Hz
22+
Breakout.analogWrite(PWM0, 25);
23+
Breakout.analogWrite(PWM1, 50);
24+
Breakout.analogWrite(PWM2, 75);
25+
Breakout.analogWrite(PWM3, 100);
26+
// PWM4 and PWM8 are sharing the same timer channel therefore is not possible
27+
// to use both outputs at the same time
28+
Breakout.analogWrite(PWM4, 125);
29+
Breakout.analogWrite(PWM5, 150);
30+
Breakout.analogWrite(PWM6, 175);
31+
Breakout.analogWrite(PWM7, 200);
32+
//Breakout.analogWrite(PWM8, 225);
33+
Breakout.analogWrite(PWM9, 250);
34+
}
35+
36+
void loop() {
37+
delay(100);
38+
}

src/Arduino_PortentaBreakout.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
3434
#include <PDM.h>
3535
#include <Portenta_Ethernet.h>
3636
#include <Ethernet.h>
37-
#include "utility/Analog/Analog.h"
3837
#include "utility/RTC/RTC.h"
3938

4039
#define LAST_ARDUINO_PIN_NUMBER LEDB + 1
@@ -198,12 +197,12 @@ class BreakoutCarrierClass {
198197
}
199198
void analogWrite(breakoutPin pin, int val) {
200199
if (pin > -1) {
201-
BreakoutPWM::analogWrite((int)pin, val);
200+
::analogWrite((int)pin, val);
202201
}
203202
return;
204203
}
205204
void analogWriteResolution(int bits) {
206-
BreakoutPWM::analogWriteResolution(bits);
205+
::analogWriteResolution(bits);
207206
}
208207
int analogRead(breakoutPin pin) {
209208
if (pin > -1) {

src/utility/Analog/Analog.cpp

Lines changed: 0 additions & 73 deletions
This file was deleted.

src/utility/Analog/Analog.h

Lines changed: 0 additions & 179 deletions
This file was deleted.

0 commit comments

Comments
 (0)