cancel
Showing results for 
Search instead for 
Did you mean: 

Hello, How would you go about storing the PCM data on an SD card, instead of via USB on the X-NUCLEO-AMICAM1 expansion board? I'm trying to modify the sample code that was provided. Thanks,

DOyad.1
Associate II
 
1 ACCEPTED SOLUTION

Accepted Solutions

Hello @DOyad.1​ 

AudioProcess is the right callback, where 1ms of audio samples are ready to be used in your application.

How are you saving the files? If it is a .wav, have you added the proper header and description in the file before opening it and start saving data?

Look at the example Datalog_Audio available here: https://www.st.com/en/embedded-software/stsw-stlkt01.html

It has been developed on another ST platform, but it is still based on an STM32L4, so porting should be feasible.

Let me know if this can help you

Best regards

Simone

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

View solution in original post

9 REPLIES 9
SimonePradolini
ST Employee

Hello @DOyad.1​ 

It should be feasible, but there is no X-NUCLEO from ST that is natively supporting SD card.

SD card pinout changes in base of the HW provider and depends also from the NUCLEO used; there is no a unique standard to support SD for X-NUCLEO-AMICAM1.

Best regards

Simone

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.
DOyad.1
Associate II

Hi Simone,

I'm using the STM32L476RG board and a MicroSD breakout board for the SD card. I'm using SPI to communicate with the SD card, which works fine.

My issue is saving the PCM data into an SD card. The sample code provided uses the USB interface. I thought it would be straightforward since a function transmits the data over USB. I could just take the PCM data and store it on an SD Card instead of over USB.

When I play back the audio, I get a lot of noise.

0693W00000aIJ4vQAG.pngW_002 is the data stored on the SD card, and Audio Track is audio transmitted over USB.

I've been trying to store the data in the PCM buffer on0693W00000aIJ4lQAG.png the SD card.

Is it possible to store the PCM data on the SD Card, or must something else be done before I can save it onto the SD card?

Thanks,

Daniel

Hi Simone @SPRAD.1​ ,

I'm using the STM32L476RG board and a MicroSD breakout board for the SD card. I'm using SPI to communicate with the SD card, which works fine.

My issue is saving the PCM data into an SD card. The sample code provided uses the USB interface. I thought it would be straightforward since a function transmits the data over USB. I could just take the PCM data and store it on an SD Card instead of over USB.

When I play back the audio, I get a lot of noise.

0693W00000aIJ4vQAG.pngW_002 is the data stored on the SD card, and Audio Track is audio transmitted over USB.

I've been trying to store the data in the PCM buffer on the SD card.0693W00000aIJ4lQAG.png 

Is it possible to store the PCM data on the SD Card, or must something else be done before I can save it onto the SD card?

Thanks,

Daniel

Hello @DOyad.1​ 

AudioProcess is the right callback, where 1ms of audio samples are ready to be used in your application.

How are you saving the files? If it is a .wav, have you added the proper header and description in the file before opening it and start saving data?

Look at the example Datalog_Audio available here: https://www.st.com/en/embedded-software/stsw-stlkt01.html

It has been developed on another ST platform, but it is still based on an STM32L4, so porting should be feasible.

Let me know if this can help you

Best regards

Simone

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

Hello Simone @[SPRAD.1]​ ,

Yes, I added the proper header and description in the .wav file before opening it and saving the data. I even saved the data on a text file and imported the raw PCM data into Audacity. Both files had the same noise.

Thanks for the example!

I will look into it and see if I can get it working. I'll let you know how I get on soon enough. 

Thanks,

Daniel

Hi Simone @[SPRAD.1]​ ,

When I set the SD card buffer size to uint16_t Audio_OUT_Buff[(((AUDIO_IN_CHANNELS * AUDIO_IN_SAMPLING_FREQUENCY) / 1000) * N_MS)*500], I get an ram overflow error when sampling at 192 kHz. I think the sample code is set to 16 kHz. I haven't tried 16 kHz because I would have to desolder a connection on the STM32L476RG as per the X-NUCLEO-AMICAM1 documentation.

Are ye multiplying by 500, so that the buffer size is half the sampling rate?

The screenshot is the main.h file.

0693W00000aIWldQAG.png 

Thanks,

Daniel

Hello Simone @SPRAD.1​,

I got it working.

I'll just have to use a board with more RAM if I want to sample at 192 kHz.

Thanks for all your help,

Daniel

Hi @DOyad.1​ ,

Sorry for the late reply.

I'm happy to see that you got the application working well.

Come back to us for any further support.

Best regards

Simone

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

Hi @SPRAD.1​ ,

That's no problem.

Thanks again for the help.

Best regards,

Daniel