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

Studio Bluetooth

Not applicable


I have 2 boards: CYW920719Q40EVB-01 and I have set one as an SPI master and the second as an SPI slave following the examples from wiced studio 6.2. The SPI comms between the two boards worked..So far so good!

Problem Description:

Now I want to use one board as a master and to speak with real peripherals (sensors). I chose the bosch BMP280 which also works with SPI and wrote the simplest possible code to speak with it (just to read out the ID register (0XD0),which suppose to reply back with 0X58. No matter what I do the BMP280 does not reply back.

Of course the first thing to do is suspect the sensor since the two cypress boards work together. So I have tested the sensor with an arduino and it works fine, it replies straight back no sweat!

The setting up of the sensor is as correct as I can tell. The code is:


*                                Constants


#define CS WICED_P07

#define START_TIMER 100 /*100 ms timer for start and ack*/

#define MASTER_P38_CLK_P28_MOSI_P01_MISO 0x00261C01 /* Macro for SPI master pin configurations */

#define DEFAULT_FREQUENCY 1000000 /* 1 MHz */

#define my_FREQUENCY 200000 /* 200 KHz */


*                                Function Definitions


  static void spi_master_driver( void );

static void initialize_app( void );



*  Entry point to the application. Initialize the app




    wiced_set_debug_uart( WICED_ROUTE_DEBUG_TO_PUART );




* This functions initializes the SPI and GPIO as well as timer


void initialize_app( void )



    /*Initialize CS GPIO and SPI*/

    wiced_hal_gpio_configure_pin(CS, GPIO_OUTPUT_ENABLE, GPIO_PIN_OUTPUT_HIGH);


    /*Start a timer for 100 ms*/

    wiced_bt_app_start_timer(NULL, START_TIMER, NULL, spi_master_driver);



* This function  exchanges data with the slave


void spi_master_driver( void )




wiced_hal_gpio_set_pin_output(CS, GPIO_PIN_OUTPUT_LOW);

wiced_hal_pspi_exchange_data(SPI1, sizeof(MYTRCBUFFER), &MYTRCBUFFER, &MYRECBUFFER);

wiced_hal_gpio_set_pin_output(CS, GPIO_PIN_OUTPUT_HIGH);

// wiced_hal_pspi_tx_data(SPI1, sizeof(MYTRCBUFFER), &MYTRCBUFFER);

//  wiced_hal_pspi_rx_data(SPI1,sizeof(MYRECBUFFER), MYRECBUFFER);

    WICED_BT_TRACE("Master Sent:%0X, Master Received:%0X, delayrep:%d\n",MYTRCBUFFER, MYRECBUFFER, delayrep);


As you can tell is a very concise code, can't do shorter than that, and as far as I can tell it should work. Needless to say that the BMP280 supports SPI_MODE_3

So to find out what was going on, I have used a digital scope to see how the comms go about and compare the arduino comms with the sensor and the cypress comms with the sensor. It seems that the clock and data (cypress master) start almost together, with a very small difference the clock comes first but the data are raised right after it. When using the arduino as a master the cs, clock and data are more spacious. The waveforms are attached. In both cases 0XD0 is sent, but only when arduino served as a master the BMP280 replied back.

So my question is this: is the BMP280 sensor compatible with the cypress CYW920719? or the cypress SPI is to fast for it and there are compatibility issues? Please let me know so I can choose other sensor if I need to.

With regards,


1 Solution
10 likes received 5 sign-ins First like received

Looks like you are doing an 'exchange' instead of 'tx' followed by 'rx'. When you use the API wiced_hal_pspi_exchange_data you are sending only 8 clock pulses to the sensor and in those 8 pulses 8 bits of data is sent as well as received from the slave. But looking at the datasheet of BMP280 you need to first send the register address as the first 8 bits and then read the data in the next 8 bits. During these 2 operations your CS line should be asserted.

So in your code you need to remove 'wiced_hal_pspi_exchange_data', uncomment 'wiced_hal_pspi_tx_data' and 'wiced_hal_pspi_rx_data' APIs and finally move 'wiced_hal_gpio_set_pin_output(CS, GPIO_PIN_OUTPUT_HIGH);' after 'wiced_hal_pspi_rx_data'

Besides this you need to make sure that in the '/20719-B1_Bluetooth/platforms/CYW920719Q40EVB_01/wiced_platform_pin_config.c' file your CS pin (which is WICED_P07) is configures as 'WICED_GPIO and not as 'WICED_SPI_1_CS'. This is to make sure that the CS pin is not controlled by the SPI HW block but controlled by the application

View solution in original post

10 Replies