Difference between revisions of "MCU/WISE-1520 SDK"
Erick.huang (talk | contribs) m (ADD ADC example - HW descrition.) |
|||
(3 intermediate revisions by one other user not shown) | |||
Line 837: | Line 837: | ||
=== ADC Example === | === ADC Example === | ||
− | ==== | + | ==== HW description ==== |
+ | |||
+ | The WISE-1520 has two ADC (analog to digital converter) channels, ADC0 and ADC4. The ADC0 is at M2.COM pin50 and WISE-DB1500 CN3.pin7. | ||
+ | |||
+ | The ADC4 is at M2.COM pin59 and WISE-DB1500 CN3.pin15. | ||
+ | <p style="text-align: center;">[[File:ED1500.png|RTENOTITLE]]</p> | ||
+ | |||
+ | ==== FW implement ==== | ||
+ | |||
+ | Add below code in wise_1520_main.c or download [[Media:Wise1520_demo_main.zip|wise1520_demo_main.zip]] and unzip. | ||
+ | |||
+ | Step 1: add header file | ||
+ | |||
+ | //Common interface file in CC3200 SDK | ||
+ | |||
+ | #include "common.h" | ||
+ | |||
+ | #include "gpio_if.h" | ||
+ | |||
+ | #include "adc.h" | ||
+ | |||
+ | <span style="background-color:#AFEEEE;">#include "adc.h" // add header file.</span> | ||
+ | |||
+ | Step 2: add function declare | ||
+ | |||
+ | //******************************************************************* | ||
+ | |||
+ | // Local functions prototypes | ||
+ | |||
+ | //******************************************************************* | ||
+ | |||
+ | … | ||
+ | |||
+ | <span style="background-color:#AFEEEE;">static float ADC_ReadDatByChannel(uint32_t Channel);</span> | ||
+ | |||
+ | … | ||
+ | |||
+ | <span style="background-color:#AFEEEE;">define NO_OF_SAMPLES 128 // define sample times</span> | ||
+ | |||
+ | Step 3: add code in caller | ||
+ | |||
+ | void ConnectionTask(void* pTaskParams){ | ||
+ | |||
+ | … | ||
+ | |||
+ | … | ||
+ | |||
+ | <span style="background-color:#AFEEEE;">float fADC0_v;</span> | ||
+ | |||
+ | <span style="background-color:#AFEEEE;">float fADC4_v;</span> | ||
+ | |||
+ | … | ||
+ | |||
+ | <span style="background-color:#AFEEEE;">fADC0_v=ADC_ReadDatByChannel(0);</span> | ||
+ | |||
+ | <span style="background-color:#AFEEEE;">UART_PRINT("[ADC0]: %f \n\r", fADC0_v);</span> | ||
+ | |||
+ | <span style="background-color:#AFEEEE;">fADC4_v=ADC_ReadDatByChannel(4);</span> | ||
+ | |||
+ | <span style="background-color:#AFEEEE;">UART_PRINT("[ADC4]: %f \n\r", fADC4_v);</span> | ||
+ | |||
+ | <span style="background-color:#AFEEEE;">}</span> | ||
+ | |||
+ | Step 4: function implement | ||
+ | |||
+ | <span style="background-color:#AFEEEE;">float ADC_ReadDatByChannel(uint32_t Channel){</span> | ||
+ | |||
+ | <span style="background-color:#AFEEEE;">uint32_t uiChannel;</span> | ||
+ | |||
+ | <span style="background-color:#AFEEEE;">uint32_t uiIndex=0;</span> | ||
+ | |||
+ | <span style="background-color:#AFEEEE;">uint32_t ulSample;</span> | ||
+ | |||
+ | <span style="background-color:#AFEEEE;">float fSample = 0.0;</span> | ||
+ | |||
+ | | ||
+ | |||
+ | <span style="background-color:#AFEEEE;">switch(Channel)</span> | ||
+ | |||
+ | <span style="background-color:#AFEEEE;">{</span> | ||
+ | |||
+ | <span style="background-color:#AFEEEE;">case 0:</span> | ||
+ | |||
+ | <span style="background-color:#AFEEEE;">uiChannel = ADC_CH_3;</span> | ||
+ | |||
+ | <span style="background-color:#AFEEEE;">MAP_PinTypeADC(PIN_60, PIN_MODE_255);</span> | ||
+ | |||
+ | <span style="background-color:#AFEEEE;">break;</span> | ||
+ | |||
+ | <span style="background-color:#AFEEEE;">case 4:</span> | ||
+ | |||
+ | <span style="background-color:#AFEEEE;">uiChannel = ADC_CH_1;</span> | ||
+ | |||
+ | <span style="background-color:#AFEEEE;">MAP_PinTypeADC(PIN_58, PIN_MODE_255);</span> | ||
+ | |||
+ | <span style="background-color:#AFEEEE;">break;</span> | ||
+ | |||
+ | <span style="background-color:#AFEEEE;">default:</span> | ||
+ | |||
+ | <span style="background-color:#AFEEEE;">return -1.0;</span> | ||
+ | |||
+ | <span style="background-color:#AFEEEE;">}</span> | ||
+ | |||
+ | <span style="background-color:#AFEEEE;">MAP_ADCTimerConfig(ADC_BASE,2^17);</span> | ||
+ | |||
+ | <span style="background-color:#AFEEEE;">MAP_ADCTimerEnable(ADC_BASE);</span> | ||
+ | |||
+ | <span style="background-color:#AFEEEE;">MAP_ADCEnable(ADC_BASE);</span> | ||
+ | |||
+ | <span style="background-color:#AFEEEE;">MAP_ADCChannelEnable(ADC_BASE, uiChannel);</span> | ||
+ | |||
+ | | ||
+ | |||
+ | <span style="background-color:#AFEEEE;">while(uiIndex < NO_OF_SAMPLES + 4)</span> | ||
+ | |||
+ | <span style="background-color:#AFEEEE;">{</span> | ||
+ | |||
+ | <span style="background-color:#AFEEEE;">if(MAP_ADCFIFOLvlGet(ADC_BASE, uiChannel))</span> | ||
+ | |||
+ | <span style="background-color:#AFEEEE;">{</span> | ||
+ | |||
+ | <span style="background-color:#AFEEEE;">ulSample = MAP_ADCFIFORead(ADC_BASE, uiChannel);</span> | ||
+ | |||
+ | //to voltage | ||
+ | |||
+ | <span style="background-color:#AFEEEE;">fSample = ((float)((ulSample>>2) & 0x0FFF)*1.48 )/4096.0;</span> | ||
+ | |||
+ | <span style="background-color:#AFEEEE;">uiIndex++;</span> | ||
+ | |||
+ | <span style="background-color:#AFEEEE;">}</span> | ||
+ | |||
+ | <span style="background-color:#AFEEEE;">}</span> | ||
+ | |||
+ | <span style="background-color:#AFEEEE;">MAP_ADCChannelDisable(ADC_BASE, uiChannel);</span> | ||
+ | |||
+ | <span style="background-color:#AFEEEE;">switch(Channel)</span> | ||
+ | |||
+ | <span style="background-color:#AFEEEE;">{</span> | ||
+ | |||
+ | <span style="background-color:#AFEEEE;">case 0:</span> | ||
+ | |||
+ | <span style="background-color:#AFEEEE;">MAP_PinTypeGPIO(PIN_60, PIN_MODE_0, false);</span> | ||
+ | |||
+ | <span style="background-color:#AFEEEE;">MAP_GPIODirModeSet(GPIOA0_BASE, 0x20, GPIO_DIR_MODE_IN);</span> | ||
+ | |||
+ | <span style="background-color:#AFEEEE;">break; </span> | ||
+ | |||
+ | <span style="background-color:#AFEEEE;">case 4:</span> | ||
+ | |||
+ | <span style="background-color:#AFEEEE;">MAP_PinTypeGPIO(PIN_58, PIN_MODE_0, false);</span> | ||
+ | |||
+ | <span style="background-color:#AFEEEE;">MAP_GPIODirModeSet(GPIOA0_BASE, 0x8, GPIO_DIR_MODE_IN);</span> | ||
+ | |||
+ | <span style="background-color:#AFEEEE;">break;</span> | ||
+ | |||
+ | <span style="background-color:#AFEEEE;">}</span> | ||
+ | |||
+ | <span style="background-color:#AFEEEE;">return fSample;</span> | ||
+ | |||
+ | <span style="background-color:#AFEEEE;">}</span> | ||
+ | |||
+ | ==== ADC Result ==== | ||
+ | |||
+ | See the ADC value in debug message below picture. | ||
+ | <p style="text-align: center;">[[File:ADC Result.png|RTENOTITLE]]</p><p style="text-align: center;"></p> | ||
− | |||
− | |||
== Application Loader == | == Application Loader == | ||
<div style="margin-left:0.847cm;margin-right:0cm;"> | <div style="margin-left:0.847cm;margin-right:0cm;"> |
Latest revision as of 09:01, 13 October 2017
Contents
Introduction
WISE-1520 Software Development Kit (SDK)
Source Tree
Directory | Description |
doc/ | Documents about WISE-1520 SDK. |
inc/ | Header files including examples, sensor driver and etc. |
lib/ | Library. |
project/ | Project files for IDE. |
src/ | Source files including examples, sensor driver and etc. |
packages/ | Software packages. |
tool/ | Tools. |
Software Packages
File Name | Description |
ccs_setup_win32.exe | TI Code Composer Studio (CCS)
Integrated Development Environment (IDE). |
CC3200SDK-1.1.0-windows-installer.exe | TI CC3200 SDK v1.1.0. |
CC31xx_CC32xx_ServicePack-1.0.0.10.0-windows-installer.exe | TI CC3200 Service Pack. |
tirtos_simplelink_setupwin32_2_14_01_20.exe | TI RTOS for CC3200. |
uniflash_setup_3.4.0.00002.exe | TI UniFlash Standalone Flash Tool for TI Microcontrollers (MCU). |
Setup Development Environment
Preparing for Hardware
- WISE-1520, WISE-1500 and WISE-ED20.
- 802.11b/g/n (2.4 GHz) Wireless Access Point (AP).
- PC running the Microsoft® Windows® 7 or XP operating systems.
Please refer to the following steps for setup a WISE series of boards before using WISE-1520 SDK.
Step02: Connect the WISE-ED20 to PC using micro-USB cable. The device will be visible in the Device Manager as below after TI CC3200 SDK or FTDI driver installed. The user can refer to section "Install CC3200 SDK" for how to install CC3200 SDK.
Code Composer Studio (CCS)The user can refer to the following steps for setup CCS with WISE-1520 SDK and get more information from section "TI".
Running CCS installerInstall TI-RTOS
Install CC3200 SDK
Install CC3200 Service PackImport ProjectCompile and Debug
Flash ProgrammingPlease refer to the following steps for flash programming.
Running UniFlash InstallerProgramming
Web ServiceThe web service will show you information and setting about WISE-1520. The user can get it in more detailed as below subsections.
Main Page
WiFi Connectivity Setting
AgentLite
Firmware Upgrade
Remote Reset
Account/PasswordRTC
Firmware Version
ExampleWISE-1520 DemoThere are two mainly examples including AgentLite and OTA the user can refer to it for how to implement it from file “wise1520_demo_main.c” in folder “src/example” of source tree of WISE-1520 SDK. By the way, the user can enable or disable these examples by macro “AGENT_APP_EXAMPLE “and “OTA_APP_EXAMPLE” to decide whether compiled these function into binary or not. In addition to last two examples, the source code of web configuration is also in file “wise1520_demo_main.c” as default.
The default enabled function on WISE-1520 module from manufacture only includes AgentLite and web service and the default debug port is set by UART1. On the other hand, the UART0 is used to print out debug message as default in our examples. The user can use UART1 as debug port by macro “USE_UART1” in compilation.
The WISE-1520 Demo has been implemented based on TI CC3200 SDK and TI RTOS. If the user wants to know in more detailed what the example does, the user must to study domain knowledge about TI CC3200 SDK and TI RTOS that should be found from section "TI".
Detailed about WISE-1520 DemoThe detailed behavior about this example is explained as following:
Import WISE-1520 DemoPlease refer to section "Import Project" for how to import project of WISE-1520 Demo.
AgentLite Example
OTA ExampleThe “Over the Air” (OTA) is method for software update. The new application hosted in cloud can be updated into WISE-1520. For doing this example, the user needs to setup between WISE-1520 and cloud service, and require project of Application Loader running together. The user can refer to section "Application Loader" for how to setup for Application Loader and section "TI" for more information about OTA.
Setup for Cloud Service
Setup for WISE-1520
ADC ExampleHW descriptionThe WISE-1520 has two ADC (analog to digital converter) channels, ADC0 and ADC4. The ADC0 is at M2.COM pin50 and WISE-DB1500 CN3.pin7. The ADC4 is at M2.COM pin59 and WISE-DB1500 CN3.pin15. FW implementAdd below code in wise_1520_main.c or download wise1520_demo_main.zip and unzip. Step 1: add header file //Common interface file in CC3200 SDK #include "common.h" #include "gpio_if.h" #include "adc.h" #include "adc.h" // add header file. Step 2: add function declare //******************************************************************* // Local functions prototypes //******************************************************************* … static float ADC_ReadDatByChannel(uint32_t Channel); … define NO_OF_SAMPLES 128 // define sample times Step 3: add code in caller void ConnectionTask(void* pTaskParams){ … … float fADC0_v; float fADC4_v; … fADC0_v=ADC_ReadDatByChannel(0); UART_PRINT("[ADC0]: %f \n\r", fADC0_v); fADC4_v=ADC_ReadDatByChannel(4); UART_PRINT("[ADC4]: %f \n\r", fADC4_v); } Step 4: function implement float ADC_ReadDatByChannel(uint32_t Channel){ uint32_t uiChannel; uint32_t uiIndex=0; uint32_t ulSample; float fSample = 0.0;
switch(Channel) { case 0: uiChannel = ADC_CH_3; MAP_PinTypeADC(PIN_60, PIN_MODE_255); break; case 4: uiChannel = ADC_CH_1; MAP_PinTypeADC(PIN_58, PIN_MODE_255); break; default: return -1.0; } MAP_ADCTimerConfig(ADC_BASE,2^17); MAP_ADCTimerEnable(ADC_BASE); MAP_ADCEnable(ADC_BASE); MAP_ADCChannelEnable(ADC_BASE, uiChannel);
while(uiIndex < NO_OF_SAMPLES + 4) { if(MAP_ADCFIFOLvlGet(ADC_BASE, uiChannel)) { ulSample = MAP_ADCFIFORead(ADC_BASE, uiChannel); //to voltage fSample = ((float)((ulSample>>2) & 0x0FFF)*1.48 )/4096.0; uiIndex++; } } MAP_ADCChannelDisable(ADC_BASE, uiChannel); switch(Channel) { case 0: MAP_PinTypeGPIO(PIN_60, PIN_MODE_0, false); MAP_GPIODirModeSet(GPIOA0_BASE, 0x20, GPIO_DIR_MODE_IN); break; case 4: MAP_PinTypeGPIO(PIN_58, PIN_MODE_0, false); MAP_GPIODirModeSet(GPIOA0_BASE, 0x8, GPIO_DIR_MODE_IN); break; } return fSample; } ADC ResultSee the ADC value in debug message below picture. Application LoaderThe application loader is loaded by 1st stage loader in the ROM. The user can get it for loading multi-images or other purposes. This example is used to demonstrate how to loading two applications in flash, one is loaded as default and the other is loaded when any keys is pressed on terminal.
Import Application LoaderPlease refer to section "Import Project" for how to import project of Application Loader.
Application Loader ExampleStep01: Compile example. Step02: Launch UniFlash and load configuration. Step03: Compile and create two binaries. Step04: Check options for programming “f80_sys_mcuimgA.bin” binary as below. Step05: Programming into flash and booting from it. Step06: Run the program the user specifies.
AppendixReferencesTIAbout example located at default path(C:\TI\CC3200SDK_X.X.X\cc3200-sdk\docs\examples):
About TI CC3200 SDK located at default path(C:\TI\CC3200SDK_X.X.X\cc3200-sdk\docs):
About TI RTOS located at default path (C:\TI\tirtos_simplelink_X_XX_XX_XX\docs):
About development tools:
The more about CC3200:
Memory/Flash UsageThe WISE-1520 has 1 MBytes flash and 256 KBytes RAM. Flash with MP default Setup (1 block is 4KB):
Flash with OTA Setup (1 block is 4KB):
RAM:
|