Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

PSoC™ 6 Forum Discussions

ravo
Level 5
Level 5
5 solutions authored 100 replies posted 250 sign-ins

Dears I have problem to change sample frequency for USB audio demo project  USB Audio Device (FreeRTOS) https://github.com/Infineon/mtb-example-psoc6-usb-audio-device-freertos in Modus Toolbox 3.0

I modify USB descriptor to include 16000 Hz freq

ravo_1-1670932637897.png

And add new PLL_FREQ definition in audio_app.c

#define PLL_FREQ_FOR_48KHZ 55296000 /* in Hz */
#define PLL_FREQ_FOR_44KHZ 50803200 /* in Hz */
#define PLL_FREQ_FOR_16KHZ 18432000 /* in Hz */

And ofcourse modify app_set_clock to adapt to new freq:

void audio_app_set_clock(uint32_t sample_rate)
{
/* Wait till the CapSense is ready */
while (!touch_is_ready())
{
vTaskDelay(1);
};

switch (sample_rate)
{
case AUDIO_SAMPLING_RATE_48KHZ:
{
cyhal_clock_set_frequency(&pll_clock, PLL_FREQ_FOR_48KHZ, &tolerance_0_p); // PLL_FREQ_FOR_48KHZ
break;
}
case AUDIO_SAMPLING_RATE_44KHZ:
{
cyhal_clock_set_frequency(&pll_clock, PLL_FREQ_FOR_44KHZ, &tolerance_0_p);
break;
}
case AUDIO_SAMPLING_RATE_16KHZ:
{
cyhal_clock_set_frequency(&pll_clock, PLL_FREQ_FOR_16KHZ, &tolerance_0_p);
break;
}
default:
break;

But it did not help, in Windows Repro/HeadPhones  advanced settings ... I see only 24bit/48000 and 24bit/44100 Hz

(before I do any modification - only compiled demo, there was only grayed 48000 Hz)

ravo_2-1670933082595.png

Could somebody help to get it works ?

Regards

Radim

0 Likes
7 Replies
RodolfoGL
Employee
Employee
250 sign-ins 5 comments on KBA First comment on KBA

Every time you change the USB descriptor, you need to make sure to uninstall the USB driver first, otherwise you might have some driver issues on Windows. Alternatively, you can change the PID value in the device descriptor under the device descriptor tree window, so a new device enumerates. 

A side note. Note that this CE originally sets the PLL as the source for the CPU clocks. If you change it to ~18 MHz, you will significantly drop the CPU frequency. You actually can keep the PLL frequency the same as for 48KHz, since both frequencies are multiple.

ravo
Level 5
Level 5
5 solutions authored 100 replies posted 250 sign-ins

Dear @RodolfoGL ,

thanks for mention that it needs to uninstall USB drivers. I just do it once more, but still in USB Audio settings for Speakers there is still only 44100 and 48000 Hz

ravo_0-1671013248222.png

And If I replace 44100 Hz to 16000 Hz in USB desriptors variable tSampFreq = "16000; 48000;" than Windows show only 48000 Hz and it is grayed out(not available to change them)

ravo_0-1671013836799.png

Do you have another idea what could be still wrong ?

Regards

Radim

0 Likes
RodolfoGL
Employee
Employee
250 sign-ins 5 comments on KBA First comment on KBA

The driver might not be uninstalling correctly. Try to change the PID and let the OS re-enumerate it as a new device.

0 Likes
ravo
Level 5
Level 5
5 solutions authored 100 replies posted 250 sign-ins

Dear @RodolfoGL ,

I just tried to modify VID & PID but after re-enumeration, it is same as previous (only grayed out 48kHz). So it did not helped me. I also studied USB Audio from usb.org if I have been omitted something else. But I did not found anything.

Radim

0 Likes
RodolfoGL
Employee
Employee
250 sign-ins 5 comments on KBA First comment on KBA

If you add an additional frequency, you need to go change this #define AUDIO_STREAMING_EPS_NUMBER in audio.h. Currently it is set to 2.

Also try to set the Audio IN and Audio OUT to have the exact same frequencies options. I think the firmware doesn't distinguish between them.

0 Likes
ravo
Level 5
Level 5
5 solutions authored 100 replies posted 250 sign-ins

Dear @RodolfoGL ,

thanks for this info. But it did not help. I try to find where AUDIO_STREAMING_EPS_NUMBER  is used and only in usb_comm.c

is definition

uint8_t usb_comm_sample_frequency[AUDIO_STREAMING_EPS_NUMBER][AUDIO_SAMPLE_FREQ_SIZE];

both def are now 3U

Radim

Radim

0 Likes
ravo
Level 5
Level 5
5 solutions authored 100 replies posted 250 sign-ins

Dear @RodolfoGL 

I verified once again and also using USB Device Tree Viewer utility:

        ------- Audio Streaming Format Type Descriptor --------
bLength                  : 0x11 (17 bytes)
bDescriptorType          : 0x24 (Audio Interface Descriptor)
bDescriptorSubtype       : 0x02 (Format Type)
bFormatType              : 0x01 (FORMAT_TYPE_I)
bNrChannels              : 0x02 (2 channels)
bSubframeSize            : 0x03 (3 bytes per subframe)
bBitResolution           : 0x18 (24 bits per sample)
bSamFreqType             : 0x03 (supports 3 sample frequencies)
tSamFreq[1]              : 0x03E80 (16000 Hz)
tSamFreq[2]              : 0x0AC44 (44100 Hz)
tSamFreq[3]              : 0x0BB80 (48000 Hz)
Data (HexDump)           : 11 24 02 01 02 03 18 03 80 3E 00 44 AC 00 80 BB   .$.......>.D....
                           00                                                .

But still I am unable to view these frequencies in Device Properties and playback frequency is still only 48000 Hz.

Could be another problem here ?

Regards

Radim

 

0 Likes