Showing posts with label CC2650. Show all posts
Showing posts with label CC2650. Show all posts

Thursday, June 4, 2020

How to add you own custom board files to CC26xx BLE stack


The following steps show you how to add you own custom board files to CC26xx BLE stack using CC2650 BLE stack 2.2.04.06 version

1. Create CC2650_YK folder under C:\ti\simplelink\ble_sdk_2_02_04_06\src\boards\

2.
   2.1 Copy Board.h/CC2650_LAUNCHXL.h/CC2650_LAUNCHXL.c from C:\ti\simplelink\ble_sdk_2_02_04_06\src\boards\CC2650_LAUNCHXL to C:\ti\simplelink\ble_sdk_2_02_04_06\src\boards\CC2650_YK
  
   2.2 Rename CC2650_LAUNCHXL.h/CC2650_LAUNCHXL.c to CC2650_YK.h/CC2650_YK.c
  
   2.3 Revise #include "CC2650_LAUNCHXL.h" in Board.h to #include "CC2650_YK.h"

3. Create cc2650yk folder under C:\ti\simplelink\ble_sdk_2_02_04_06\src\target

4
   4.1 Copy cc2650lp_board.h/cc2650lp_board.c from C:\ti\simplelink\ble_sdk_2_02_04_06\src\target\cc2650lp to C:\ti\simplelink\ble_sdk_2_02_04_06\src\target\cc2650yk

   4.2 Rename cc2650lp_board.h/cc2650lp_board.c to cc2650yk_board.h/cc2650yk_board.c

   4.3 Add the following codes in cc2650yk_board.h
      
       #elif defined(CC2650_YK)
       #include <../../boards/CC2650_YK/Board.h>

   4.4 Add the following codes in cc2650yk_board.c

       #elif defined(CC2650_YK)
       #include <../../boards/CC2650_YK/Board.h>
       #include <../../boards/CC2650_YK/CC2650_YK.c>

5.
   5.1 Add the following codes in board.h
  
       #elif defined(CC2650_YK)
       #include "./cc2650yk/cc2650yk_board.h"

   5.2 Add the following codes in board.c
  
       #elif defined(CC2650_YK)
       #include "./cc2650yk/cc2650yk_board.c"

6. Change CC2650_LAUNCHXL in Predefined Symbols to CC2650_YK

7. Now you can build the code with your own custom board.

Monday, May 6, 2019

How to check APS ack in TI Z-Stack

The following steps show you how to check APS ack in TI Z-Stack using ON/OFF cluster toggle command in SampleSwitch example.

1. Setup OnOffOptions and use zcl_registerClusterOptionList in  zclSampleSw_Init to register receiving APS ack on ZCL_CLUSTER_ID_GEN_ON_OFF cluster command.
   
    zclOptionRec_t OnOffOptions[] =
    {
      {
         ZCL_CLUSTER_ID_GEN_ON_OFF, ( AF_EN_SECURITY | AF_ACK_REQUEST ),
      },
    };
    ZStatus_t status = zcl_registerClusterOptionList ( SAMPLESW_ENDPOINT, 1,
                                                                                    OnOffOptions );
 2.  Add "case AF_DATA_CONFIRM_CMD:..." in SYS_EVENT_MSG case of zclSampleSw_event_loop

    uint16 zclSampleSw_event_loop( uint8 task_id, uint16 events )
    {
      ...
     
      if ( events & SYS_EVENT_MSG )
      {
        while ( (MSGpkt = (afIncomingMSGPacket_t *)osal_msg_receive( zclSampleSw_TaskID )) )
        {
          switch ( MSGpkt->hdr.event )
          {
            case AF_DATA_CONFIRM_CMD:
              afDataConfirm_t *SWafDataConfirm;
              SWafDataConfirm = (afDataConfirm_t *)MSGpkt;
              rcv_aps_ack_trans_id=SWafDataConfirm->transID;
              // You can use rcv_aps_ack_trans_id to check if it matches to APS_Counter when you send toggle command with zclGeneral_SendOnOff_CmdToggle
              break;
     ...

Thursday, October 11, 2018

How to use serial bootloader mode to download binary to LAUNCHXL-CC1310/LAUNCHXL-CC2650 using Flash Programmer 2

The following steps show you how to use serial bootloader mode to download binary to LAUNCHXL-CC1310/LAUNCHXL-CC2650 using Flash Programmer 2.

1. Select XDS110 CC1310 connection to do mass erase.


2. Select CC1310 and connect it to XDS110 Class Application/User Uart.




3. Select binary to download and you should see "Sucess!" after download.


Thursday, October 19, 2017

Using CC13xx/CC26xx running Contiki OS to toggle LED from UART.

The following example shows how to using CC13xx/CC26xx running Contiki OS to toggle LED from UART.

1. Replace the following code into hell-world.c

#include "contiki.h"
#include "dev/cc26xx-uart.h"
#include "dev/serial-line.h"
#include "dev/leds.h"

#include < stdio.h >/* For printf() */
#include  < string.h >


 PROCESS(test_serial, "Serial line test process");
 AUTOSTART_PROCESSES(&test_serial);

 PROCESS_THREAD(test_serial, ev, data)
 {
   PROCESS_BEGIN();
   cc26xx_uart_set_input(serial_line_input_byte);
  
   printf("Hello, world Serial line test\n");

   for(;;) {
     PROCESS_YIELD();
     if(ev == serial_line_event_message) {
       printf("received line: %s\n", (char *)data);
       if(strcmp(data,"ON")==0)
           leds_on(LEDS_GREEN);
       else if(strcmp(data,"OFF")==0)
           leds_off(LEDS_GREEN);
     }
   }
   PROCESS_END();
 }


2. Build hello-world.bin for LAUNCHXL-CC1310 using  "make TARGET=srf06-cc26xx BOARD=launchpad/cc1310 hello-world.bin"

3. Download hello-world.bin to LAUNCHXL-CC1310 using Flash Programmer 2.

4. Start a terminal tool like teraterm to connect to LAUNCHXL-CC1310 application virtual COM port..

5. Enter "ON" and "CTRL+Enter" to send ON command with end character "0x0A" to LAUNCHXL-CC1310 and you will see green led is turned on

6. Enter "OFF" and "CTRL+Enter" to send OFF command with end character "0x0A" to LAUNCHXL-CC1310 and you will see green led is turned on

Monday, August 22, 2016

How to use backdoor serial boot loader for CC2650/CC2640/CC2630/CC2538

The following steps show you how to use backdoor serial boot loader for CC2650/CC2640/CC2630/CC2538

1. CC2650/CC2640/CC2630/CC2538 support backdoor Serial Bootloader Interface by default. It might be sometimes overwritten by your application so you might need to do "Mass Erase" from Flash Programmer 2 to make it come back.


2. Hold "SELECT" and press "RESET" button on SmartRF06EB.

3. Select correct chip from virtual COM port simulated by SmartRF06EB. In my case, I use CC2650


4. Then click mouse right button to connect CC2650 from virtual COM port.


5. 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.

>Initiate access to target: COM53.
>Reading file: C:/ti/simplelink/ble_sdk_2_02_00_31/examples/hex/cc2650lp_host_test_rel.hex.
>Start flash erase ...
>Erase finished successfully.
>Start flash programming ...
>Warning: CC2650 bootloader will be disabled.
>Flash programming locked bootloader access. No further actions possible.
>Programming finished successfully.
>Start flash verify ...
>ERROR: No connection between interface and target.
>Reset target ...


6. Test your application on CC2650

Wednesday, April 6, 2016

Contiki CC2650 ADC demo using DIO23 as ADC input

The following code shows how to use CC2650 DIO23 as ADC input to read analog signal in Contiki OS.

1. Replace the following code to hello-world.c

#include "contiki.h"
#include "ti-lib.h"
#include "driverlib/aux_adc.h"
#include "driverlib/aux_wuc.h"

#include /* For printf() */

#define CLOCK_SECOND 128

char buf[32];
static struct etimer et;

/*---------------------------------------------------------------------------*/
PROCESS(hello_world_process, "Hello world process");
AUTOSTART_PROCESSES(&hello_world_process);
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(hello_world_process, ev, data)
{
  PROCESS_BEGIN();
    unsigned short i;
    uint16_t singleSample;

    etimer_set(&et, CLOCK_SECOND);
    printf("Contiki CC26xx ADC demo using DIO23 as ADC input\r\n");
    while(1)
    {
        if(ev == PROCESS_EVENT_TIMER && etimer_expired(&et)) {
        //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");

        }
        etimer_set(&et, CLOCK_SECOND);
        PROCESS_YIELD();
    }

  PROCESS_END();
}


2. Build by "make TARGET=srf06-cc26xx BOARD=srf06/cc26xx hello-world.bin" and download hello-world.bin using Flash Programmer 2 to CC2650 LaunchPad.

3. You can see ADC reading output on UART.


Friday, April 1, 2016

Steps for TI CC26xx BLE stack applications to use System_printf

1) Modify your appBLE.cfg config file (e.g. CCS->Project Explorer->YourApp->TOOLS->appBLE.cfg)

//System.SupportProxy = SysCallback; //Comment out this line and add the following 3 lines
var SysStd = xdc.useModule("xdc.runtime.SysStd");
var System = xdc.useModule("xdc.runtime.System");
System.SupportProxy = SysStd;

2) Add the following header file to your C file

#include < xdc/runtime/System.h >

3. Use System_printf("Test\n") and System_flush() to output messages.

Thursday, November 12, 2015

How to build DTLS example for SmartRF06EB+CC2650EM in Contiki 6LowPAN

The following steps show you how to build DTLS example for SmartRF06EB+CC2650EM in Contiki 6LowPAN.

On SmartRF06EB+CC2650EM side:

1. Do "git clone --recursive https://github.com/cetic/6lbr" to get source code of 6lbr which contains DTLS examples.

2. Do "git clone --recursive https://github.com/contiki-os/contiki" to get Contiki source code

3. Copy folder "6lbr-demo" under "\6lbr\examples\" to "\contiki\examples"

4. Copy folder "tinydtls" under "\6lbr\apps\" to "\contiki\apps\"

5. Revise "#include "debug.h"" to "#include "../../../../apps/tinydtls/debug.h"" in \contiki\examples\6lbr-demo\apps\dtls-echo\dtls-echo.c.

6. Go to directory "\contiki\examples\6lbr-demo" and do "make TARGET=srf06-cc26xx clean" to clean up things.

7. Do "make TARGET=srf06-cc26xx WITH_TINYDTLS=1 WITH_DTLSECHO=1 6lbr-demo.bin" to get 6lbr-demo.bin which contains DTLS echo application for SmartRF06EB+CC2650EM.

8.  Download 6lbr-demo.bin to SmartRF06EB+CC2650EM using Flash Programmer 2.

9. Turn on SmartRF06EB+CC2650EM to join 6lbr Edge Router. If you connect UART to SmartRF06EB, you would see output like the followings:


On VMPlayer side:

1. Download tinyDTLS from http://sourceforge.net/projects/tinydtls/ and untar it to your home folder in Contiki VMPlayer. When I test this, it is tinydtls-0.8.2.

2. Open a terminal and go to "/tinydtls-0.8.2/" folder.

3. Do "./configure" and "make".

4. You will get dtls-client in "/tinydtls-0.8.2/test" folder.



5. If your network interface is eth0, run the following commands in terminal.

    sysctl -w net.ipv6.conf.eth0.accept_ra=1
    sysctl -w net.ipv6.conf.eth0.accept_ra_rt_info_max_plen=64
    route -A inet6 add aaaa::/64 gw bbbb::100

6. Run "./dtls-client aaaa::212:4b00:695:8605" in "/tinydtls-0.8.2/test" folder and you can send something to dtls-server on aaaa::212:4b00:695:8605. You will see echo from dtls-server running on SmartRF06EB+CC2650EM with aaaa::212:4b00:695:8605 as IPv6 address.


Wednesday, September 9, 2015

How to build Contiki 6lbr Slip Radio on CC2650 SensorTag or SmartRF06EB+CC2650EM

Do the following steps to build Contiki 6lbr Slip Radio for CC2650 SensorTag+CC-DEVPACK-DEBUGGER.

1. Change "#if BOARD_CONF_DEBUGGER_DEVPACK" to "#if 1" in \contiki\platform\srf06-cc26xx\sensortag\cc2650\board.h.

2. do "make clean".

3. do "make TARGET=srf06-cc26xx BOARD=sensortag/cc2650 slip-radio.bin".

4. Download slip-radio.bin to CC2650 SensorTag and connect CC2650 SensorTag+CC-DEVPACK-DEBUGGER to 6lbr router (could be Raspberry Pi or BeagleBone Black).

5. On 6lbr router, do "sudo vi /etc/6lbr/6lbr.conf" and make sure "DEV_RADIO=/dev/ttyACM0".

6. On 6lbr router, start 6lbr with "sudo service 6lbr start"


Do the following steps to build Contiki 6lbr Slip Radio for SmartRF06EB+CC2650EM.

1. do "make clean".

2. do "make TARGET=srf06-cc26xx BOARD=srf06/cc26xx slip-radio.bin".

3. Download slip-radio.bin to SmartRF06EB+CC2650EM and connect FT232 Serial-to-USB dongle to P412 on SmartRF06EB. Connect FT232 to 6lbr router (could be Raspberry Pi or BeagleBone Black).

4. On 6lbr router, do "sudo vi /etc/6lbr/6lbr.conf" and make sure "DEV_RADIO=/dev/ttyUSB0".

5. On 6lbr router, start 6lbr with "sudo service 6lbr start"


Tuesday, July 21, 2015

Setup Compile Environment on Windows Cygwin For CC2650/CC2538 Contiki 6LowPAN

The following step-by-step guide shows you how to setup compile environment on Win 7 Cygwin to build Contiki 6LowPAN For CC2650STK, CC2650DK, and CC2538DK.

1. Download and install Cygwin. During Cygwin installation, you have to stop at "Select Packages", put "make" in the seach box, and make sure you select make utility in Devel Category.



2. Install ARM GNU Compiler toolchain. Download and install gcc-arm-none-eabi-4_9-2015q2-20150609-win32.exe. It would be installed to C:\Program Files (x86)\GNU Tools ARM Embedded\4.9 2015q2 and you have to add the path of the installed ARM GNU compiler binaries to PATH environment variable in the Cygwin terminal. To do this, you can add the following line to .bashrc file.

export PATH=/cygdrive/c/Program\ Files\ \(x86\)/GNU\ Tools\ ARM\ Embedded/4.9\ 2015q2/bin/:$PATH

You have to restart Cygwin to enable PATH varibale and type "which arm-none-eabi-gcc" to confirm Cygwin uses correct arm-none-eabi-gcc version.

3. Download and install Msysgit from http://msysgit.github.io/. Remember to select "Use Git Bash only" during installion.





you also have to add the path of the installed Git binaries to PATH environment variable in the Cygwin terminal. To do this, you can add the following line to .bashrc file. You have to restart Cygwin to enable PATH varibale

export PATH=/cygdrive/c/Program\ Files/GNU/bin/:$PATH

4. Switch to C drive by run "cd /cygdrive/c/" under Cygwin. Then, run "git clone --recursive https://github.com/contiki-os/contiki"



5. To build cc26xx-web-demo for CC2650STK, run "cd /cygdrive/c/contiki/examples/cc26xx/cc26xx-web-demo/" and then "make BOARD=sensortag/cc2650 cc26xx-web-demo.bin".



6. After finishing, you will have cc26xx-web-demo.bin under C:\contiki\examples\cc26xx\cc26xx-web-demo

7. You can download cc26xx-web-demo.bin to CC2650STK by using TI Flash Programmer2.

8. For CC2538DK, you can do similar steps to make it work.