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

Disclaimer: The attached demo code is developed to provide a reference to the customer, it has not been extensively tested. Also, it does not perform all the functionalities included in hello_client app available for Bluetooth devices in WICED SDK.

 

Introduction:

The Hello client demo app available for CYW20706, CYW20719 and CYW20735 in WICED SDK, is designed to connect and access services of the Hello sensor device. This post discusses about an example, which allows WiFi-BT Combo devices to act as a central device (client).

 

Procedure:

Extract the project in the attached zip file ble_hello_client.zip in /43xxx_Wi-Fi/apps/snip/snip/Bluetooth/ directory. Program the device using the ble_hello_client project. After programming, WICED device scans for the available Bluetooth devices. UUID and device name of the ble_hello_sensor project is already defined in application (ble_hello_client.c). WICED device recognizes the desired device and tries to connect to it, invoking the connection up callback.

 

Note that ble_hello_sensor should be running and advertising to test the client functionality. Both Combo and Bluetooth chips can be used for Hello sensor app. Be ensured that the UUID and device name of the Hello sensor device is correctly mentioned in Hello client app.

Attached to this post are three examples that are specific for CYW954907AEVAL1F EVK.

These examples are briefed in the CYW954907AEVAL1F EVK User Guide.

 

Please refer to "2.2 Install Software" section of the same User Guide on how to add them.

 

Chapter "5. Code Examples" briefs about these examples in the User Guide.

SheetalJ_96

Clock and PMU in CYW43907

Posted by SheetalJ_96 Moderator Dec 11, 2017

This blog post provides overview of Clock, PMU and Oscillators/crystals in CYW43907.

 

Clock

The CPU clock frequencies for APPS core can be configured to one of five options: 60MHz, 80MHz, 120MHz, 160MHz, 320MHz.

PLATFORM_CPU_CLOCK_FREQUENCY parameter must be set to required frequency in file platform_config_bsp_default.h.

For example, to set APPS CPU Frequency to 320MHz , define should be the following

 

     #define     PLATFORM_CPU_CLOCK_FREQUENCY     PLATFORM_CPU_CLOCK_FREQUENCY_320_MHz

 

Power Management Unit (PMU)

The Power Management Unit (PMU) core manages power and clock resources for the entire chip, including Clock/reset management and power management.The CYW43907 has an advanced PMU sequencer, which automatically controls the power switches of all resources.

 

Oscillators/Crystals

CYW43907 uses an external crystal of 37.4 MHz to provide a frequency reference. It is used for generating all radio frequencies and normal operation clocking.

As an alternative to a crystal, an external precision frequency reference can be used, provided that it meets the phase noise requirements. Please refer to the CYW43907 Datasheet for exact requirements.

Along with external crystal, CYW43907 uses a secondary low power oscillator (LPO) for low power mode timing. The internal LPO frequency range is approximately 33 kHz ± 30%, 32.768 kHz to be exact.

This post discusses about how to configure CYW943907AEVAL1F board as USB device and PC/laptop as USB host. After programming the device, CYW943907AEVAL1F acts as HID keyboard. It prints alphabets ‘a’ to ‘z’ after pressing USER_1 and prints digits ‘1’ to ‘0’ after pressing USER_2 on any text editor on PC/laptop.

 

To evaluate USB operation on CYW943907AEVAL1F board, some hardware modifications are needed. Refer to blog post Hardware connections for USB evaluation on CYW943907AEVAL1F for the required changes.

 

Make the hardware connections to connect Olimex ARM-USB-TINY-H debugger with CYW943907AEVAL1F board as discussed in post OpenOCD -WICED.

 

For initializing device as HID keyboard, wiced_usb_device_hid_keyboard_init() function is called. There are different APIs and functions used within this function to initialize the USB device stack, USB DCI (Device Controller Interface) resources and USBX device controller. hid_keyboard_callback() is the function used to define HID class parameters for keyboard. In function wiced_usb_device_usbx_evt_callback(), different callback events are defined based on the state of the USB device like reset, attached, configured, etc.

 

The APIs available to configure CYW43907 as USB device are as follows:

1. ux_system_initialize (VOID *non_cached_memory_pool_start, ULONG non_cached_memory_size, VOID *cached_memory_pool_start, ULONG cached_memory_size)

          USBX has its own memory manager. The memory needs to be allocated to USBX before the host or device side of USBX is initialized. USBX memory manager can accommodate systems where memory can be cached. This API initializes USBX memory resources with non-cached and cached memory pool.

     a. non_cached_memory pool start - Beginning of non-cached memory

     b. non_cached_memory_size - size of memory needed

     c. cached_memory_pool_start - Beginning of cached memory

     d. cached_memory_size - size of memory needed

 

2. ux_device_stack_initialize (UCHAR * device_framework_high_speed, ULONG device_framework_length_high_speed, UCHAR * device_framework_full_speed, ULONG device_framework_length_full_speed, UCHAR * string_framework, ULONG string_framework_length, UCHAR * language_id_framework, ULONG language_id_framework_length, UINT (*ux_system_slave_change_function)(ULONG), UX_USER_CONFIG_DEVICE *user_config_device)

          This API is used to initialize the USB device stack. It mainly provides the stack with the device framework for the USB function

     a. device_framework_high_speed - pointer to high speed framework

     b. device_framework_length_high_speed - Length of the high speed framework

     c. device_framework_full_speed - pointer to full speed framework

     d. device_framework_length_full_speed - Length of the full speed framework

     e. string_framework - pointer to string framework

     f. string_framework_length - Length of the string framework

     g. language_id_framework - pointer to string language framework

     h. language_id_framework_length - Length of the string language framework

     i. ux_system_slave_change_function - function to be called when the device state changes

     j. user_config_device - user configured device data

 

3. ux_dcd_bcm4390x_initialize (ULONG dcd_io, ULONG parameter)

         This API is used to define USB Device Controller Interface (DCI) resource.

     a. dcd_io - DCI resource address

     b. parameter - information about DCI resource

 

Download the usb_device application attached with this blog post. Extract and add the downloaded folder in apps folder of WICED Studio 6.0 or later.

To program your device using JTAG, install the drivers using zadig. Connect Olimex debugger and CYW943907AEVAL1F board to your PC/laptop. You can see JTAG device detected in Device Manager as follows.

Create the make target as follows:

          usb_device-CYW943907AEVAL1F JTAG=Olimex_ARM-USB-TINY-H download run

 

Download the program to CYW43907 by double clicking on above make target. After you download the program, you will see WICED device acting as HID keyboard in Device Manager.

Open any text editor in your PC/laptop. You should see alphabets or digits getting printed after pressing USER_1 or USER_2.

 

Note: The USB Device functionality does not work for device classes (For instance, mass storage class) that use a transfer data length which is a multiple of the maximum packet size. Currently there is no workaround for this issue. The issue is being investigated and will be updated once there is a solution or workaround identified.

This Help article discusses how to effectively execute multiple applications on the CYW943907AEVAL1F evaluation platform. To achieve switching between applications, you put device into deep sleep when current application is running and load another application when device resumes. WICED Application Framework (WAF) supports loading and storing of multiple application binaries in the external sflash. You can set the platform to execute any of the stored binaries.

 

There are three binaries APP0, APP1 and APP2 where you can store three different applications. By default APP0 application executes whenever we download the program.

There are two requirements for the application to perform switching:

  • All applications must use the same Application DCT.
  • All applications must use the same AON (Always ON) RAM defines.

 

In WICED SDK 5.0 and above, apps\snip contains two applications satisfying above requirements: multi_image_0 and multi_image_1.

multi_image_0 application prints text on console showing that application 0 has started and multi_image_1 application prints text showing that application 1 has started.

To set the APP0 to point to second application, check for following lines in the make file multi_image_0.mk:

          APP1_FILE = snip.multi_image_1-$(PLATFORM)  

          APP1 = build/$(APP1_FILE)/binary/$(APP1_FILE).stripped.elf

 

To test the application, make following targets and build in the given order:

          snip.multi_image_1-CYW943907AEVAL1F

          snip.multi_image_0-CYW943907AEVAL1F download download_apps run

 

When downloading to the device, the sflash_write application sets the device in an "always on" state. In this state, the device will not go into deep sleep. In order to use this feature you must power cycle the device before you can test. For more details, go through README.txt in multi_image_0 folder.

 

After downloading the program, you will see following text on UART terminal.

Now power cycle the device.

To see the information about AON RAM variables, use command info.

To switch the application, use command switch.

After putting these commands, you will see second application loaded as follows.

This post discusses how to connect CYW943907AEVAL1F EVK with the 128*64 SSD 1306 OLED Display module. Corresponding projects for the same are already there in snip folder of WICED Studio 5.2 and above.

 

1. Hello World Application

Connect the SSD 1306 display to J12 and J9 headers of CYW943907AEVAL1F as shown in figure.

 

Sr. No.

Display pinCYW943907 pin

CYW943907 pin name/

kit signal name

1GNDJ9.6 or J9.7GND
2VCCJ9.43.3V
3SDAJ12.9I2C_1_SDA
4SCLJ12.10I2C_1_SCL

Open the 43xx_Wi-Fi\apps\snip\graphics\hello\hello.mk file in WICED Studio. Add device CYW943907AEVAL1F in the VALID_PLATFORMS list.

Create make target, run & download program to device CYW943907AEVAL1F.

You should see "Hello World!" displayed on the SSD 1306 Display.

 

2. Graphics Test application

Connect the SSD 1306 Display to J12 and J9 headers of CYW943907AEVAL1F as shown in Hello World application.

Open the 43xx_Wi-Fi\apps\snip\graphics\graphicstest\graphicstest.mk file in WICED Studio 5.2. Add device CYW943907AEVAL1F in the VALID_PLATFORMS list.

In graphicstest.c file, different functions are defined to form various shapes on the display.

Create make target, run & download program to device CYW943907AEVAL1F.

You should see the visual sequences on display. Following figure shows one of the sequence.

SheetalJ_96

MQTT with IBM Bluemix

Posted by SheetalJ_96 Moderator Sep 27, 2017

IBM Watson IoT Platform provides powerful application access to IoT devices and data to help you rapidly compose analytics applications, visualization dashboards and mobile IoT apps. It is a service that is available in IBM Bluemix. Watson IoT Platform allows you to perform powerful device management operations, and store and access device data, connect a wide variety of devices and gateway devices. It provides secure communication to and from your devices by using MQTT and TLS. Instances of the Watson IoT Platform can be created in the Bluemix dashboard. The Watson IoT Platform can be integrated with other Bluemix services and accessed by using the Bluemix dashboard. MQTT.fx tool is used to monitor the messages exchanged between cloud and device.

 

This Help Article discusses how to use CYW943907AEVAL1F EVK for connecting to IBM Bluemix.

 

Create a Bluemix account in console.bluemix.net. In Bluemix Console, register a device and device type. Note down the Token number you get while registering the device.

  1. Open the pub_sub_bluemix.zip file provided along with this post in WICED Studio 5.1 or above.
  2. Open the file wifi_config_dct.h to configure the Device Configuration Table (DCT). Modify the values of the macros CLIENT_AP_SSID and CLIENT_AP_PASSPHRASE to match your Wi-Fi access point SSID and password respectively. Ensure that the AP is connected to the internet.
  3. In pub_sub_bluemix.c file, following macros have to be set with proper values to connect to the IBM Bluemix.

                #define   ORG_ID                                                             " "

                #define   DEVICE_TYPE                                                  " "

                #define   DEVICE_NAME                                                 " "

                #define   TOKEN                                                               " "

ORG_ID is unique organization ID you get after creating account. Click on the upper right corner of Bluemix console. Red box shows the organization ID. Type the device type, device name and authorization token you get while registering the device.

As we are making the unsecured connection, change the Security settings in Bluemix console. Go to Security Section. Click on the edit tab.

Select 'TLS Optional' option from the list.

After updating the above information, create make target, run & download program to device CYW943907AEVAL1F.

 

To verify the output, open the MQTT.fx tool. On the main window, click on the setting tab.

    

In the pop-up window, set the broker address in the following format:

                         "{ORG_ID}.messaging.internetofthings.ibmcloud.com"

To generate Client ID and password, open the Bluemix Console. Select APPS section from the Bluemix console window and click on Generate API key.

In the pop-up window, you will see the API key and Authentication token generated as below. Copy the credentials and click on Generate.

Now paste these credentials as User Name and Password in User Credentials tab.

  • The MQTT client ID is in the following format: a:org_Id:appId
  • The MQTT user name is the API key, for example, a-org_Id-a84ps90Ajs
  • The MQTT password is the authentication token, for example, MP$08VKz!8rXwnR-Q

For more information, you can browse the link: MQTT connectivity for applications

Click on OK.

Click on Connect to connect to the IBM Bluemix. You should see a green circle after connection.

Devices can subscribe to commands which have following format:

               iot-2/cmd/command_id/fmt/format_string

command_id is the ID of the command, for example, update. It can be any string permitted by MQTT.

format_string is the format of the event payload, for example, json, text, bin.

Type Subscribe topic and click on Subscribe as shown in below figure.

Similarly devices publish the events which have the following format:

               iot-2/type/device_type/id/device_name/cmd/command_id/fmt/format_string

device_type and device_name are the type and name of the device you have registered.

For more information, you can browse the given link.

Type some message in the box below and click on Publish. You will see that message on UART terminal.

Filter Blog

By date:
By tag: