cancel
Showing results for 
Search instead for 
Did you mean: 

SAI1_SD_A Pin Change Issue in Project BVLINKWB1 V2.0.0

dogukanbos
Associate

Hi All,

I am using a P-NUCLEO-WB55 development board in BVLINKWB1_V2.0.0 project. 
Project ST Link Here: https://www.st.com/en/embedded-software/fp-aud-bvlinkwb1.html

In this project, I would like to change the SAI1_SD_PIN from PA10 to PB15 in P-NUCLEO-WB55 board. But I faced a weird situation which is excessive noise. I will appreciate if you can help me to solve the problem. During this journey, I will mention about my progress step by step to be clear. I'm just a beginner with PDM microphones. As much as I learned, I had some trials in line with my needs. In this process, I'm sorry if I have made some mistakes that annoy you or that should not be done.


In this project, if I directly build and upload the .elf file the firmware is working very well. You can listen the recorded voice (voice name "PA10_Test_Record.wav") that was recorded by "ST BLE Sensor Classic" IOS app through P-NUCLEO-WB55.

As you can see the screenshot below: (The voice can be seen clearly)
0_PA10_Successfull_Test.png

Until here everything is OK.

From below

 

// cca02m2_audio.h file

#define AUDIO_IN_SAI_SCK_PIN                                     GPIO_PIN_8
#define AUDIO_IN_SAI_SCK_GPIO_PORT                               GPIOA
#define AUDIO_IN_SAI_SCK_GPIO_CLK_ENABLE()                       __GPIOA_CLK_ENABLE()
#define AUDIO_IN_SAI_SCK_AF                                      GPIO_AF3_SAI1

#define AUDIO_IN_SAI_SD_PIN                                    	GPIO_PIN_10
#define AUDIO_IN_SAI_SD_GPIO_PORT                              	GPIOA
#define AUDIO_IN_SAI_SD_GPIO_CLK_ENABLE()                     	__GPIOA_CLK_ENABLE();
#define AUDIO_IN_SAI_SD_AF                                     	GPIO_AF3_SAI1

 

 

 

// In CCA02M2_AUDIO_IN_Init function

hAudioInSai.Init.PdmInit.Activation 	= ENABLE;
hAudioInSai.Init.PdmInit.ClockEnable 	= SAI_PDM_CLOCK2_ENABLE;

hAudioInSai.FrameInit.FrameLength = 16;

if ( AudioInCtx[Instance].ChannelsNbr <= 2U)
{        
	hAudioInSai.Init.PdmInit.MicPairsNbr = 1;
	hAudioInSai.Init.AudioFrequency = ((PDM_Clock_Freq * 1000U) / hAudioInSai.FrameInit.FrameLength ) * 1U;
}
else
{
	hAudioInSai.Init.PdmInit.MicPairsNbr = 2;
	hAudioInSai.Init.AudioFrequency = ((PDM_Clock_Freq * 1000U) / hAudioInSai.FrameInit.FrameLength ) * 2U;
}

 


To below:

 

// cca02m2_audio.h file

#define AUDIO_IN_SAI_SCK_PIN                                     GPIO_PIN_8
#define AUDIO_IN_SAI_SCK_GPIO_PORT                               GPIOA
#define AUDIO_IN_SAI_SCK_GPIO_CLK_ENABLE()                       __GPIOA_CLK_ENABLE()
#define AUDIO_IN_SAI_SCK_AF                                      GPIO_AF13_SAI1

#define AUDIO_IN_SAI_SD_PIN                                    	GPIO_PIN_15
#define AUDIO_IN_SAI_SD_GPIO_PORT                              	GPIOB
#define AUDIO_IN_SAI_SD_GPIO_CLK_ENABLE()                      	__GPIOB_CLK_ENABLE();
#define AUDIO_IN_SAI_SD_AF                                     	GPIO_AF13_SAI1

 

Also, I edited some lines into "CCA02M2_AUDIO_IN_Init" function like below:

 

// In CCA02M2_AUDIO_IN_Init function

hAudioInSai.Init.PdmInit.Activation 	= DISABLE;
//hAudioInSai.Init.PdmInit.ClockEnable 	= SAI_PDM_CLOCK2_ENABLE;

hAudioInSai.FrameInit.FrameLength = 16;

if ( AudioInCtx[Instance].ChannelsNbr <= 2U)
{        
	hAudioInSai.Init.PdmInit.MicPairsNbr = 1;
	hAudioInSai.Init.AudioFrequency = ((PDM_Clock_Freq * 1000U) / hAudioInSai.FrameInit.FrameLength ) * 1U;
}
else
{
	hAudioInSai.Init.PdmInit.MicPairsNbr = 2;
	hAudioInSai.Init.AudioFrequency = ((PDM_Clock_Freq * 1000U) / hAudioInSai.FrameInit.FrameLength ) * 2U;
}

 


After, these changes, I recorded the voice and it was too noisy like recording a voice during driving an open car. Sensitivity was decreased. I have to be close to the microphone around 2-3 cm to record my voice. (Normally 30 cm was pretty enough to hear the voice) You can see the output result below: (Same sound, closer distance) In addition, you can find the voice record in the attachment as "PB15_Noisy_Test_Record.wav"

2_Noisy_Changed_PB15_Pin.png


 I must change PA10 pin to PB15 pin. Because the only available pin was PB15 on my design. If you ask me why you changed AF number you can see the table from STM32WB55 datasheet:

Default project AF Pins:
Default_Alternate_Functions.png

After change AF Pins:
Desired_Alternate_Functions.png

As a result, I should be able to run the project in the same way by using the PB15 pin instead of the PA10 pin on the default project pins PA8 clock and PA10 data pins.

Thank you for your time.

1 REPLY 1
Federica Bossi
ST Employee

Hi @dogukanbos ,

Welcome to ST Community!

What sounds strange to me is: Why do you change the alternate function of PA8 from
#define AUDIO_IN_SAI_SCK_AF GPIO_AF3_SAI1 to #define AUDIO_IN_SAI_SCK_AF GPIO_AF13_SAI1 ?

And why you disable PDM from:
hAudioInSai.Init.PdmInit.Activation = ENABLE;
hAudioInSai.Init.PdmInit.ClockEnable = SAI_PDM_CLOCK2_ENABLE;
to:
hAudioInSai.Init.PdmInit.Activation = DISABLE;
//hAudioInSai.Init.PdmInit.ClockEnable = SAI_PDM_CLOCK2_ENABLE;

I think your problem is related to these changes.

If this helps you, please mark my answer as "Best Answer" by clicking on the "Accept as Solution" button, this can be helpful for Community users to find this solution faster.

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.