Skip navigation
Home > All Places > WICED Studio Wi-Fi/Combo > WICED Studio Wi-Fi/Combo Forums > Blog > Authors rameshm_61

In present WICED the SPI bit banging clock frequency is set to 1MHz and cannot be changed directly by changing SPI_CLOCK_SPEED_HZ when initializing SPI using wiced_spi_init():


wiced_spi_device_t spi_device =


.port = WICED_SPI_1,

.chip_select = WICED_GPIO_16,



.bits = 8,


wiced_result_t status = wiced_spi_init( &spi_device );


The delay is not set because the macro call SPI_BB_DELAY( cycles ) is not implementing any required delay. For this to enable, one need to define the following macro in platform_spi_i2c.c file (\WICED-Studio-5.0\43xxx_Wi-Fi\WICED\platform\MCU\BCM4390x\peripherals\platform_spi_i2c.c)



This macro will enable the following

#define SPI_BB_DELAY( cycles )                                                          \

    do                                                                                  \

    {                                                                                 \

        uint32_t delay_cycles = cycles;                                                 \

        uint32_t last_stamp  = PLATFORM_APPSCR4->cycle_cnt;                             \


        while (delay_cycles != 0)                                                       \

        {                                                                               \

            uint32_t current_stamp = PLATFORM_APPSCR4->cycle_cnt;                       \

            uint32_t passed_cycles = current_stamp - last_stamp;                        \


            if (passed_cycles >= delay_cycles)                                          \

            {                                                                           \

                break;                                                                  \

            }                                                                           \


            delay_cycles -= passed_cycles;                                              \

            last_stamp = current_stamp;                                                 \

        }                                                                               \

    }                                                                                   \

    while ( 0 )


Note that the delay is calculated by the following expression

spi_bb_clock_toggle_delay_cycles = (((CPU_CLOCK_HZ + (config->speed / 2)) / config->speed) + 1) / 2;

The parameter SPI_CLOCK_SPEED_HZ which you set is taken as config->speed.

1) What flash products are currently supported within WICED?


Cypress      : S25FL064L, S25FL128L, S25FL256L     

Macronix    : MX25L8006E, MX25L1606E, MX25L6433F, MX25L12835F, MX25L25635F, MX25U1635F, MX66U51235F

Micron        : N25Q512A, N25Q064A

Microchip   : SST25VF080B   

Winbond    : W25Q64FV



2) How does one enable a specific SFLASH within in WICED?


There are couple of MACRO defined to each of the above mentioned parts.







One need to enable this Macro as Global defines in .mk file of the platform folder. eg:




3) How to store your WLAN firmware into external SFLASH?


One need to add download_apps in the make target of the project. eg:

snip.scan-BCM943907AEVAL1F download_apps download run



4) Which app is going to manage writing to SFLASH?


sflash_write is the code responsible for writing into external flash. You can go to the following location to get access to the code


This app will get loaded into the MCU and will interact with sflash_write.tcl openOCD script to write the data into flash attached to the MCU.



5) How does one test whether sflash_write is working or not?


One can try to build the sflash_write app by itself with no-os or network stack dependency and then can look at the sflash driver to see where it is failing. eg:

waf.sflash_write-BCM943907AEVAL1F-NoNs-NoOS WIPE=1 download run



6) What if one wants to use some different SFLASH other than the verified SFLASH products mentioned above?



You need to create your know SFLASH functions in WICED as per your SFLASH. You can look into the following folder for more info:


As you can see the implementation for different SFLASH, you can take reference and do the changes as per your requirement.



We have also provided different MACRO in sflash_write.c file for testing connected sflash device. Please check the following test mode defines







As sflash_write.c will interact with sflash_write.tcl openOCD script, please verify flash commands described in sflash_write.c matches with commands described in sflash_write.tcl script.

Each Wi-Fi device must have a unique MAC address for communication through WiFi. WICED has different options to set the MAC address.


1) MAC address in OTP portion

Module Partners will program MAC address in the OTP memory of the WLAN chip. This will be unique and you can contact the module vendors for your know MAC address.


2) MAC address in DCT portion

DCT has memory for specifying MAC address. To direct WLAN chip to use MAC address from DCT, it is necessary to define global variable in the application makefile.

Add "GLOBAL_DEFINES+= MAC_ADDRESS_SET_BY_HOST" in .mk file in the project folder.


3) MAC address by User

If you don't want to use MAC address in OTP or DCT, you may redefine the WICED API function host_platform_get_mac_address() to provide your know MAC address when the WICED WiFi driver intializes the WLAN chip. You also need to set "GLOBAL_DEFINES+= MAC_ADDRESS_SET_BY_HOST" in .mk file.

You can locate host_platform_get_mac_address() under MCU folder, C:\..\..\..\WICED-Studio-5.0\43xxx_Wi-Fi\WICED\platform\MCU\BCM4390x\BCM4390x_platform.c

Upon Reset, the CPU will run ROM bootloader. Depending on the boot the following takes place

>> Upon Cold boot, ROM bootloader will run the second stage bootloader which will loads the WICED application into RAM and warm bootloader into Always-On RAM. Once the second stage boot is complete, the WICED application will takes over.

>> Upon warm boot, the ROM bootloader will jump into AON RAM and run from there. The warm bootloader will load WICED application to RAM.


The ROM booatloader expects that a valid image has been written to the SFLASH starting at address 0x14000000. If bootloader detects an invalid image, it will be halted with the CPU and waiting for an interrupt. The only way to recover, is to power it off and re-flash a valid image.

Different countries has different WiFi regulations and it is user responsibility to meet those, if operating in a particular country. Setting Country code parameter in WICED STUDIO will help us to meet those regulatory standards.

By default in WICED the country code is set to "WICED_COUNTRY_UNITED_STATES". Please refer to the following file in WICED

>> C:\..\..\..\WICED-Studio-5.0\43xxx_Wi-Fi\include\wiced_defaults.h


/*Country code */



If user want to change the country code as per his/her region change the above macro. Refer to the following file for getting different country code which are available in WICED STUDIO

>> C:\..\..\..\WICED-Studio-5.0\43xxx_Wi-Fi\WICED\WWD\include\wwd_constants.


If you have more questions or queries related to this contact us by the following link


Filter Blog

By date:
By tag: