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

Add blackpill+PCM5102A example #1

Open
elagil opened this issue Dec 22, 2024 · 91 comments · May be fixed by #2
Open

Add blackpill+PCM5102A example #1

elagil opened this issue Dec 22, 2024 · 91 comments · May be fixed by #2

Comments

@elagil
Copy link
Contributor

elagil commented Dec 22, 2024

Create firmware for Blackpill + PCM5102A DAC, based on blus_mini_mk1

@litezxc
Copy link

litezxc commented Dec 22, 2024

I can write hse and other parameters for 0% errors on 48khz
32-bit: 384 5 12 1 48000 0.0000%
RCC_OscInitStruct.PLL.PLLM = 25;
RCC_OscInitStruct.PLL.PLLN = 336;
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4;
RCC_OscInitStruct.PLL.PLLQ = 7;
PeriphClkInitStruct.PLLI2S.PLLI2SN = 384;
PeriphClkInitStruct.PLLI2S.PLLI2SR = 5;

@elagil
Copy link
Contributor Author

elagil commented Dec 22, 2024

That will help with the setup. What pins for I2S do you use?

@litezxc
Copy link

litezxc commented Dec 22, 2024

V5+ VIN
GND GND
B12 (i2s2_ws) LCK
B15 (i2s2_sd) DIN
B10 (i2s2_ck) BCK
GND SCK

@elagil
Copy link
Contributor Author

elagil commented Dec 22, 2024

Please extract and flash. I hope it shows up on USB.
This is an elf file.

blackpill_pcm5102a.zip

@litezxc
Copy link

litezxc commented Dec 22, 2024

one sec

@elagil elagil linked a pull request Dec 22, 2024 that will close this issue
@litezxc
Copy link

litezxc commented Dec 22, 2024

log

@elagil
Copy link
Contributor Author

elagil commented Dec 22, 2024

I guess you need a bin file then, not an elf?

@litezxc
Copy link

litezxc commented Dec 22, 2024

may be:)

@elagil
Copy link
Contributor Author

elagil commented Dec 22, 2024

Let's try ;)
firmware.bin.zip

@litezxc
Copy link

litezxc commented Dec 22, 2024

yes, sir!

@litezxc
Copy link

litezxc commented Dec 22, 2024

log2

@elagil
Copy link
Contributor Author

elagil commented Dec 22, 2024

Do you have a field to enter it?

@litezxc
Copy link

litezxc commented Dec 22, 2024

what is it? :)

@elagil
Copy link
Contributor Author

elagil commented Dec 22, 2024

I think 0x08000000

@litezxc
Copy link

litezxc commented Dec 22, 2024

maybe hex file?

@elagil
Copy link
Contributor Author

elagil commented Dec 22, 2024

What do you mean? Do you not have a field for the start address?

@litezxc
Copy link

litezxc commented Dec 22, 2024

log3

@elagil
Copy link
Contributor Author

elagil commented Dec 22, 2024

Use "Start address"

@litezxc
Copy link

litezxc commented Dec 22, 2024

How? Im sorry Im stupid 🥇

@elagil
Copy link
Contributor Author

elagil commented Dec 22, 2024

Below file path, there is a start address field. You just enter 0x08000000 in it

@litezxc
Copy link

litezxc commented Dec 22, 2024

log4

Device did not show up

@elagil
Copy link
Contributor Author

elagil commented Dec 22, 2024

Did you disconnect/reconnect usb? That might be necessary.

@litezxc
Copy link

litezxc commented Dec 22, 2024

Yes

@elagil
Copy link
Contributor Author

elagil commented Dec 22, 2024

I will check what might be wrong, probably some clock setting

@elagil
Copy link
Contributor Author

elagil commented Dec 22, 2024

Ok, maybe this one. Disables VBUS detection. It might not be present on your device.

firmware.bin.zip

@litezxc
Copy link

litezxc commented Dec 22, 2024

If a reason is found, then that project might also work 💯

@litezxc
Copy link

litezxc commented Dec 22, 2024

No device

@litezxc
Copy link

litezxc commented Dec 22, 2024

Maybe there is a problem with the initialization of the USB audio device or OTG?

@elagil
Copy link
Contributor Author

elagil commented Dec 22, 2024

It could be anything.. Do you see an unrecognized device in device manager?
Hard to debug without the debugger or panic messages.

@litezxc
Copy link

litezxc commented Dec 23, 2024

image

According to my observations, only frequencies with 0% errors can be used with this DAC, as even 0.01% errors result in sound distortion.
According to the table, only 16/96 and 32/48 are suitable for high-quality output on this equipment. I'm going to sleep, see you later!

@litezxc
Copy link

litezxc commented Dec 24, 2024

@elagil
Copy link
Contributor Author

elagil commented Dec 24, 2024

Probably I won't have time to debug this until next year. Then I can test with some hardware that I have, which is similar to a blackpill.

@litezxc
Copy link

litezxc commented Dec 24, 2024

the only issue is with sound transmission, while everything else is already defined and working great ^^

@litezxc
Copy link

litezxc commented Jan 2, 2025

Happy New Year!

@elagil
Copy link
Contributor Author

elagil commented Jan 2, 2025

Happy new year! I had some time to test. Please try!
There is a potential bug in the I2S driver of embassy which this works around.

firmware.bin.zip

@litezxc
Copy link

litezxc commented Jan 3, 2025

It works :)

@litezxc
Copy link

litezxc commented Jan 3, 2025

The volume control is not working, but sounds great!

@litezxc
Copy link

litezxc commented Jan 3, 2025

Sometimes there is white noise instead of music, but if you refresh the page, everything is fine.

@elagil
Copy link
Contributor Author

elagil commented Jan 3, 2025

What do you mean by white noise? Does it sound like a quickly repeating sound?

Please try this one. It should also enable volume control.
firmware.bin.zip

@litezxc
Copy link

litezxc commented Jan 3, 2025

01033.zip

Sometimes it sounds like this :) Volume control is now working!!!

@elagil
Copy link
Contributor Author

elagil commented Jan 3, 2025

Cool! That does really sound like white noise. When does it occur?

@litezxc
Copy link

litezxc commented Jan 3, 2025

It manifests chaotically, it can happen in the middle of a song or right away :) It can be fixed either by restarting the controller or by refreshing the page several times.

@elagil
Copy link
Contributor Author

elagil commented Jan 3, 2025

Ok, that shouldn't happen of course. I will try to find out why it happens.

@litezxc
Copy link

litezxc commented Jan 3, 2025

I feel like the solution is somewhere nearby; it might be the buffers

@elagil
Copy link
Contributor Author

elagil commented Jan 3, 2025

firmware.bin.zip

Please try that, I changed some logic. Might not change anything.

@litezxc
Copy link

litezxc commented Jan 3, 2025

Right now, there is nothing but noise, and resetting the controller doesn't help, but at least it's stable ;)

@elagil
Copy link
Contributor Author

elagil commented Jan 3, 2025

Interesting! Not sure why that is yet.

@litezxc
Copy link

litezxc commented Jan 3, 2025

If we try to double the buffers, we will immediately understand if that's the issue, and we can also check the L2S frequency next time

@litezxc
Copy link

litezxc commented Jan 16, 2025

Hi, bro! How are you? Do you have any projects in mind that you would like to work on?

@elagil
Copy link
Contributor Author

elagil commented Jan 18, 2025

Hi there! This one isn't quite fixed yet ;)

@litezxc
Copy link

litezxc commented Jan 18, 2025

Do you think it’s feasible to use two L2S outputs simultaneously, connecting a separate DAC to each output? This way, we get the following options:

-4 channels
-2 channels single-ended
-And if we invert one channel of each DAC, we can have 2 differential outputs :)

@litezxc
Copy link

litezxc commented Jan 18, 2025

Image

I just don't know if it's possible to use a common HSE for both outputs and whether there will be perfect synchronization between the channels :)

As for the inversion code, we can try to adapt it from SigmaStudio :)

And one more question regarding the delay when inverting. Theoretically, there shouldn't be any delay since resource consumption is minimal :)

That's the deal, bro :)

@litezxc
Copy link

litezxc commented Jan 18, 2025

By the way, I was playing around with:

-PeriphClkInitStruct.PLLI2S.PLLI2SN
-PeriphClkInitStruct.PLLI2S.PLLI2SR

in another project and got the same drops and white noise as in our project. Could this be the issue? :)

How to create drops and white noise:

I opened main.c and changed the parameters mentioned above, and voila - noise and drops! :)

@elagil
Copy link
Contributor Author

elagil commented Jan 19, 2025

Yes, it could be the issue, but it's hard to check the clocks without hardware. I cannot replicate on my setup (I don't have a blackpill).

Do you think it’s feasible to use two L2S outputs simultaneously, connecting a separate DAC to each output? This way, we get the following options:

Why not use the same I2S for multiple DACs? Also, there are differential DACs already, so no need to invert yourself.

@litezxc
Copy link

litezxc commented Jan 19, 2025

Sad but thrue :)

You can do without DACs at all if you use sigma-delta modulation and PWM output, but you'll have to do a bit of soldering :) like in this example, 32 bits 384 kHz https://github.com/beefdeadbeef/f4uac

By the way, do you have Keil Vision?

@elagil
Copy link
Contributor Author

elagil commented Jan 19, 2025

Interesting! Doesn't quite reach dynamic range of CD audio, but probably close enough.

No, I don't have Keil.

@litezxc
Copy link

litezxc commented Jan 19, 2025

Do you know if it's possible to build a project without using Keil Vision? The software no longer supports older versions of compilers, and it's just a mess there? :)

@litezxc
Copy link

litezxc commented Jan 19, 2025

Here are some sigma-delta projects that work on the 401 and 411 tablets. I tried the one that uses a DAC, but everything works much better without sigma-delta :)

https://github.com/sdima1357/stm32f401cdu6_Audio
https://github.com/sdima1357/stm32f401ccAudioNative

@elagil
Copy link
Contributor Author

elagil commented Jan 19, 2025

Do you know if it's possible to build a project without using Keil Vision? The software no longer supports older versions of compilers, and it's just a mess there? :)

Sorry, I am not familiar with the Keil ecosystem. You may have to convert a Keil project to something like make/CMake + GCC, in order to build it differently. See for example https://cmake.org/cmake/help/book/mastering-cmake/chapter/Converting%20Existing%20Systems%20To%20CMake.html

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 a pull request may close this issue.

2 participants