STM32 & MCP4922 DAC

309 views
Skip to first unread message

Johannes Steinlein

unread,
Jan 4, 2020, 4:53:14 PM1/4/20
to Mozzi-users
Hey everyone,

so i'm planning on building a Synthesizer Prototyping PCB and due to that, i made some tests using an external DAC (MCP4922) with Mozzi.
On an Arduino everything compiles fine, but if i try to compile for an STM32 Blue Pill,the DAC_MCP49xx-Library throws errors, because it uses direct port manipulation and is not STM32 capable

Does anyone now how Direct Port Manipilation on an STM32 works and how i can fix this?
In the Library PB2 is used, for the STM32 PB8 needs to be used.
However, the PORTB-Macro doesn't seem to exist in the STM-Implementation for Arduino.

I really would like to make my ProtoBoard run with an STM32 instead of and ArduinoNano :-)

Thanks everyone!
Skulk

Johannes Steinlein

unread,
Jan 9, 2020, 1:39:19 PM1/9/20
to Mozzi-users
So it seems i've figured it out in the meantime. I'll leve it here, for other to find.

Maybe someday a rewritten DAC-Library finds its way into mozzi?


// Set PB8 to Output, leave all others untouched (CRH sets Pins 8-16, CRL 0-7)
  GPIOB->regs->CRH = (GPIOB->regs->CRH & 0xFFFFFFF0| 0x00000000 |0x00000003;

  // Set PB8 to High
  GPIOB->regs->BSRR = 0b0000000100000000;

  // Set PB8 to Low
  GPIOB->regs->BSRR = 0b0000000100000000 << 16;

I have not yet tested this, but it compiles fine.

Bayonet

unread,
Feb 8, 2020, 5:20:54 AM2/8/20
to Mozzi-users
Have you tested this out yet? I'm thinking of picking up an STM32 or ESP32, whichever works better. I have a different library because I was having compilation issues. Give this a try if your bodge doesn't work

https://github.com/helgenodland/MCP4922-Arduino-SPI-Library

Tom Combriat

unread,
May 20, 2020, 7:44:31 AM5/20/20
to Mozzi-users
Hi,
A new support for external way of outputting the sound has been recently added: https://github.com/sensorium/Mozzi/commit/f0b8080551b68a4cff1fb911cd88e7a82ccf2895 there is no example for MCP49XX series for now, but it will come in near futur. That should be very easy to implement in this context if you want to give it a try!
Best,

Jebus Rice

unread,
Jun 16, 2020, 6:50:55 PM6/16/20
to Mozzi-users
Hi!

Has anyone got an MCP4822 to work as the external DAC for mozzi?  I have 4 of these sitting around not doing much.

Not sure how different these are to the MCP4922.

JR

Tom Combriat

unread,
Jun 17, 2020, 11:54:34 AM6/17/20
to Mozzi-users
Hey!

They are completely compatible, only the voltage reference is different. This PR has been tested with both MCP49xx and MCP48xx, for both Arduino AVR and STM32!
Tom
Reply all
Reply to author
Forward
0 new messages