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

Introduction

 

This blog discusses about network interface through Ethernet with CYW943907AEVAL1F.

The CYW43907 integrates a high performance Ethernet MAC controller. The controller interfaces to an external PHY either over a

Media Independent Interface (MII) or a Reduced Media Independent Interface (RMII). The controller can transmit and receive data at

10 Mbps and 100 Mbps. Below table shows the signal descriptions for CYW43907 Ethernet MAC.

 

Signal Name
Type
Description
RMII_G_RXCIMII receive clock
RMII_G_COLIMII collision detection
RMII_G_CRSIMII carrier sense
RMII_G_TXCIMII/RMII transmit clock
RMII_G_TXD0OMII/RMII transmit signal
RMII_G_TXD1OMII/RMII transmit signal
RMII_G_TXD2OMII transmit signal
RMII_G_TXD3OMII transmit signal
RMII_G_RXD0IMII/RMII receive signal
RMII_G_RXD1IMII/RMII receive signal
RMII_G_RXD2IMII receive signal
RMII_G_RXD3IMII receive signal
RMII_MDIOI/OMII/RMII management data
RMII_MDCOMII/RMII management clock
RMII_G_TXENOMII/RMII transmit enable
RMII_G_RXDVIMII/RMII receive data valid

 

 

 

Application

 

Download the attached zip file, extract to folder tcp_client_ethernet and add the folder to <WICED SDK>/43xxx_Wi-Fi/apps/snip.

tcp_client_ethernet.JPG

 

Open tcp_client_ethernet.c and follow application instructions mentioned in the source code.

Appl Instructions.JPG

 

Once the program is successfully compiled and downloaded. Observe the serial terminal for message logs.

serial terminal.JPG

 

At the same time observe the message logs of TCP echo server which looks as below,

tcp_server.JPG

 

 

Application Details

 

I. The macro TCP_SERVER_IP_ADDRESS in #define TCP_SERVER_IP_ADDRESS MAKE_IPV4_ADDRESS(192,168,1,2) definition contains the IP address of TCP echo server.

II. The device_init_ip_settings in the following declaration sets the provided IPv4 address to CYW943907AEVAL1F. Assign ip_address, netmask and gateway to device_init_ip_settings depending the on the gateway and netmask values of your AP/router.

      device_init_ip_settings.JPG

The netmask and gateway values can be found by using the command ipconfig  in the command window of PC (TCP Server) connected to the same AP as CYW943907AEVAl1F.

ipconfig_edited.jpg

 

III. wiced_core_init( ) initializes platform related APIs, RTOS functions and the device configuration table.

IV. wiced_network_init( ) initializes the network interface and creates packet pools for transmission and reception.

V. The API wiced_network_up( WICED_ETHERNET_INTERFACE, WICED_USE_STATIC_IP, &device_init_ip_settings ) brings up the network as WICED_ETHERNET_INTERFACE with the IP configuration as WICED_USE_STATIC_IP and initializes IP settings to device_init_ip_settings. IP configurations can be changed to WICED_USE_EXTERNAL_DHCP_SERVER_RESTORE or WICED_USE_EXTERNAL_DHCP_SERVER and NULL can be passed to wiced_network_up() instead of &device_init_ip_settings.

Note: The network IP configuration can be changed to WICED_USE_EXTERNAL_DHCP_SERVER_RESTORE or WICED_USE_EXTERNAL_DHCP_SERVER as below.

  1. wiced_network_up( WICED_ETHERNET_INTERFACE, WICED_USE_EXTERNAL_DHCP_SERVER_RESTORE , NULL ), or
  2. wiced_network_up( WICED_ETHERNET_INTERFACE, WICED_USE_EXTERNAL_DHCP_SERVER , NULL )

WICED_USE_EXTERNAL_DHCP_SERVER_RESTORE uses an external DHCP server and restores the last saved DHCP state. Since IP configuration is set to external DHCP server, NULL is passed instead of device_init_ip_settings in wiced_network_up () and device_init_ip_settings definition has to commented.

 

VI. The API wiced_tcp_create_socket( &tcp_client_socket, WICED_ETHERNET_INTERFACE ) creates a TCP socket over the network Ethernet interface.

VII. The API wiced_tcp_bind( &tcp_client_socket, TCP_SERVER_PORT ) binds tcp_client_socket to the local port TCP_SERVER_PORT (50007).

VIII. The API wiced_rtos_register_timed_event() registers a function that will be called at a regular interval.

IX. The API wiced_tcp_connect( &tcp_client_socket, &server_ip_address, TCP_SERVER_PORT, TCP_CLIENT_CONNECT_TIMEOUT ) establishes connection between client and server over predefined over defined ports.

X. The API wiced_packet_create_tcp(&tcp_client_socket, TCP_PACKET_MAX_DATA_LENGTH, &packet, (uint8_t**)&tx_data, &available_data_length) creates a TCP packet by automatically allocating memory for the tx_data.

XI. wiced_packet_set_data_end(packet, (uint8_t*)tx_data + strlen(tx_data)) sets the end of the data portion.

XII. The API wiced_tcp_send_packet(&tcp_client_socket, packet) sends the TCP data , if the data transmission fails the packet will be deleted by wiced_packet_delete(packet) and connection will be closed by wiced_tcp_disconnect(&tcp_client_socket).

XIII. The contents of the received packet will be retrieved by the API wiced_packet_get_data(). After retrieving the contents in rx_data[ ], packet will be deleted and connection will be disconnected.

XIV. AP and Ethernet could be brought up together by following the steps below.

     1. Define a variable for access point IP settings as below,

          ap_ip_settings.JPG

     2. Bring up network with interface as WICED_AP_INTERFACE, IP configuration as WICED_USE_INTERNAL_DHCP_SERVER and static IP interface as ap_ip_settings.

          ap network up.JPG

Introduction

 

This blog discusses about the usage of PWM module of CYW943907AEVAL1F in WICED SDK 6.0. The CYW43907 provides up to six independent PWM channels. The PWM pins for CYW943907AEVAL1F EVK are as shown in the table below.

 

Enum ID

Header

Conn

Function

WICED Peripheral

Alias

WICED_GPIO_6J12:4PWM, GPIOWICED_PWM_1
WICED_GPIO_7J12:3PWM, GPIOWICED_PWM_2
WICED_GPIO_12J10:6PWM, GPIOWICED_PWM_3
WICED_GPIO_11J10:7PWM, GPIOWICED_PWM_4
WICED_GPIO_17J6:1PWM, GPIOWICED_PWM_5
WICED_GPIO_3J10:4PWM, GPIOWICED_PWM_6

 

The PWM pins can be re-assigned to different I/Os using the pin mux functionality in "platform_pwm_peripherals" at

<WICED SDK>/43xxx_Wi-Fi/platforms/CYW943907AEVAL1F/platform.c.

 

In order to re-assign a PWM, just change the first argument in the entry for that row to the desired pin name. For example, to re-assign WICED_PWM_1 to PIN_GPIO_0, just change PIN_GPIO_10 to PIN_GPIO_0.

 

const platform_pwm_t platform_pwm_peripherals[] =

{

   [WICED_PWM_1]  = {PIN_GPIO_10,  PIN_FUNCTION_PWM0, },   /* or PIN_GPIO_0, PIN_GPIO_8,  PIN_GPIO_12, PIN_GPIO_14, PIN_GPIO_16, PIN_PWM_0   */

...

};

 

PWM Features

 

The following features apply to the PWM channels:

  • Each channel is a square wave generator with a programmable duty cycle.
  • Each channel generates its duty cycle by dividing down the input clock.
  • Both the high and low duration of the duty cycle can be divided down independently by a 16-bit divider register.
  • Each channel can work independently or update simultaneously.
  • Pairs of PWM outputs can be inverted for devices that need a differential output.
  • Continuous or single pulses can be generated.
  • The input clock can either be a high-speed clock from a PLL channel or a lower speed clock at the crystal frequency.

 

Different APIs in WICED for PWM

 

PWM APIs used in WICED are given below.

 

wiced_result_t wiced_pwm_init ( wiced_pwm_t pwm, uint32_t frequency, float duty_cycle )

 

This API initializes a PWM pin. Prepares a Pulse-Width Modulation pin for use. Does not start the PWM output.

 

     Parameters
[in]pwm: The PWM interface which should be initialized
[in]frequency: Output signal frequency in Hertz
[in]duty_cycle: Duty cycle of signal as a floating-point percentage (0.0 to 100.0)

 

     Returns
     WICED_SUCCESS : on success.
     WICED_ERROR : if an error occurred with any step

 

wiced_result_t wiced_pwm_start ( wiced_pwm_t pwm )

 

This API starts Pulse-Width Modulation signal output on a PWM pin

 

     Parameters
[in]pwm: The PWM interface which should be started

 

     Returns
     WICED_SUCCESS : on success.
     WICED_ERROR : if an error occurred with any step

 

wiced_result_t wiced_pwm_stop ( wiced_pwm_t pwm )

 

This API stops output on a PWM pin.

 

     Parameters
[in]pwm: The PWM interface which should be stopped

 

     Returns
     WICED_SUCCESS : on success.
     WICED_ERROR : if an error occurred with any step

APIs are explained in <WICED SDK>/43xxx_Wi-Fi/doc/API.html at Components > Platform functions > PWM and also at <WICED SDK>/43xxx_Wi-Fi/include/wiced_platform.h in WICED SDK6.0.

 

Testing the Application

 

  1. Download the PWM application attached with this blog post extract and add the downloaded folder "pwm" to "snip" folder in <WICED SDK>/43xxx_Wi-Fi/apps/.
  2. Create a make target for the application. Example: snip.pwm-CYW943907AEVAL1F download run.
  3. Connect CYW943907AEVAL1F EVK to PC and run the make target by double clicking on it.
  4. After the application is compiled and downloaded, it will start running. You can see the messages in serial terminal like "putty" or "Tera Term".

output.JPG

 

You can change the frequency of PWM by using the API wiced_pwm_init ( wiced_pwm_t pwm, uint32_t frequency, float duty_cycle ). The figure below shows the screen capture of PWM with 1MHz frequency.

T0001.BMP

 

Once the application starts running, whenever the button USER_1 is pressed, interrupt service routine (button1_isr()) is called. Application is written in such a way that the duty cycle get reduced by 5% every time USER_1 button is pressed hence the brightness of LED_1 reduces.

This Help Article explains the low power measurement using applications available in WICED Studio 6.0 for CYW943907AEVAL1F evaluation kit.

 

A low power app note is available in WICED 6.0  at 43xxx_Wi-Fi/doc/WICED-Powersave-App-Note.pdf for CYW94390x, STM32 and AT91SAM4S.

 

1. Board Rework: Following modification has to be made in CYW943907AEVAL1F to measure power consumption.

    1. Remove R41.
    2. Remove R55.
    3. Short respective terminals of R41 and R55 as shown in the Figure 2.b and jump wires for ammeter connection.

     Note: Short wires at R41 & R55 terminals to a common ammeter terminal to measure IVBAT+IVDDIO as shown in Figure 1 below.

 

Board Modifications.png

Figure 1. Board Modification

 

IMG_20171123_111604 edited.jpg

Figure 2.a. CYW943907AEVAL1F Before Rework

 

IMG_20171123_152938 edited2.jpg

Figure 2.b. CYW943907AEVAL1F After Rework

 

2. Testing

 

     i. Make the connections as shown in the figures 3.a and 3.b.

IMG_20171123_153043 edited.jpg

Figure 3.a. CYW943907AEVAL1F Bottom.

 

IMG_20171123_153515 edited.jpg

Figure 3.b. CYW943907AEVAL1F Top.

 

     ii. Create make target, download and run applications mentioned in section 3 below .

 

 

3. Example Power Save Applications for CYW943907AEVAL1F:

             

     i. Application Sleep (Deep Sleep)- 43xxx_Wi-Fi/apps/test/apps_sleep

 

In this example, the application:

        • Periodically goes to Deep Sleep in a co-operative way.
        • Wakes up through timer.
        • Saves variables in Always On RAM (AONRAM) and verifies them after warm boot.
        • Registers event handlers for entering and leaving Deep Sleep. Does not load firmware to WLAN side.

apps_sleep 1.png

Figure 4. apps_sleep.c- Power Consumption on CYW943907AEVAL1F board ~360uA in Deep Sleep (at Marker 2)

 

     ii. Ping Deep Sleep (Deep Sleep + Networking)- 43xxx_Wi-Fi>/apps/snip/ping_deepsleep

 

In this example, the application:

        • Connects to Access Point (AP) and pings AP periodically.
        • Periodically goes into Deep Sleep in a Co-operative way.
          • Checks for networking to be idle.
          • Suspends networking stack.
        • Resumes networking after coming out of Warm boot.

 

ping_deepsleep 0.png

Figure 5. Ping Deep Sleep- Average power consumption ~1.45mA (between markers 1 and 2)

 

     iii. Ping Power Save- 43xxx_Wi-Fi/apps/snip/ping_powersave/ping_powersave.c

 

In the ping_powersave demo:

 

        • The system connects to AP and periodically pings the AP.
        • In between pings, the system suspends network timers and enters low-power mode (Sleep) for WIFI_SLEEP_TIME( by default 1 second - defined in ping_powersave.c) seconds.
        • The system resumes network timers when coming out of sleep.

 

ping_powersave 0.png

Figure 6. Ping Power Save- Average current consumption ~61.15mA (between markers 1 and 2)

 

 

    iv. Powersave (Deep Sleep + Sleep Use Cases)- 43xxx_Wi-Fi/apps/test/powersave/powersave.c

 

        • Console-based application
        • Commands can be
          • Entered using UART console
          • Statically compiled
        • Following features are supported

 

Change POWERSAVE_STANDALONE_TEST_DEEPSLEEP_NO_ASSOC to 1 and keep all other tests 0 in powersave.c as shown below,

#define POWERSAVE_STANDALONE_TEST_DEEPSLEEP_NO_ASSOC              1

NO_ASSOC deep sleep 0.png

Figure 7. Power Save- Average current consumption ~1.14mA (between markers 1 and 2)

 

Change POWERSAVE_STANDALONE_TEST_DEEPSLEEP_ASSOC to 1 and keep all other tests 0 in powersave.c as shown below,

#define POWERSAVE_STANDALONE_TEST_DEEPSLEEP_ASSOC                 1

ASSOC 0.png

Figure 8. Power Save- Average current consumption ~1.54mA (between markers 1 and 2)

 

Change POWERSAVE_STANDALONE_TEST_WAIT_FOR_WLAN to 1 and keep all other tests 0 in powersave.c as shown below,

#define POWERSAVE_STANDALONE_TEST_WAIT_FOR_WLAN                   1

POWERSAVE_STANDALONE_TEST_WAIT_FOR_WLAN 0.png

Figure 9. Power Save- Average current consumption ~40.43mA (between markers 1 and 2)

 

Change POWERSAVE_STANDALONE_TEST_ACTIVE_WAIT_FOR_WLAN to 1 and keep all other tests 0 in powersave.c as shown below,

#define POWERSAVE_STANDALONE_TEST_ACTIVE_WAIT_FOR_WLAN            1

POWERSAVE_STANDALONE_TEST_ACTIVE_WAIT_FOR_WLAN 0.png

Figure 10. Power Save- Average current consumption ~11.90mA (between markers 1 and 2)

 

Change POWERSAVE_STANDALONE_TEST_LOW_POWER_NETWORKING to 1 and keep all other tests 0 in powersave.c as shown below,

#define POWERSAVE_STANDALONE_TEST_LOW_POWER_NETWORKING            1

POWERSAVE_STANDALONE_TEST_LOW_POWER_NETWORKING 0.png

Figure 11. Power Save- Average current consumption ~111mA (between markers 1 and 2)

 

Change POWERSAVE_STANDALONE_TEST_WAKEUP_FROM_DEEP_SLEEP_PROFILE to 1 and keep all other tests 0 in powersave.c as shown below,

#define POWERSAVE_STANDALONE_TEST_WAKEUP_FROM_DEEP_SLEEP_PROFILE  1

POWERSAVE_STANDALONE_TEST_WAKEUP_FROM_DEEP_SLEEP_PROFILE 0.png

Figure 12. Power Save- Average current consumption ~901uA (between markers 1 and 2)

The sd_filesystem application demonstrates few operations on directories and files (Ex: create, delete, read, write, open, close, copy etc) in micro SD card formatted as FAT32.

 

Testing

 

1. Connect your micro SD card to your PC/Laptop and create a folder in it by the name “src” and add some files or folders (Which will be copied or mirrored in target directory “tgt” by the application).

2. Insert micro SD card in the provided SD card slot of CYW943907AEVAL1F and connect the board to PC USB port.

sd_card_slot.png

3. Open the project sd_filesystem located at 43xxx_Wi-Fi/apps/snip/sd_filesystem in WICED_SDK 5.1. The source code sd_filesystem.c is found in the project along with related makefile sd_filesystem.mk.

4. Add platform support for CYW943907AEVAL1F in makefile sd_filesystem.mk at the line VALID_PLATFORMS as below (only in WICED_SDK 5.1),

mk.PNG

5. Create a target as below to download and run the application on the board CYW943907AEVAL1F.

 

6. Double click on the target to compile and download it into CYW943907AEVAL1F.

7. Open any serial port reader tool (Ex: Tera Term, Putty) and start capturing WICED Serial Port Data and wait for Build to complete.

8. Once compile, download and run is complete, then messages will be printed in serial terminal as shown below.

9. If CYW943907AEVAL1F resets during copying files or mirroring nested directories it indicates application stack overflow . Then decrease PATH_BUFFER_SIZE to 256 (Which is 2048 as shown in diagram below) and FILE_BUFFER_SIZE (which is 65536 as shown in diagram below) in sd_filesystem.c

If the reset occurs even after the above mentioned changes then increase APPLICATION_STACK_SIZE to 6k (which is 1024*256 as shown in figure below) in sd_filesystem.mk.

Filter Blog

By date:
By tag: