This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

WL1831MOD: HCI Commands for PCM HSP Audio

Part Number: WL1831MOD
Other Parts Discussed in Thread: WL1831

I have a system that provides two-way PCM audio on I2S connected to the WL1831MOD that needs to be routed to a Bluetooth headset using first HSP then, eventually HFP profile. The audio is 8 kHz, stereo, 16-bit.

I am able to pair and connect to the headset and have been able to stream audio to the headset over the UART HCI - A2DP and HSP over HCI (after issuing VS HCI command (0xFE10). However, I need to take the audio from the I2S interface instead of the HCI interface.

I believe that I have properly configured the codec in the WL1831 (with VS HCI 0xFE06) and have setup the synchronous connection (with HCI 0x0128). I am not using 0xFE06 in this instance - I want PCM audio. I am able to see the AT+CKPD=200, AT+VGS and AT+VGM commands in btmon on the host, but have no host audio at the headset and no headset audio at the host. I can see the PCM_CLK, PCM_SYNC, and PCM data toward the WL1831MOD (from my host), but never PCM data from the WL1831MOD (toward my host).

I feel like it is a configuration issue either with the WL1831 codec or the synchronous connection. The following are the current configuration of both: 

hcitool -i hci0 cmd 0x3f 0x106 0x01 0x00 0x01 0x00 0x00 0x1f 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x10 0x00 0x01 0x00 0x00 0x10 0x00 0x01 0x00 0x00 0x00 0x01 0x00 0x11 0x00 0x01 0x00 0x00 0x11 0x00 0x00

hcitool -i hci0 cmd 0x01 0x0028 0x01 0x00 0x40 0x1f 0x00 0x00 0x40 0x1f 0x00 0x00 0x0a 0x00 0x00 0x00 0x01 0x01 0x00

Can you help?

  • Hi Mitch,

    I will follow up here next week.

    Thanks,
    Jacob

  • Hi Jacob-

    Thanks. Looking forward to your follow up.

    -Mitch

  • Hi Jacob-

    Any suggestions for the issue described above?

    Thanks, -MItch

  • Hi Mitch,

    I'll follow up later today. By the way, are you using the BlueZ stack, or the BluetopiaPM build for Linux? 

    Thanks,
    Jacob

  • Thanks, Jacob.

    We are currently using BlueZ 5.50 but could consider moving to Bluetopia if that makes sense.

    -Mitch

  • Hey Mitch,

    Are you trying to configure the WL1831 for I2S follower? I'll double check your commands but I wanted to confirm.

    Thanks,
    Jacob 

  • I need for the WL1831 to be slave on the I2S bus. I realize that some of the parameters in the 0xFE06 command may not be quite right. I have, however, tried many combinations and have never seen the WL1831 output data on BT Audio Out (pin 57) when there is PCM_CLK and PCM_SYNC present on pins 60 and 58, respectively. Please help me understand if this is simply an issue with the parameters or if I am missing something else altogether.
    Thanks, -Mitch

  • Hi Mitch,

    Can you provide your HCI commands in this format before you convert it to the hcitool format? 

    It looks like the third parameter you pass in only specifies a length of 1:

    hcitool -i hci0 cmd 0x3f 0x106 0x01 0x00 0x01 0x00 0x00 0x1f 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x10 0x00 0x01 0x00 0x00 0x10 0x00 0x01 0x00 0x00 0x00 0x01 0x00 0x11 0x00 0x01 0x00 0x00 0x11 0x00 0x00

    Also, I could not find the 0x0128 HCI synchronous connection command. Are you trying to use this command instead?

    Thanks,
    Jacob

  • I think this is what the first command I sent you should look like in the requested format:

    Again, I'm not sure I have the parameters right. I'm looking for some guidance.

    As far as the third parameter in the hcitool command goes, based on this example found in the forum (https://e2e.ti.com/support/wireless-connectivity/wi-fi-group/wifi/f/wi-fi-forum/451013/why-is-sound-distorted-when-using-wl18xx-hfp-hsp-over-hci):

    e.g.)
    # Route SCO connection over HCI instead of PCM
    hcitool -i hci0 cmd 0x3f 0x210 0x01 0x00 0x00 0x00 0xFF > /dev/null

    it doesn't look like the hcitool command requires a length parameter. Am I mistaken? I can find no reference to the 0xFE10 (0x3f 0x210) command (mentioned in that link) to know whether it takes four or five parameters. Either way the third parameter in the command is 0x01 which doesn't make sense. It should be 0x04 if the following four bytes are the parameters.

    Regarding the 0x0128 command... I took that from a btmon trace. From looking at the Core v4.2 specification, I think the "01" is correct - it's a Link Control Command. However, I am not sure the parameters in the command are correct or if that is all that is necessary to start the WL1831 sending the received headset audio out on pin 57 (BT Audio Out).

    Note that I am trying to start the audio outside of the bluetooth stack by manually issuing the 0x0128 command because I believe the Bluez stack will only send/receive SCO audio via the HCI interface and I need the WL1831 to send/receive audio via the I2S interface.

    Questions...
    If the WL1831 is setup for slave mode and there is a bluetooth headset connected, and there is a PCM clock and sync signal on pins 60 and 58, will the WL1831 put the received headset audio data onto pin 57? Or, is there more required? Vendor specific commands? Core BT commands? Or both? And, do I have the WL1831 codec set up properly for 8 kHz, 16-bit, two channel audio?

    Thanks again for your help. -Mitch

  • Hi Mitch,

    Overall, your codec configuration looks pretty good. Thank you for putting it in the table format for me. The only change I recommend is to have your channel out_edges match each other and in_edges match each other too. For example, your out_edges could both be falling and your in_edges could both be rising depending on your use case. 

    Do you see any data over the I2S line? 

    I'll follow up on your other questions later this week.

    Thanks,
    Jacob

  • Hi Jacob-

    I will have a look at the edge directions per your suggestion. Regarding I2S data... No. That is the issue. There is no data produced on pin 57 (BT_AUD_OUT). Should there be for the conditions and configuration I have provided (see my last post and the questions at the end)?

    Thanks, -Mitch

  • Hi Mitch,

    If the WL1831 is setup for slave mode and there is a bluetooth headset connected, and there is a PCM clock and sync signal on pins 60 and 58, will the WL1831 put the received headset audio data onto pin 57? Or, is there more required? Vendor specific commands? Core BT commands? Or both? And, do I have the WL1831 codec set up properly for 8 kHz, 16-bit, two channel audio?

    If you have the PCM signals connected (BT_AUD_IN, BT_AUD_OUT, BT_AUD_FSYNC, BT_AUD_CLK), you should see output on the BT_AUD_OUT pin (pin 57). You should only need the HCI_VS_Write_CODEC_Config (0xFD06) that you are using to enable the PCM interface.

    Is your WL1831 PCM interface connected to your BlueZ Linux host or is it connected to an external audio codec?

    Thanks,
    Jacob

  • Hi Jacob-

    There are active PCM signals present on BT_AUD_IN, BT_AUD_FSYNC and BT_AUD_CLK. The WL1831 PCM is connected to the BlueZ Linux host, but BlueZ is not aware of the PCM audio - it is being generated by a cellular modem. I am trying to connect the cellular audio to a BT-connected headset.

    Thanks, -Mitch

  • Hi Mitch,

    I'll follow up here later this week.

    Thanks,
    Jacob

  • Hi Mitch,

    I generated an hcitool command from the picture you sent above. It looks nearly identical, except the length specification is 0x00 instead of 0x01. Can you try this value instead?

    hcitool -i hci0 cmd 0x3f 0x106 0x01 0x00 0x01 0x00 0x00 0x1f 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x10 0x00 0x01 0x00 0x00 0x10 0x00 0x01 0x00 0x00 0x00 0x01 0x00 0x11 0x00 0x01 0x00 0x00 0x11 0x00 0x00

    Converted hcitool:

    hcitool cmd 0x3f 0x0106 0x00 0x01 0x01 0x40 0x1f 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x10 0x00 0x01 0x00 0x00 0x10 0x00 0x01 0x00 0x00 0x00 0x10 0x00 0x11 0x00 0x00 0x10 0x00 0x11 0x00 0x00 0x00

    If that does not solve the issue, can you try configuring your edges to be the opposite of the codec? Make sure that the WL1831 frame sync edge is using the opposite edge than the edge the audio codec is sampling/asserting. If the audio codec is asserting on the rising edge, you should use the falling edge on the WL1831. 

    Finally, if both of those do not help, can you try running a loopback test:

    Try using the same Send_HCI_VS_Write_CODEC_Config command you just tried, but changing the PCM Direction to be 0x00 (Master). This is important so that the WL1831 device is driving the clock. Next, can you run the HCI_VS_Set_Pcm_Loopback_Enable (0xFE28) command immediately after to loop audio on your device? You should then be able to either listen to the audio being sent to the device or scope the AUD_IN and AUD_OUT pins to ensure the audio is not getting corrupted. You do not need a Bluetooth connection for this test as it is a local test for the PCM interface.

    If you observe noise and/or corrupted data, the PCM configuration is the problem. Otherwise, it is a Bluetooth issue.

    Thanks,
    Jacob