Skip to content
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

Compatability/Compilation Issues w/ Nano 33 BLE Sense #216

Open
sacerd-OS opened this issue Dec 3, 2023 · 10 comments
Open

Compatability/Compilation Issues w/ Nano 33 BLE Sense #216

sacerd-OS opened this issue Dec 3, 2023 · 10 comments

Comments

@sacerd-OS
Copy link

Board: Nano 33 BLE Sense
Version: GitHub Latest
Steps to Reproduce: Attempt to compile empty sketch onto Nano 33 BLE Sense with MozziGuts.h included

The issue seems to stem from the fact that Mozzi considers the Nano 33 BLE Sense to be of the MBED family (I don't know what this means so I can't interpret). In AudioConfigMBED.h, Mozzi therefore assumes the 33 BLE Sense is compatable with the Arduino AdvancedAnalog library, which it isn't and assumes the board has a pin A13 which it doesn't.

The result is failed compilation and what seems to be a bunch of issues related to the AdvancedAnalog library. Unfortunately this isn't my jam so I can't help fix.

@tomcombriat
Copy link
Collaborator

Related: #200 .

Is this the same board actually?
I don't have one of these, but will try to have a quick look at some point (or someone else).
Thanks for reporting!

@sacerd-OS
Copy link
Author

sacerd-OS commented Dec 3, 2023

Not my wheelhouse, but they don't appear to be the same. The sense is based on nRF52840 and the IOT is based on the SAMD21. The pin layouts seem different, at least. It seems to be in the mbed class of Arduinos, with its own separate listing as mbed_nano for compatability checks.

@tfry-git
Copy link
Collaborator

tfry-git commented Dec 4, 2023

IIRC, the Nano 33 BLE used to work before we added the MBED port (for Arduino Giga/Portenta). Probably it's simply and over-eager hardware detection inside hardware_defines.h, then. Could you try modifiying that file? If you change this line https://github.com/sensorium/Mozzi/blob/cf9e173cd181f2a893f31923aaa0f2ec8e39efbc/hardware_defines.h#L59C6-L59C30 to #if (0), do things work?

If so, at least, we know what's going on, and just need to adjust that define.

@sacerd-OS
Copy link
Author

sacerd-OS commented Dec 10, 2023

IIRC, the Nano 33 BLE used to work before we added the MBED port (for Arduino Giga/Portenta). Probably it's simply and over-eager hardware detection inside hardware_defines.h, then. Could you try modifiying that file? If you change this line https://github.com/sensorium/Mozzi/blob/cf9e173cd181f2a893f31923aaa0f2ec8e39efbc/hardware_defines.h#L59C6-L59C30 to #if (0), do things work?

If so, at least, we know what's going on, and just need to adjust that define.

I get a different error, unfortunately

.../Mozzi/MozziGuts_impl_STM32duino.hpp:13:10: fatal error: HardwareTimer.h: No such file or directory
#include "HardwareTimer.h"
^~~~~~~~~~~~~~~~~
compilation terminated.

exit status 1

Compilation error: exit status 1

On version 1.10 I get an error that I'm missing <STM32ADC.h> (hardware_defines.h line 52), so it wasn't working on that version either.

@tfry-git
Copy link
Collaborator

tfry-git commented Jan 1, 2024

I see now what you already pointed out long ago: The Nano 33 BLE is entirely different from the Nano 33 IoT, with a different CPU, and a different core, too. So it really seems we never supported the BLE so far, despite the fact that the IoT has been reported to work with Mozzi.

It is probably not going to be exceedingly difficult to provide at least basic support for the Nano 33 BLE, but we're currently in the middle of restructuring some internals, and so touching those parts of the code right now would add a lot of complexity. The restructuring will also add some more flexibility for configuration, and with some luck, I think the BLE may actually work out of the box in a PWM mode, with analog input disabled.

Feel free to remind us, should we forget to revisit this issue.

@jonrichings
Copy link

I've hit the same problem. Also using a couple of different nRF52840 modules. This is a growing family so it would be nice to have some support for them.

@tfry-git
Copy link
Collaborator

tfry-git commented Jul 4, 2024

The following compiles with Mozzi 2.0, and might just work (but I don't have a 33 BLE to test with).

#define MOZZI_AUDIO_MODE MOZZI_OUTPUT_EXTERNAL_TIMED
#define MOZZI_ANALOG_READ MOZZI_ANALOG_READ_NONE
#define MOZZI_AUDIO_BITS 12  // wild guess at what might be supported. In case of trouble, try with 8
#include <Mozzi.h>
#include <Oscil.h>
#include <tables/sin2048_int8.h>

Oscil <SIN2048_NUM_CELLS, MOZZI_AUDIO_RATE> aSin(SIN2048_DATA);

void setup(){
  analogWriteResolution(MOZZI_AUDIO_BITS);
  pinMode(D9, OUTPUT);
  startMozzi(); // :)
  aSin.setFreq(440); // set the frequency
}

void audioOutput(AudioOutput out) {
  analogWrite(D9, out.l()+MOZZI_AUDIO_BIAS);
}

void updateControl(){
}
AudioOutput updateAudio(){
  return MonoOutput::from8Bit(aSin.next());
}

void loop(){
  audioHook();
}

@jonrichings
Copy link

Thanks for the try. I still get the same problem though. Looks like the required library, HardwareTimer.h is not available for the nRF52840 based boards.

@tfry-git
Copy link
Collaborator

tfry-git commented Jul 5, 2024

What core are you using? I tested "Arduino Mbed OS Nano Boards".

@jonrichings
Copy link

Adafruit Feather nRF52840 Express and Sense. Since you asked I just tried it on Arduino Nano 33 BLE and that did compile. I can't say for sure it works since I have no speaker on that right now. Maybe it only works on Mbed boards?

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

No branches or pull requests

4 participants