Teensy 2.0 Mozzi error

38 views
Skip to first unread message

Steve R

unread,
Sep 22, 2024, 2:49:39 PM9/22/24
to Mozzi-users
Good evening

I'm trying to compile some Mozzi code for a Teensy 2.0, and I always get the same error:

c:\Users\squid\Documents\Arduino\libraries\Mozzi/internal/MozziGuts_impl_AVR.hpp: In function 'uint8_t MozziPrivate::adcPinToChannelNum(uint8_t)'

c:\Users\squid\Documents\Arduino\libraries\Mozzi/internal/MozziGuts_impl_AVR.hpp:42:37: error: 'P' was not declared in this scope

  pin = pgm_read_byte(adc_mapping + (P));
                                     ^
exit status 1

I'm using Mozzi 2.0.1 and FixMath 1.0.6, I have the current PJRC Arduino extension, and have the same issue on Arduino on two different computers. 

I have tried compiling even the simplest standard Mozzi example code - e.g. 01.Basics Sinewave, and I still get the same error, so I don't think there's an error in the code.

I've tried compiling the same code for a Leonardo (same 32u4 processor) and the code compiles without any error.

Am I missing something stupid or is this a Mozzi bug?

Thanks

Steve 

tomco...@live.fr

unread,
Sep 22, 2024, 5:35:22 PM9/22/24
to Mozzi-users
Hi,
If I am correct, this is not really a bug but more like an unsupported feature: I think the only Teensy boards supported are from the Teensy3 and Teensy4 families (see https://sensorium.github.io/Mozzi/#supported-boards-output-modes-and-default-pins). I have to say that as I never saw a Teensy2 in my life ;).

If you have the courage you can actually try to port it to Mozzi! Even if you don't you can open an issue on Mozzi's dev page (https://github.com/sensorium/Mozzi) in order to remind us that it is something that might be useful (if that is actually useful for you?). It seems to be based on an ATMega so it should actually be quite close to the Arduino port.

Hope it helps!
Tom

tomco...@live.fr

unread,
Sep 22, 2024, 5:48:20 PM9/22/24
to Mozzi-users
Wait, I might have been wrong… Could you try replacing l.42 of Mozzi/internal/MozziGuts_impl_AVR.hpp:42:37  which read:
pin = pgm_read_byte(adc_mapping + (P));
with
pin = pgm_read_byte(adc_mapping[pin] );
or
pin = pgm_read_byte(adc_mapping +pin);

Steve R

unread,
Sep 23, 2024, 4:33:58 PM9/23/24
to Mozzi-users
Thanks.  The Teensy 2.0 is still listed as supported.  It's a Atmega 32U4 board, similar to the Leonardo and Pro Micro, but is has a USB midi option I want to use.

The code compiles with the Leonardo and Pro Micro, so there isn't an issue with Mozzi and the 32u4.  

I assume the "P" has a function - therefore editing it out of MozziGuts_impl_AVR is likely to have an impact elsewhere, so I've tried adding "int P = 0" at the start of the header file and now it compiles for the Teensy 2.0.  It'll be a while before I have the hardware ready to test it - or find out if I've broken Mozzi...


Steve

tomco...@live.fr

unread,
Sep 24, 2024, 3:06:40 AM9/24/24
to Mozzi-users
Hi again,
> I assume the "P" has a function - therefore editing it out of MozziGuts_impl_AVR is likely to have an impact elsewhere, so I've tried adding "int P = 0" at the start of the header file and now it compiles for the Teensy 2.0.  It'll be a while before I have the hardware ready to test it - or find out if I've broken Mozzi...

Well, not really, it really looks like a typo. Setting P=0 will fix the compilation but it is very likely that the ADC won't work. A fix has been published for Mozzi which I just merged (https://github.com/sensorium/Mozzi/pull/277) it will be included in the next release! Thanks for reporting that!

PS: just to mention because I discovered that recently: The Raspberry Pico (supported by Mozzi) can also do USB-MIDI (see https://github.com/sensorium/Mozzi/issues/263) The op still has some problems to make it run but I had some successes on a standard RP2040 (without Wifi).

Tom

Steve R

unread,
Sep 25, 2024, 6:38:00 PM9/25/24
to Mozzi-users
Thanks for the proper fix - I'll look out for the next release.  My P=0 was just a temporary cludge so I could check for any other issues.

The Raspberry Pico is an alternative.  It doesn't offer enough ADCs for what I want to do and there are linearity issues with those ADCs, but it's USB midi is more interesting. Someone has written USB midi host to serial midi for it - I wonder if it has enough resources to run USB midi host and Mozzi...


Steve 

tomco...@live.fr

unread,
Sep 26, 2024, 4:53:13 AM9/26/24
to Mozzi-users
No problem, will try to throw a Release soon!

> It doesn't offer enough ADCs for what I want to do
Same problem here, I am usually plugging some SPI ADCs to alleviate that. I did not know about the non-linearity, that is a good info! Thanks.

> Someone has written USB midi host to serial midi for it
Would you have a reference? I am also interested ;)


> I wonder if it has enough resources to run USB midi host and Mozzi...
The good thing IMO with the pico is that it has two cores, so Mozzi can cleanly run in a separated core, completely unhindered by communications waiting time and so on.
Reply all
Reply to author
Forward
0 new messages