Skip to content

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

Closed
wants to merge 2 commits into from
Closed

Conversation

Polyphe
Copy link
Contributor

@Polyphe Polyphe commented Oct 30, 2021

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)

Add NRF52 series
Add PWM for NRF52 series, that works on NRF52832,  and Micro:bit V2 (NRF52833), should work on NRF52840 too.
@runger1101001
Copy link
Member

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.

@Polyphe
Copy link
Contributor Author

Polyphe commented Oct 31, 2021

Hi @runger1101001 ,
You're welcome.
For your information, I tried my library with 3PWM and 6PWM (Micro:bit V2 and NRF52832). I didn't try on stepper motors, because I don't have got any.

@askuric
Copy link
Member

askuric commented Oct 31, 2021

Hey @Polyphe
Thanks for the great work.
Your code is merged in the context of the other PR #127 to the dev branch and it will be present in the next release 😄

@askuric askuric closed this Oct 31, 2021
@runger1101001
Copy link
Member

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];
^~~~~~~~~~~~~~~~

@Polyphe
Copy link
Contributor Author

Polyphe commented Nov 17, 2021 via email

@runger1101001
Copy link
Member

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?

@Polyphe
Copy link
Contributor Author

Polyphe commented Nov 17, 2021 via email

@runger1101001
Copy link
Member

runger1101001 commented Nov 17, 2021

Looks like

  int pA = digitalPinToPinName(pinA); 

compiles on both. Now I will try to test on both platforms.

@runger1101001
Copy link
Member

runger1101001 commented Nov 17, 2021

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.
Still trying on the nRF53832 feather board, it seems to resist all efforts to program it from my Mac so far...

[Edit]
Feather Bluefruit nRF52832 is also working nicely. I get 23000 FOC iterations on that board, I guess the hardware is better than the BLE? Anyway, looks like the nRF52 support is working very well.

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.

3 participants