Please note as of Wednesday, August 15th, 2018 this wiki has been set to read only. If you are a TI Employee and require Edit ability please contact x0211426 from the company directory.

CC3200 Sensor Profile Application

From Texas Instruments Wiki
Jump to: navigation, search
Cc31xx cc32xx return home.png
Cc32xx return sample apps.png

Overview

This application showcases the usage of lowest power mode(Hibernate) for CC3200. Exercising Hibernate can be quite rewarding in terms of power consumption. Especially, when the use case demands the device to be active for only fractional amount of time over long periods(like periodically sending some data over network every one hour). One can also calculate the hibernate current using this application.

Application details

Power Management Framework

CC3200 device have multiple power modes, which can be exercised by the user as per the requirement of their application. Power management framework makes it easier to specify the power policy for APPS MCU. All user has to configure is the lowest power mode the device should go into (Hibernate for this application). The framework tries to hide the intricacies of the underlying settings and helps the user to experience the low power mode capabilities of the device in a simple manner. If one wishes to have the custom settings for different power modes or use the framework for a different device, it can be accomplished with changing a couple of files. For more information regarding Power Management Framework, please refer to CC32xx Power Management Framework

Current Measurement

This application specify the Hibernate as the lowest power mode. When the device is in hibernate, the current values can be as low as in the order of microseconds. The procedure for measuring current can be found at CC3200 Low Power Modes Current Measurement page.

Program Flow

Most the parameters user will need to modify are specified as MACROs

  • SSID_NAME - Name of the Access Point used for this application.
  • GPIO_SRC_WKUP - Gpio number used as wake up source.
  • APP_UDP_PORT - Port number on which the device will send the udp packets.
  • HIB_DUR_SEC - Time (in seconds) after which the device will come out of Hibernate.
  • HIB_DUR_NSEC - Time (in addition to HIB_DUR_SEC) in nanoseconds after which the device will come out of Hibernate.
  • TRAFFIC_DUR_SEC - Time (in seconds) for which the device will send the udp packets.
  • TRAFFIC_DUR_NSEC - Time (in addition to TRAFFIC_DUR_SEC ) in nanoseconds for which the device will send the udp packets.
  • SERVER_IP_ADDRESS - Address of the udp server(other machine on same network) to receive udp packets sent by device.
#define SSID_NAME              "cc3200demo"
#define GPIO_13                 13
#define GPIO_17                 17
#define GPIO_SRC_WKUP		GPIO_13
#define APP_UDP_PORT            5001
#define HIB_DUR_SEC	        60
#define HIB_DUR_NSEC	        0
#define TRAFFIC_DUR_SEC         5
#define TRAFFIC_DUR_NSEC        0
#define SERVER_IP_ADDRESS       0xC0A80066

NoteNote: Security parameters for the AP can be configure inside WlanConnect function in "main.c".
NoteNote: Whatever Gpio is used as wake up source has to added in gpio_list array in "user_app_config.h" and pinmux for the same Gpio has to be added in "pinmux.c".

To start with, the board must be initialized and the power management framework have to be loaded.

    //
    // Board Initialisation
    //
    BoardInit();

    //
    // Configure the pinmux settings for the peripherals exercised
    //
    PinMuxConfig();

    //
    // Initialize the platform
    //
    platform_init();

    //
    // Configuring UART
    //
    g_tUartHndl = uart_open(PRCM_UARTA0);

Which will be followed by creation of task for setting timer and GPIO as wake source from Hibernate

    //
    // setting up timer and gpio as source for wake up from HIBERNATE
    //
    osi_TaskCreate(TimerGPIOTask,
                (const signed char *)"set wk_src for hibernate",
                OSI_STACK_SIZE, NULL, 1, NULL );

Task: TimerGPIOTask

  1. Starts simplelink, switch to station mode(if not already),set NWP power policy and connects to the AP.
  2. If the connection is unsuccessful, jump to 4th step.
  3. send UDP packets to Server address(specified as MACRO) for configurable duration(MACRO)
  4. Disconnects, stop simplelink, set timer and GPIO as wake sources from Hibernate.
  5. Set Power policy for the APPS MCU.
    //
    // starting the simplelink
    //
    iRetVal = sl_Start(NULL, NULL, NULL);
    ...
    //
    // Switch to STA mode if device is not in this mode
    //
    SwitchToStaMode(iRetVal);

    //
    // Set the power management policy of NWP
    //
    iRetVal = sl_WlanPolicySet(SL_POLICY_PM, SL_NORMAL_POLICY, NULL, 0);
    ...
    //
    // connecting to the Access Point
    //
    if(-1 == WlanConnect())
    {

        goto no_network_connection;
    }else{
    	UART_PRINT("Connected to AP\n\r");
    }
    ...
    while(g_ucTrafficEnable == 1)
    {
        //
        // sending message
        //
        iRetVal = sendto(iSockDesc, pcSendBuff,BUFF_SIZE, 0,
                        (struct sockaddr *)&sServerAddr,sizeof(sServerAddr));
        if(iRetVal < 0)
        {
            UART_PRINT("send error\n\r");
            while(FOREVER);
        }
        ManageDelay(128,BUFF_SIZE);
    }
    ...
    //
    // disconnect from the Access Point
    //
    WlanDisconnect();

    //
    // stop the simplelink with reqd. timeout value (30 ms)
    //
    sl_Stop(SL_STOP_TIMEOUT);

    //
    // setting Timer as one of the wakeup source
    //
    tTimerHndl = SetTimerAsWkUp();

    //
    // setting some GPIO as one of the wakeup source
    //
    tGPIOHndl = SetGPIOAsWkUp();
    .
    .
    //
    // Setting up HIBERNATE as the lowest power mode for the system.
    //
    lp3p0_setup_power_policy(POWER_POLICY_HIBERNATE);

Porting to TI-RTOS

For porting this application on TI-RTOS, please refer to Steps to build a new application on CC3200 with TI-RTOS: and Notes section on CC32xx_TI-RTOS page. cc_idle_task_pm() is the function needed to be hooked to the idle task.

Source Files briefly explained

  • main.c - The main file implementing the sensor profile.
  • lp3p0_board.c - Board specific initialization for Power Management framework .
  • lp3p0_plat_ops.c - Board specific APIs like IO parking and framework loading.

Supporting Files

  • pinmux.c - Generated by the PinMUX utility.

Common Files

  • startup_ccs.c - CCS related functions
  • startup_ewarm.c - IAR related functions
  • wdt_if.c - Interface file for Watchdog Timer

Prerequisites

This application facilitates the user to get the current numbers for Hibernate mode. The prerequisites for running this application are the following:

  • Ensure that the device is in Station mode
  • Delete all previously stored AP profiles.

NoteNote: One can simply run UDP Socket application before executing this application, that will take care of the above mentioned points.

Usage

  • Modify MACROs according to the requirement and recompile.
  • Setup a serial communication application (HyperTerminal/TeraTerm). For detail info visit Terminal setup

    On the host PC. The settings are:
    - Port: Enumerated COM port
    - Baud rate: 115200
    - Data: 8 bit
    - Parity: None
    - Stop: 1 bit
    - Flow control: None

  • Run the application preferably from FLASH rather than from the debugger as debugger would disconnect in Hibernate.
  • See the print on the serial communication program to understand the flow.
Teraterm Snapshot

Limitations/Known Issues

Refer to CC32xx_Power_Management_Framework for limitations and known issues.

Links