Wednesday, February 15, 2017

Conversion between RSSI and LQI in Z-Stack

Z-Stack uses the following formula to convert RSSI and LQI.

LinkQuality = [255* (RSSI-MIN_ED)]/[MAX_ED-MIN_ED]

Therefore with simple algebra

RSSI = MIN_ED+LinkQuality*( MAX_ED-MIN_ED)/255

Default values for MIN_ED and MAX_ED are -87 and 10 respectively.

Then, maybe you can convert RSSI to distance...

Friday, February 10, 2017

Use ZTool + Z-Stack 3.0 ZNP to set up a basic Zigbee 3.0 network

The following steps show you how to use ZTool + Z-Stack 3.0 ZNP to set up Zigbee 3.0 network:

1. You have to prepare two CC253x EVBs (CC2530DK, CC2531EMK, or CC2538EM) and run Z-Stack ZNP 3.0 FW on it.

2. You can run the following MT commands (TX in red) to setup Zigbee 3.0 coordinator.

10:36:58.53 COM1 SYS_OSAL_NV_WRITE (0x2109) --> Write startup option to clear NV when reset
    Id: 0x0003
    Offset: 0x00
    Len: 0x01
    Value: . (0x03)

10:36:58.55 COM1 SYS_OSAL_NV_WRITE_SRSP (0x6109)
    Status: SUCCESS (0x0)

10:37:06.11 COM1 SYS_RESET (0x4100) --> Do reset to clear NV
    Type: 0x00 (HARD RESET) (0x0)

10:37:08.18 COM1 SYS_RESET_RESPONSE (0x4180)
    Reason: 0x02
    TransportRev: 0x02
    Product: 0x00
    MajorRel: 0x02
    MinorRel: 0x07
    HwRev: 0x00

10:37:42.94 COM1 SYS_OSAL_NV_WRITE (0x2109) --> Write ZCD_NV_LOGICAL_TYPE to 0 which means coordinator
    Id: 0x0087
    Offset: 0x00
    Len: 0x01
    Value: . (0x00)

10:37:42.97 COM1 SYS_OSAL_NV_WRITE_SRSP (0x6109)
    Status: SUCCESS (0x0)



10:38:32.55 COM1 APP_CNF_BDB_SET_CHANNEL (0x2F08) --> Set Primary channel mask to channel 13 only
    isPrimary: TRUE (0x1)
    Channel: CHNL_0x00002000 (0x2000)

1
0:38:32.55 COM1 APP_CNF_BDB_SET_CHANNEL_SRSP (0x6F08)
    Status: SUCCESS (0x0)

10:38:34.43 COM1 APP_CNF_BDB_SET_CHANNEL (0x2F08) --> Set Secondary channel to 0x0 to disable secondary channel mask
    isPrimary: FALSE (0x0)
    Channel: NONE (0x0)

10:49:01.44 COM1 APP_CNF_BDB_SET_CHANNEL_SRSP (0x6F08)
    Status: SUCCESS (0x0)

10:38:45.58 COM1 APP_CNF_BDB_START_COMMISSIONING (0x2F05)
--> Start commissioning using network formation as parameter to start coordinator
    CommissioningMode: (0x04) Network Formation (0x4)

10:38:47.35 COM1 APP_CNF_BDB_START_COMMISSIONING_SRSP (0x6F05)
    Status: SUCCESS (0x0)

10:38:47.35 COM1 ZDO_STATE_CHANGE_IND (0x45C0)
    State: 8 (0x8)

10:38:47.36 COM1 APP_CNF_BDB_COMMISSIONING_NOTIFICATION (0x4F80)
    Status: 1 (0x1)
    Commissioning Mode: 0x02 (Formation) (0x2)
    Commissioning Mode: 254 (0xFE)

10:38:47.62 COM1 ZDO_STATE_CHANGE_IND (0x45C0)
    State: 8 (0x8)

10:38:47.88 COM1 ZDO_STATE_CHANGE_IND (0x45C0)
    State: 8 (0x8)

10:38:48.15 COM1 ZDO_STATE_CHANGE_IND (0x45C0)
    State: 8 (0x8)

10:38:48.41 COM1 ZDO_STATE_CHANGE_IND (0x45C0)
    State: 8 (0x8)

10:38:48.68 COM1 ZDO_STATE_CHANGE_IND (0x45C0)
    State: 8 (0x8)

10:38:48.94 COM1 ZDO_STATE_CHANGE_IND (0x45C0)
    State: 8 (0x8)

10:38:49.49 COM1 ZDO_STATE_CHANGE_IND (0x45C0)
    State: 9 (0x9)

10:38:49.49 COM1 APP_CNF_BDB_COMMISSIONING_NOTIFICATION (0x4F80)
    Status: 0x00 (Success) (0x0)
    Commissioning Mode: 0x02 (Formation) (0x2)
    Commissioning Mode: 69 (0x45)

10:39:11.49 COM1 UTIL_GET_DEVICE_INFO (0x2700) --> Get device info to confirm coordinator is setup correctly

10:39:11.5 COM1 UTIL_GET_DEVICE_INFO_RESPONSE (0x6700)
    Status: SUCCESS (0x0)
    IEEEAddr: 0x00124B0001025822
    ShortAddress: 0x0000
    DeviceType: COORDINATOR, ROUTER, END_DEVICE (0x7)
    DeviceState: DEV_ZB_COORD (0x9)
    NumAssocDevices: 0x00
    AssocDevicesList

10:39:26.7 COM1 SYS_OSAL_NV_WRITE (0x2109) --> Write ZCD_NV_ZDO_DIRECT_CB to 1 to receive ZDO related messages
    Id: 0x008F
    Offset: 0x00
    Len: 0x01
    Value: . (0x01)

10:39:26.71 COM1 SYS_OSAL_NV_WRITE_SRSP (0x6109)
    Status: SUCCESS (0x0) 


10:44:16.54 COM1 APP_CNF_BDB_START_COMMISSIONING (0x2F05) --> Start commissioning using network steering as parameter to be ready for device to join
    CommissioningMode: (0x02) Network Steering (0x2)

10:44:16.55 COM1 APP_CNF_BDB_START_COMMISSIONING_SRSP (0x6F05)
    Status: SUCCESS (0x0)

10:44:16.56 COM1 ZDO_MGMT_PERMIT_JOIN_RSP (0x45B6)
    SrcAddr: 0x0000
    Status: ZDP_SUCCESS (0x0)

10:44:16.57 COM1 APP_CNF_BDB_COMMISSIONING_NOTIFICATION (0x4F80)
    Status: 0x00 (Success) (0x0)
    Commissioning Mode: 0x01 (Network Steering) (0x1)
    Commissioning Mode: 67 (0x43)


3. You can run the following MT commands to setup Zigbee 3.0 router.

10:43:43.75 COM99 SYS_OSAL_NV_WRITE (0x2109) --> Write ZCD_NV_LOGICAL_TYPE to 1 which means router
    Id: 0x0087
    Offset: 0x00
    Len: 0x01
    Value: . (0x01)

10:43:59.35 COM1 APP_CNF_BDB_SET_CHANNEL (0x2F08) --> Set Primary channel mask to channel 13 only
    isPrimary: TRUE (0x1)
    Channel: CHNL_0x00002000 (0x2000)
10:43:59.35 COM1 APP_CNF_BDB_SET_CHANNEL_SRSP (0x6F08)
    Status: SUCCESS (0x0)

10:44:11.43 COM1 APP_CNF_BDB_SET_CHANNEL (0x2F08) --> Set Secondary channel to 0x0 to disable secondary channel mask
    isPrimary: FALSE (0x0)
    Channel: NONE (0x0)
10:44:11.45 COM1 APP_CNF_BDB_SET_CHANNEL_SRSP (0x6F08)
    Status: SUCCESS (0x0)

10:44:26.46 COM99 APP_CNF_BDB_START_COMMISSIONING (0x2F05) --> Start commissioning using network steering as parameter to make device to start scan Zigbee network to join
    CommissioningMode: (0x02) Network Steering (0x2)

10:44:26.46 COM99 APP_CNF_BDB_START_COMMISSIONING_SRSP (0x6F05)
    Status: SUCCESS (0x0)

10:44:26.56 COM99 APP_CNF_BDB_COMMISSIONING_NOTIFICATION (0x4F80)
    Status: 1 (0x1)
    Commissioning Mode: 0x01 (Network Steering) (0x1)
    Commissioning Mode: 0 (0x0)

10:44:26.8 COM99 ZDO_STATE_CHANGE_IND (0x45C0)
    State: INVALID_PARAMETER (0x2)

10:44:27.11 COM99 ZDO_STATE_CHANGE_IND (0x45C0)
    State: INVALID_PARAMETER (0x2)

10:44:27.37 COM99 ZDO_STATE_CHANGE_IND (0x45C0)
    State: 3 (0x3)

10:44:27.88 COM99 ZDO_STATE_CHANGE_IND (0x45C0)
    State: 5 (0x5)

10:44:28.24 COM99 ZDO_STATE_CHANGE_IND (0x45C0)
    State: 7 (0x7)

10:44:28.9 COM99 APP_CNF_BDB_COMMISSIONING_NOTIFICATION (0x4F80)
    Status: 0x00 (Success) (0x0)
--> Router joins coordinator successfully
    Commissioning Mode: 0x01 (Network Steering) (0x1)
    Commissioning Mode: 0 (0x0)

11:03:22.81 COM99 UTIL_GET_DEVICE_INFO (0x2700)--> Get device info to confirm router is setup correctly

11:03:22.81 COM99 UTIL_GET_DEVICE_INFO_RESPONSE (0x6700)
    Status: SUCCESS (0x0)
    IEEEAddr: 0x00124B0000E50127
    ShortAddress: 0x4EE6
    DeviceType: COORDINATOR, ROUTER, END_DEVICE (0x7)
    DeviceState: DEV_ROUTER (0x7)
    NumAssocDevices: 0x00
    AssocDevicesList
 

4. On Ztool of coordinator, you should see ZDO_END_DEVICE_ANNCE_IND pops when router joins coordinator.

10:44:28.84 COM1 ZDO_END_DEVICE_ANNCE_IND (0x45C1)
    SrcAddr: 0x4EE6
    NwkAddr: 0x4EE6
    IEEEAddr: 0x00124B0000E50127
    Capabilities: 0x8E

Thursday, February 9, 2017

How to add a COAP resource to read ADC input from DIO23 in Contiki cc26xx-web-demo on CC2650 LaunchPad.

To add a COAP resource to read ADC input from DIO23 in Contiki cc26xx-web-demo on CC2650 LaunchPad, you have to add the following code with "+" into your cc26xx-web-demo.c, cc26xx-web-demo.h, coap-server.c, and res-sensors.c.

1. /examples/cc26xx/cc26xx-web-demo/cc26xx-web-demo.c
@@ -55,9 +55,15 @@
 #include
 #include
 #include
+
+#include "ti-lib.h"
+#include "driverlib/aux_adc.h"
+#include "driverlib/aux_wuc.h"
+

 /*---------------------------------------------------------------------------*/
 PROCESS_NAME(cetic_6lbr_client_process);
 PROCESS(cc26xx_web_demo_process, "CC26XX Web Demo");
+PROCESS(adc_process, "ADC process");
 /*---------------------------------------------------------------------------*/
 /*
  * Update sensor readings in a staggered fashion every SENSOR_READING_PERIOD
@@ -84,6 +90,9 @@ static struct uip_icmp6_echo_reply_notification echo_reply_notification;
 static struct etimer echo_request_timer;
 int def_rt_rssi = 0;
 #endif
+
+uint16_t singleSample;
+

 /*---------------------------------------------------------------------------*/
 process_event_t cc26xx_web_demo_publish_event;
 process_event_t cc26xx_web_demo_config_loaded_event;
@@ -110,6 +119,9 @@ DEMO_SENSOR(batmon_temp, CC26XX_WEB_DEMO_SENSOR_BATMON_TEMP,
 DEMO_SENSOR(batmon_volt, CC26XX_WEB_DEMO_SENSOR_BATMON_VOLT,
             "Battery Volt", "battery-volt", "batmon_volt",
             CC26XX_WEB_DEMO_UNIT_VOLT);
+DEMO_SENSOR(adc_dio23, CC26XX_WEB_DEMO_SENSOR_ADC_DIO23,
+            "ADC DIO23", "adc-dio23", "adc_dio23",
+            CC26XX_WEB_DEMO_UNIT_VOLT);

 /* Sensortag sensors */
 #if BOARD_SENSORTAG
@@ -464,6 +476,14 @@ get_batmon_reading(void *data)
     }
   }

+  if(adc_dio23_reading.publish) {
+    if(1) {
+      buf = adc_dio23_reading.converted;
+      memset(buf, 0, CC26XX_WEB_DEMO_CONVERTED_LEN);
+      snprintf(buf, CC26XX_WEB_DEMO_CONVERTED_LEN, "%d", singleSample);
+    }
+  }
+

   ctimer_set(&batmon_timer, next, get_batmon_reading, NULL);
 }
 /*---------------------------------------------------------------------------*/
@@ -825,6 +845,7 @@ init_sensors(void)

   list_add(sensor_list, &batmon_temp_reading);
   list_add(sensor_list, &batmon_volt_reading);
+  list_add(sensor_list, &adc_dio23_reading);
   SENSORS_ACTIVATE(batmon_sensor);

 #if BOARD_SENSORTAG
@@ -864,6 +885,7 @@ PROCESS_THREAD(cc26xx_web_demo_process, ev, data)

   /* Start all other (enabled) processes first */
   process_start(&httpd_simple_process, NULL);
+  process_start(&adc_process, NULL);
 #if CC26XX_WEB_DEMO_COAP_SERVER
   process_start(&coap_server_process, NULL);
 #endif
@@ -966,6 +988,56 @@ PROCESS_THREAD(cc26xx_web_demo_process, ev, data)

   PROCESS_END();
 }
+
+PROCESS_THREAD(adc_process, ev, data)
+{
+  PROCESS_BEGIN();
+  static struct etimer et_adc;
+  while(1)
+  {
+         etimer_set(&et_adc, CLOCK_SECOND*5);
+         PROCESS_WAIT_EVENT();
+         if(etimer_expired(&et_adc)) {
+               //intialisation of ADC
+               ti_lib_aon_wuc_aux_wakeup_event(AONWUC_AUX_WAKEUP);
+               while(!(ti_lib_aon_wuc_power_status_get() & AONWUC_AUX_POWER_ON))
+               { }
+
+               // Enable clock for ADC digital and analog interface (not currently enabled in driver)
+               // Enable clocks
+               ti_lib_aux_wuc_clock_enable(AUX_WUC_ADI_CLOCK | AUX_WUC_ANAIF_CLOCK | AUX_WUC_SMPH_CLOCK);
+               while(ti_lib_aux_wuc_clock_status(AUX_WUC_ADI_CLOCK | AUX_WUC_ANAIF_CLOCK | AUX_WUC_SMPH_CLOCK) != AUX_WUC_CLOCK_READY)
+               { }
+               //printf("clock selected\r\n");
+
+               // Connect AUX IO7 (DIO23, but also DP2 on XDS110) as analog input.
+               AUXADCSelectInput(ADC_COMPB_IN_AUXIO7);
+               //printf("input selected\r\n");
+
+               // Set up ADC range
+               // AUXADC_REF_FIXED = nominally 4.3 V
+               AUXADCEnableSync(AUXADC_REF_FIXED,  AUXADC_SAMPLE_TIME_2P7_US, AUXADC_TRIGGER_MANUAL);
+               //printf("init adc --- OK\r\n");
+
+               //Trigger ADC converting
+               AUXADCGenManualTrigger();
+               //printf("trigger --- OK\r\n");
+
+               //reading adc value
+               singleSample = AUXADCReadFifo();
+
+               printf("%d mv on ADC\r\n",singleSample);
+
+               //shut the adc down
+               AUXADCDisable();
+               //printf("disable --- OK\r\n");
+               get_batmon_reading(NULL);
+
+               etimer_reset(&et_adc);
+               }
+  }
+  PROCESS_END();
+}

 

2./examples/cc26xx/cc26xx-web-demo/cc26xx-web-demo.h
@@ -146,6 +146,7 @@
 #define CC26XX_WEB_DEMO_SENSOR_MPU_GYRO_X    12
 #define CC26XX_WEB_DEMO_SENSOR_MPU_GYRO_Y    13
 #define CC26XX_WEB_DEMO_SENSOR_MPU_GYRO_Z    14
+#define CC26XX_WEB_DEMO_SENSOR_ADC_DIO23     15
 /*---------------------------------------------------------------------------*/
 extern process_event_t cc26xx_web_demo_publish_event;
 extern process_event_t cc26xx_web_demo_config_loaded_event;

3. /examples/cc26xx/cc26xx-web-demo/coap-server.c
@@ -50,6 +50,7 @@ extern resource_t res_leds;

 extern resource_t res_batmon_temp;
 extern resource_t res_batmon_volt;
+extern resource_t res_adc_dio23;

 extern resource_t res_device_sw;
 extern resource_t res_device_hw;
@@ -133,6 +134,7 @@ PROCESS_THREAD(coap_server_process, ev, data)

   rest_activate_resource(&res_batmon_temp, "sen/batmon/temp");
   rest_activate_resource(&res_batmon_volt, "sen/batmon/voltage");
+  rest_activate_resource(&res_adc_dio23, "adc/dio23");

   rest_activate_resource(&res_device_hw, "dev/mdl/hw");
   rest_activate_resource(&res_device_sw, "dev/mdl/sw");

4. examples/cc26xx/cc26xx-web-demo/resources/res-sensors.c
@@ -111,12 +111,24 @@ res_get_handler_batmon_volt(void *request, void *response, uint8_t *buffer,
                       buffer, preferred_size, offset);
 }
 /*---------------------------------------------------------------------------*/
+static void
+res_get_handler_adc_dio23(void *request, void *response, uint8_t *buffer,
+                            uint16_t preferred_size, int32_t *offset)
+{
+  res_get_handler_all(CC26XX_WEB_DEMO_SENSOR_ADC_DIO23, request, response,
+                      buffer, preferred_size, offset);
+}
+/*---------------------------------------------------------------------------*/

 RESOURCE(res_batmon_temp, "title=\"Battery Temp\";rt=\"C\"",
          res_get_handler_batmon_temp, NULL, NULL, NULL);
 /*---------------------------------------------------------------------------*/
 RESOURCE(res_batmon_volt, "title=\"Battery Voltage\";rt=\"mV\"",
          res_get_handler_batmon_volt, NULL, NULL, NULL);
 /*---------------------------------------------------------------------------*/
+/*---------------------------------------------------------------------------*/
+RESOURCE(res_adc_dio23, "title=\"ADC DIO23\";rt=\"mV\"",
+         res_get_handler_adc_dio23, NULL, NULL, NULL);
+/*---------------------------------------------------------------------------*/

 #if BOARD_SENSORTAG
 /*---------------------------------------------------------------------------*/
 /* MPU resources and handler: Accelerometer and Gyro */

Build cc26xx-web-demo for CC2650 LaunchPad by "make TARGET=srf06-cc26xx BOARD=launchpad/cc2650 cc26xx-web-demo.bin" and download cc26xx-web-demo.bin to your CC2650 LaunchPad. Let it join 6lbr and you should see resource adc/dio23 on COAP interface. You can press Get button to get the ADC reading from DIO23. Try to connect different voltage (0-3.6V) to test.


Wednesday, January 11, 2017

Build 6lbr running on CC2650DK or CC1310DK

The following steps show how to build 6lbr running CC2650DK or CC1310DK

1. Refer to http://sunmaysky.blogspot.tw/2016/03/running-6lbr-on-cc2538dk-with-enc28j60.html which shows you how to connect ENC28J60 to SmartRF06EB.

2. git clone --recursive https://github.com/cetic/6lbr

3. Change "#define CETIC_6LBR_NVM_DEFAULT_CHANNEL 26" in \6lbr\examples\6lbr\6lbrnvm-data.h to "#define CETIC_6LBR_NVM_DEFAULT_CHANNEL 25"

4.  Add "#define RF_CORE_CONF_CHANNEL 25" into common configuration in \6lbr\examples\6lbr\project-conf.h

5. Change directory to \6lbr\examples\6lbr

6. Run "make TARGET=srf06-cc26xx BOARD=srf06/cc26xx all" for CC2650DK or "make TARGET=srf06-cc26xx BOARD=srf06/cc13xx all" for CC1310DK.

7. Download cetic_6lbr_router.bin under \6lbr\examples\6lbr\bin_srf06-cc26xx to CC2650DK or CC1310DK with Flash Programmer 2.

8. You should see the following outputs on UART of CC1310DK.



9. You can access to [bbbb::100] now.



Monday, December 19, 2016

How to use backdoor boot loader to download FW to CC2650 LaunchPad

The following steps show you how to use backdoor boot loader to download FW to CC2650 LaunchPad:

1. Connect CC2650 LaunchPad DIO11 to GND.


2. Press "RESET" button on CC2650 LaunchPad to restart CC2650 LaunchPad.

3. Select FW and download it to CC2650. You would get the following error and "Failed" on Flash Programmer2 but it actually program and verify successfully.

Thursday, November 10, 2016

Build MicroPython on Cygwin to run on CC3200 LaunchPad and toggle Yellow LED (D6)

The following steps show you how to build MicroPython on Cygwin

1. Download MicroPython by "git clone --recursive https://github.com/micropython/micropython"

2. Switch to CC3200 MicroPython folder by "cd /cygdrive/$DRIVE_LETTER$/$MICROPYTHON_DIRECTORY$/cc3200/"

3. Build Bootloader by "make BTARGET=bootloader BTYPE=release BOARD=LAUNCHXL"

4. Build Application by "make BTARGET=application BTYPE=release BOARD=LAUNCHXL". You might suffer build problem because of Python version problem and the following steps show you how to fix them.

4.1------
You will get the following similar error which is caused by Python version on Cygwin:
Use make V=1 or set BUILD_VERBOSE in your environment to increase build verbosity.
mkdir -p build/LAUNCHXL/release/genhdr
Create build/LAUNCHXL/release/genhdr/pins.h
/c/cygwin64/bin/python: /c/cygwin64/bin/python: cannot execute binary file
make: *** [application.mk:248: build/LAUNCHXL/release/genhdr/pins.h] Error 126


You can run the following Python command:
 python boards/make-pins.py --board boards/LAUNCHXL/pins.csv --af boards/cc3200_af.csv --prefix boards/cc3200_prefix.c --hdr build/LAUNCHXL/release/genhdr/pins.h --qstr build/LAUNCHXL/release/pins_qstr.h > build/LAUNCHXL/release/pins.c

Comment out line 248 "$(Q)$(PYTHON) $(MAKE_PINS) --board $(BOARD_PINS) --af $(AF_FILE) --prefix $(PREFIX_FILE) --hdr $(GEN_PINS_HDR) --qstr $(GEN_PINS_QSTR) > $(GEN_PINS_SRC)" in application.mk and keep making by:

 make BTARGET=application BTYPE=release BOARD=LAUNCHXL

4.2------------------
You will again get the following similar error which is caused by Python version on Cygwin:
Use make V=1 or set BUILD_VERBOSE in your environment to increase build verbosity.
/c/cygwin64/bin/python: /c/cygwin64/bin/python: cannot execute binary file
make: *** [../py/py.mk:259: build/LAUNCHXL/release/genhdr/mpversion.h] Error 126


You can run the following Python command:
python ../py/makeversionhdr.py build/LAUNCHXL/release/genhdr/mpversion.h

Comment out line 259 "$(Q)$(PYTHON) $(PY_SRC)/makeversionhdr.py $" in py.mk and keep making by:

 make BTARGET=application BTYPE=release BOARD=LAUNCHXL

4.3 -------------------
You will again get the following similar error which is caused by Python version on Cygwin:
 Use make V=1 or set BUILD_VERBOSE in your environment to increase build verbosity.
GEN build/LAUNCHXL/release/genhdr/qstr.i.last
GEN build/LAUNCHXL/release/genhdr/qstr.split
/c/cygwin64/bin/python: /c/cygwin64/bin/python: cannot execute binary file
make: *** [../py/mkrules.mk:83: build/LAUNCHXL/release/genhdr/qstr.split] Error 126


 You can run the following Python command:python ../py/makeqstrdefs.py split build/LAUNCHXL/release/genhdr/qstr.i.last build/LAUNCHXL/release/genhdr/qstr build/LAUNCHXL/release/genhdr/qstrdefs.collected.h

Comment out line 83 "$(Q)$(PYTHON) $(PY_SRC)/makeqstrdefs.py split $(HEADER_BUILD)/qstr.i.last $(HEADER_BUILD)/qstr $(QSTR_DEFS_COLLECTED)" in mkrules.mk and keep making by:

 make BTARGET=application BTYPE=release BOARD=LAUNCHXL

4.4---------------------
You will again get the following similar error which is caused by Python version on Cygwin:

Use make V=1 or set BUILD_VERBOSE in your environment to increase build verbosity.
GEN build/LAUNCHXL/release/genhdr/qstr.split
GEN build/LAUNCHXL/release/genhdr/qstrdefs.collected.h
/c/cygwin64/bin/python: /c/cygwin64/bin/python: cannot execute binary file
make: *** [../py/mkrules.mk:88: build/LAUNCHXL/release/genhdr/qstrdefs.collected.h] Error 126


You can run the following Python command:
python ../py/makeqstrdefs.py cat build/LAUNCHXL/release/genhdr/qstr.i.last build/LAUNCHXL/release/genhdr/qstr build/LAUNCHXL/release/genhdr/qstrdefs.collected.h

Comment out line 88 "$(Q)$(PYTHON) $(PY_SRC)/makeqstrdefs.py cat $(HEADER_BUILD)/qstr.i.last $(HEADER_BUILD)/qstr $(QSTR_DEFS_COLLECTED)" in mkrules.mk and keep making by:

make BTARGET=application BTYPE=release BOARD=LAUNCHXL

4.5-------------------
You will again get the following similar error which is caused by Python version on Cygwin:

Use make V=1 or set BUILD_VERBOSE in your environment to increase build verbosity.
GEN build/LAUNCHXL/release/genhdr/qstrdefs.generated.h
/c/cygwin64/bin/python: /c/cygwin64/bin/python: cannot execute binary file
make: *** [../py/py.mk:273: build/LAUNCHXL/release/genhdr/qstrdefs.generated.h] Error 126
make: *** Deleting file 'build/LAUNCHXL/release/genhdr/qstrdefs.generated.h'


You can run the following Python command:
python ../py/makeqstrdata.py build/LAUNCHXL/release/genhdr/qstrdefs.preprocessed.h > build/LAUNCHXL/release/genhdr/qstrdefs.generated.h
 
Comment out line 273 "$(Q)$(PYTHON) $(PY_SRC)/makeqstrdata.py $(HEADER_BUILD)/qstrdefs.preprocessed.h > $@" in py.mk and keep making by:

make BTARGET=application BTYPE=release BOARD=LAUNCHXL

5. Finally, you will get application binary mcuimg.bin under micropython\cc3200\build\LAUNCHXL\release folder and boot loader binary bootloader.bin under micropython\cc3200\bootmgr\build\LAUNCHXL\release

6. Refer to http://processors.wiki.ti.com/index.php/User:Dbartlett/MicroPython_CC3200 to download bootloader.bin and mcuimg.bin to CC3200 LaunchPad. Please note CC3200 LAUNCHXL must be Rev 4.1 or higher. Devices older than this revision will not work.

7. Connect to MicroPython and try to following codes to turn on/off Yelleo LED (D6) on CC3200 LaunchPad.

       machine.Pin.board.GP10
       led=machine.Pin(machine.Pin.board.GP10, mode=machine.Pin.OUT)
       led.value(False) -->turn off LED
       led.value(True) -->turn on LED



Thursday, October 27, 2016

How to create a periodic event for CC253x/CC254x Z-Stack and BLE Stack.

The following codes show example to create a periodic event that is triggered every 5 seconds for CC253x in Z-Stack and you can do it accordingly for CC254x in BLE Stack.

1. Add "#define PERIODIC_EVT 0x0001"in your code. Please note that event define has to be an unused bit mask of uint16.

2. Put  the following line at where you want to start PERIODIC_EVT

osal_start_timerEx( zcl_XXX_TaskID, PERIODIC_EVT, 10 );


2. Create PERIODIC_EVT processing in zcl_XXX_event_loop
if( events & PERIODIC_EVT )
{
  //Do things that need periodic processing here!
  ...
  osal_start_timerEx( zcl_XXX_TaskID, PERIODIC_EVT, 5000 );
  return (events ^ PERIODIC_EVT);
}