-
Notifications
You must be signed in to change notification settings - Fork 602
Add new MCU support "NRF52 series" #126
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
Conversation
Add NRF52 series
Add PWM for NRF52 series, that works on NRF52832, and Micro:bit V2 (NRF52833), should work on NRF52840 too.
Dear @Polyphe , thank you so much for this! Since NRF52 is currently unsupported, I think it is fine to merge this and let people test. I will merge it locally, since it should be applied to the dev branch, and not master, and there is a conflict to resolve in the generic_mcu.cpp file. |
Hi @runger1101001 , |
So on PlatformIO for Arduino Nano 33 BLE I get some compile errors: /Users/runger/git/Arduino-FOC/src/drivers/hardware_specific/nrf52_mcu.cpp: In function 'void _configure3PWM(long int, int, int, int)': |
Hi,
In fact this comes from variant.cpp under Arduino IDE, this one defines the
number of the pin, so for BLENANO :
const uint32_t g_ADigitalPinMap[] = {
// D0 - D7
11,
9,
10,
8,
28,
29,
15,
17,
// A0 - A4 / D8 - D12
1,
2,
3,
4,
5,
// D13
19,
// A5 / D14
6
}; Pour Micro:bitV2:
const uint32_t g_ADigitalPinMap[] = {
// 0 - 4
2, // A0, LEFT PAD
3, // A1, MIDDLE PAD
4, // A2, RIGHT PAD
31, // A3, COL3
28, // A4, COL1
// 5 - 9
14, // BTN A
37, // COL4, P1.05
11, // COL2
10, // NFC2
9, // NFC1
// 10-16
30, // A5, COL5
23, // BTN B
12,
17, // SCK
1, // MISO
13, // MOSI
34, // P1.02
// 17 + 18
(uint32_t)-1, // 3.3V
(uint32_t)-1, // 3.3V
// 19 + 20
26, // SCL
32, // SDA, P1.00
// 21 - 25
21, // ROW1
22, // ROW2
15, // ROW3
24, // ROW4
19, // ROW5
// 26 - 29
36, // LOGO (touch sensor)
0, // SPEAKER (Note: Must use synthesized LF clock to make this pin
available)
20, // RUN_MIC
5, // A6, MIC_IN
// 30 - 31
16, // I2C_INT_SDA
8, // I2C_INT_SCL
// 32 - 34
25, // COMBINED_SENSOR_INT
40, // RX, P1.08
6, // TX
}; And so on...
Le mer. 17 nov. 2021 à 21:00, runger1101001 ***@***.***> a
écrit :
… So on PlatformIO for Arduino Nano 33 BLE I get some compile errors:
/Users/runger/git/Arduino-FOC/src/drivers/hardware_specific/nrf52_mcu.cpp:
In function 'void _configure3PWM(long int, int, int, int)':
/Users/runger/git/Arduino-FOC/src/drivers/hardware_specific/nrf52_mcu.cpp:111:12:
error: 'g_ADigitalPinMap' was not declared in this scope
int pA = g_ADigitalPinMap[pinA];
^~~~~~~~~~~~~~~~
/Users/runger/git/Arduino-FOC/src/drivers/hardware_specific/nrf52_mcu.cpp:
In function 'void _configure4PWM(long int, int, int, int, int)':
/Users/runger/git/Arduino-FOC/src/drivers/hardware_specific/nrf52_mcu.cpp:162:12:
error: 'g_ADigitalPinMap' was not declared in this scope
int pA = g_ADigitalPinMap[pinA];
^~~~~~~~~~~~~~~~
/Users/runger/git/Arduino-FOC/src/drivers/hardware_specific/nrf52_mcu.cpp:
In function 'int _configure6PWM(long int, float, int, int, int, int, int,
int)':
/Users/runger/git/Arduino-FOC/src/drivers/hardware_specific/nrf52_mcu.cpp:264:14:
error: 'g_ADigitalPinMap' was not declared in this scope
int pA_l = g_ADigitalPinMap[pinA_l];
^~~~~~~~~~~~~~~~
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#126 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AMD2ZST34BMV3IOX55K6BQLUMQCURANCNFSM5HBDPTAA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
Hmmm... I'm still looking into it. It compiled fine for the Feather Bluefruit board, also under PlatformIO, so it is definately board-dependent.
I will find a solution that works with both boards. If I read the code correctly, the point of using the array is to convert Arduino (framework) pin numbers to MCU-specific pin numbers? |
Yes, you are quite right.
Le mer. 17 nov. 2021 à 22:25, runger1101001 ***@***.***> a
écrit :
… Hmmm... I'm still looking into it. It compiled fine for the Feather
Bluefruit board, also under PlatformIO, so it is definately board-dependent.
Might be the case that the feather framework exposes this array in the
headers while Arduino doesn't, or something like this. Arduino Nano 33
NRF52 based boards use the mbed framework, currently version 2.5.2.
And while the Adafruit NRF52 framework clearly defines and uses this
array, the mbed one doesn't seem to have it. It doesn't define it in
variant.cpp, instead it has a
PinDescription g_APinDescription[PINS_COUNT];
I will find a solution that works with both boards. If I read the code
correctly, the point of using the array is to convert Arduino (framework)
pin numbers to MCU-specific pin numbers?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#126 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AMD2ZSTNSITL7BYLV4KAKN3UMQMWDANCNFSM5HBDPTAA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
Looks like
compiles on both. Now I will try to test on both platforms. |
Very nice, I get nice smooth rotation on my 11PP gimbal motor on a Nano 33 BLE, with 6650 FOC iterations/sec - that's using an SPI sensor. [Edit] |
I added PWM drivers for the NRF52 family. I tried the NRF52832 and the Micro:bit V2 (NRF52833), and that works very well.
That should work on NRF52840 like for example Nano BLE33.
This library directly uses the PWM registers of the NRF52, not the NRF library (nrfx_pwm.h)