Skip navigation
Home > All Places > Software Forums > WICED Studio Bluetooth > WICED Studio Bluetooth Forums > Blog > Authors AnjanaM_61

The I2S or PCM clock of CYW20706 can’t be set by the application. The audio firmware / hardware control this based on the current audio stream bit depth, sample rate, number of channels etc.




On the CYW20706, I2S is used for routing audio samples while using the A2DP profile. The direction of the audio samples depends on the A2DP role of the device. If the CYW20706 is configured as a source, then audio samples are received from a hardware codec over I2S. If configured as a sink, then the audio samples are transmitted from CYW20706 to the hardware codec.

In A2DP applications, the audio data is routed over I2S by default and or when the route is configured as AUDIO_ROUTE_I2S. CYW20706 can be configured as the I2S master by setting the is_master flag to TRUE. CYW20706 will then generate the bit clock or SCK based on the sampling frequency negotiated over the A2DP profile. For example, if the CYW20706 negotiates a sampling frequency of 44.1 kHz with the peer Bluetooth device during codec negotiation, then the I2S clock frequency will be set to 44.1 kHz by the internal libraries. The bit depth or word length is set to 16, i.e. frame length is fixed to 32 and cannot be modified. The I2S clock in the master mode can either be 

  • 44.1 KHz x 32 bits per frame = 1411.2 KHz
  • 48 KHz x 32 bits per frame = 1536 KHz

In the slave mode, any clock rate is supported up to a maximum of 3.072 MHz.


Note: If CYW20706 is an A2DP source, you can set the sampling frequency in the application firmware. For example, av_app_cb.audio_sf = 'desired sampling frequency'; in ‘ watch ‘ demo




PCM is a standard method used to digitize audio (particularly voice) for transmission over digital communication channels. CYW20706 includes a PCM interface that can connect to linear PCM codec devices either in master or in slave mode. The PCM interface is used for full duplex bi-directional transfer of 8K or 16K voice samples while using the HFP profile.

The CYW20706 uses 13 bits of the 16 bits in each PCM frame. The remaining three bits need to be ignored at the input device and may be filled with 0s, 1s, a sign bit, or a programmed value on the output. The default format is 13-bit 2’s complement data, left justified, filled with 0's and clocked MSB first.

The PCM clock setting will be done internally based on the sample rate in SCO settings. 

If WBS (wide band speech) is enabled, it will use 16K sample rate , otherwise 8K. Check WICED_BT_HFP_HFP_CODEC_SET_EVT  to check whether WBS enabled or not.

Thus the PCM clock can either be

  • 8khz * 16bit * 2(channel) = 256khz (For narrow band speech)
  • 16khz * 16bit * 2(channel) = 512khz (For wide band speech)

This is taken care by the WICED Stack. You just need to enable or disable WBS in the application project.


SPI example for CYW20706

Posted by AnjanaM_61 Moderator Jan 22, 2019

This application demonstrates how to use SPI driver interface on CYW20706 to send and receive bytes or a stream of bytes over the SPI.


Hardware connections on CYW20706 EVAL:

For SPI Slave use the below pins :

  •   CS   - P26
  • MOSI - P27
  • MISO - P25
  • CLK  - P36

For SPI Master use the below pins :

  •   CS   - P26
  • MOSI - P0
  • MISO - P25
  • CLK  - P36


Test Procedure:

  • Program 1 kit with the spi_master app and another kit with spi_slave app (attached the project).
  • Connect the SPI lines and ground on the 2 kits.
  • Power on the kits. You can see the logs through PUART
  • Reset the SPI master first and then SPI slave.

E-ink Display interface with CYW20719



E-INK (electronic ink) is a paper-like display technology, characterized by high contrast, wide viewing angles, and minimal standby power. Unlike conventional backlit, flat panel displays that emit light, E-INK displays reflect light like paper. This makes E-INK displays more comfortable to read, and provides a wider viewing angle than most light-emitting displays. Therefore, E-INK displays are comfortable to read even in sunlight.

Currently we are using CY8CKIT-028-EPD E-INK Display Shield (EPD) interfaced with CYW20719 Eval board. The E-INK Shield has a 2.7-inch E-INK display with a resolution of 264×176 pixels.

The E-INK display contains a basic driver IC that interfaces with the CYW20719 using a custom SPI interface. The driver converts a serial data stream into individual pixel data and generates the voltages required for the E-INK display. Thus, CYW20719 has low level control to the display through the driver IC.

See the E-INK display driver document for more details.



The CYW20719 controls the E-INK display’s reset, enable, discharge and border pins. The controller check the busy status of display via Busy pin of E-ink display. The table below shows the pin to pin connection between CY8CKIT-028-EPD E-INK Display Shield and CYW20719 Eval board.

Table 1: Pin connections

E-ink Display Shield Pins

Pin Defenition


Pin Configuration on 20719


Display Reset Pin

P0 (D2)

Output pin


Display Busy Pin

P33 (D1)

Input pin


Display Enable Pin

P34 (D0)

Output pin


Discharge Pin

P26 (D5)

Output pin


Border Control Pin

P2 (D6)

Output pin


Display IO Enable Pin

P4 (D7)

Output pin


Eink Select Pin

P7 (D10)

SPI CS pin



P28 (D11)




P1 (D12)




P38 (D13)








  1. 3.3V





IO Ref


Pin Significance:

  1. Display Reset Pin: Reset signal for display. This pin need to pull high and low as defined in the E-INK display driver document.
  2. Display Busy Pin: It’s an input pin for CYW20719. When busy pin is high, EPD stays in busy state and EPD ignores any input data from SPI.
  3. Discharge Pin: Used to discharge the excess voltage in charge pump capacitors during EPD power off. This pin must be set high for EPD discharge when EPD power off.
  4. Display Enable Pin – To control the display On /OFF
  5. Display IO Enable Pin – To control the voltage translator IC between the WICED and display. This pin is specific for CY8CKIT-028-EPD E-INK Display Shield.
  6. Border Control Pin: Around the active area of EPD there is a 0.5mm width blank area called Border. After EPD updates with the constant voltage, the border color may degrade to a gray level that is not as white as the active area. To avoid this phenomenon, we should reset the Border per screen update. All these are taken care in the driver code.
  7. SPI interface pins: Uses SPI MOSI, MISO, SCLK and software controlled CS pins for the SPI communication between display and CYW20719



The CYW20719 uses SPI communication with the driver IC of E-Ink display with a SPI speed maximum upto 24MHz. This E-ink display driver needs a software controlled chip select pin. Thus, make sure you have disabled the hardware SPI CS pin of CYW20719. For that, change the pin configuration of default CS (Chip select) pin (P07) to WICED_GPIO in the wiced_platform_pin_config.c file 

(Path: /20719-B1_Bluetooth/platforms/CYW920719Q40EVB_01/wiced_platform_pin_config.c)

The SPI format for display driver differs from the standard. Thus the E-ink driver code is written in such a way that follows the SPI command and timing described in the E-INK display driver document.



The E-Ink Display driver library provides the user low level APIs to use in their end application code. The various driver APIs are provided in the Appendix A. The driver API definitions are written as per the work flow defined in the E-INK display driver document. As an end user, you need not have to worry about the driver code, rather you must be familiarized with the end level driver APIs defined in Appendix A.

The display driver updates the display with respect to the current frame and previous frame written from the CYW20719 controller to the driver via SPI communication. One frame buffer contains 5808 ((246x176)/8) bytes. For converting the image into 5808 bytes’ frame buffer, you can use the GUI given by display vendor (Given in Appendix B). Check Appendix B for image and text formats supported by this E-ink display.

The procedure to update the display is:

  1. Store new pattern in the memory buffer
  2. Power on the display driver
  3. Initialize the display driver
  4. Update the display stage by stage
  5. Power off the display driver

The driver APIs are taken care of the above steps.

Attached a demo project designed for a sensor hub. The demo uses below custom functions which using low-level display driver APIs:

  • Disp_Initialize() for initializing the display
  • Display_Initial_Screen() for  displaying a initial screen
  • RefreshDisplay() for refreshing the screen with sensor value.


4.1 Display Initial Screen

Figure below shows the flow of code for displaying an initial screen on the E-ink display. First power on the E-ink by sending start commands, which is already taken care in the E-ink library API. Disp_Initialize function will initialize the display functions and create the frame buffer from the image buffer created by GUI given in Appendix B. After that clear the display with a white background by calling Cy_EINK_ShowFrame function. Cy_EINK_ShowFrame function will display the image corresponding to current frame buffer. You must call Cy_EINK_ImageToFrameBuffer() function by passing the pointer for image to displayed before calling Cy_EINK_ShowFrame function. Refer Appendix A for function descriptions.




4.2 Refresh Display



The display need to be updated by the sensor values collected. We have hard coded co-ordinates for displaying each sensor values. The RefreshDisplay function will take the sensor values, convert it to hex values and will update the main frame buffer at specific co-ordinates hard coded in the function. Cy_EINK_TextToFrameBuffer function will convert the sensor values to corresponding bytes which will be embedded into the main frame buffer. This main buffer will be passed to the Cy_EINK_ShowFrame function for displaying the screen with sensor values.


5. EH Kit Display Screen details:

Steps involved in the display configuration

  1. First step is to make an initial screen as shown above with pixel format 246 x 176
  2. Convert the image to 5808 bytes’ frame buffer using the GUI given in Appendix B
  3. Display the initial screen by the steps mentioned in section 4.1
  4. The sensor data is passing as text for time, battery, temperature, pressure etc.
  5. Find the co-ordinates to display the sensor data mentioned in step 4 by using Cy_EINK_TextToFrameBuffer() API by trial and error method.
  6. Once you fix the co-ordinates in step 5, hardcode the co-ordinates in function RefreshDisplay() and update only the values in that co-ordinates in timely basis.


Note: Attached the Appendix as well as demo project file.



Whitelist functionality in BLE allows a Peripheral to filter out the Central devices trying to scan or connect with the device. Based on the advertising filter policy selected,  the BLE peripheral will give the privilege of scanning or connecting only to the Centrals in whitelist . Whereas for a Central, if filter policy is set ‘whitelist only’, it will process advertisement packets only from the advertisers in the White list.  In this example, the device is configured as a Peripheral where you can select the advertising filter policies as well as you can add the devices to whitelist . Adding to whitelist means that only the Central devices that are added to the Peripheral’s whitelist will be able to receive the scan response packet and establish a connection with it.


APIs Used in the Example Project

  1. Setting advertising filter policy – Using the API wiced_btm_ble_update_advertisement_filter_policy( wiced_bt_ble_advert_filter_policy_t advertising_policy); the device advertising filter policy can be set.

                a. This API can be called either before starting the advertisement or while in advertising state.

                b. This API takes one parameter which defines the type of advertising policy.

    This parameter defines how the scan and connection requests are filtered

        •   BTM_BLE_ADVERT_FILTER_ALL_CONNECTION_REQ_ALL_SCAN_REQ– Process scan and connect requests from all Central devices.
        • BTM_BLE_ADVERT_FILTER_ALL_CONNECTION_REQ_WHITELIST_SCAN_REQ– Process scan requests only from devices in the White List and connect requests from all devices.
        • BTM_BLE_ADVERT_FILTER_WHITELIST_CONNECTION_REQ_ALL_SCAN_REQ– Process scan requests from all devices and connect requests only from devices in the White List.
        • BTM_BLE_ADVERT_FILTER_WHITELIST_CONNECTION_REQ_WHITELIST_SCAN_REQ– Process scan and connect requests only from devices in the White List.


Check the API details in wiced_bt_ble.h file (Path: /20719-B1_Bluetooth/include/20719/wiced_bt_ble.h)

           c. This API is useful when you want to change the advertising filter policy in runtime.


   2. Adding device to whitelist - Using the WICED   API wiced_bt_ble_update_advertising_white_list(wiced_bool_t add,wiced_bt_device_address_t remote_bda); you can add or remove the devices from  whitelist. In current implementation,  you can add only two devices to the whitelist using this API. If you want        to add more than 2 devices to the device whitelist, then  you can use the Vendor specific command. For that use the WICED API                         wiced_bt_dev_vendor_specific_command with the below parameters.  Check the API details in wiced_bt_dev.h (Path: /20719-B1_Bluetooth/include /20719               /wiced_bt_dev.h)

     a. Example: If you want to add device address 0x00A050112233 to whitelist, call the API                              wiced_bt_dev_vendor_specific_command(opcode,param_length,param_buffer,callback); where

          i) Opcode         : 0xE9 for adding whitelist

          ii) param_length  : 9  bytes

          iii) param_buffer :

          1. Length                    : 0x0E
          2. Address Type          : 0x00
          3. Address                  : 0x33,0x22,0x11,0x50,0xA0,0x00 ( LSB First )
          4. Enabling whitelist     : 0x04

          iv) callback     : call back for command complete

     b. Make sure you are stopping the advertisement before adding the device to whitelist


     3. Removing the device from whitelist: Using the  API wiced_bt_ble_update_advertising_white_list(wiced_bool_t add, wiced_bt_device_address_t      remote_bda); by passing the first parameter as False , the device can be removed from the whitelist. Note that you should call this API when the connection is           down, not in any other BLE states.


     4. To get maximum limit of whitelist: Using the API wiced_bt_ble_get_white_list_size(void); you will get the size of whitelist on the controller side.  Check the API details in wiced_bt_ble.h file.


Steps for Testing


  1. Connect the Eval board to PC and load the whitelist project attached below. Refer to the corresponding Kit User Guide for details on programming the firmware.
  2. Open the teraterm and open peripheral uart port with baud rate 115200bps
  3. You can see the logs as in Figure 1.
  4. Press ‘F’ for selecting the filter policy. For verifying ‘connecting from whitelist’ policy, select either 2 or 3
  5. Press ‘A’ to add the device address to whitelist and enter the device address (12 nibbles of address – MSB first).
  6. Press ‘S’ for starting advertisement. Device will start advertising with device name as ‘Whitelist_Demo’.
  7. Open any of BLE client apps (For example open CySmart app in mobile or PC). Try to connect to the device. The central won’t be able to connect, unless its address is what we added in whitelist (‘0x00A050112233’)
  8. Press ‘D’ to stop advertising.
  9. Make sure you are stopping the advertisement before adding the next device to whitelist.
  10. Refer Figure 1 for Debug logs.


Figure 1: Debug logs for Whitelist DemoLog.png

Filter Blog

By date:
By tag: