Showing posts with label CC2650 LaunchPad. Show all posts
Showing posts with label CC2650 LaunchPad. 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.
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.
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, April 19, 2018
Build and run 6lbr/Contiki-NG cc26xx-web-demo on Rasperry Pi with LAUNCHXL-CC1310/LAUNCHXL-CC2650
The following steps show how to build and run 6lbr/Contiki-NG cc26xx-web-demo on Rasperry Pi with LAUNCHXL-CC1310/LAUNCHXL-CC2650:
1. Build Contiki-NG slip radio for LAUNCHXL-CC1310 on InstantContiki 3.0 or Cygwin (you can refer here to setup Cygwin build environment)
2. Build Contiki-NG cc26x0-web-demo for LAUNCHXL-CC1310 on InstantContiki 3.0 or Cygwin
3. Build 6lbr/Contiki-NG on Rasperry Pi
4. Power on LAUNCHXL-CC1310 running cc26xx-web-demo and you will see it pops on sensors tab of 6lbr web page. You can test http or coap function on cc26xx-web-demo now.
1. Build Contiki-NG slip radio for LAUNCHXL-CC1310 on InstantContiki 3.0 or Cygwin (you can refer here to setup Cygwin build environment)
- 1.1 Do "git clone --recursive https://github.com/contiki-ng/contiki-ng"
- 1.2 Switch to directory contiki-ng/
- 1.3 Do "git submodule sync" and "git submodule update --init"
- 1.4 Switch to directory contiki-ng/examples/slip-radio
- 1.5 Since 6lbr/Contiki-NG only supports RPL-CLASSIC now, we use "make TARGET=cc26x0-cc13x0
srf06-cc26xxBOARD=launchpad/cc1310 MAKE_ROUTING=MAKE_ROUTING_RPL_CLASSICslip-radio.bin" to build slip radio for LAUNCHXL-CC1310. - 1.6 Download slip-radio.bin to one LAUNCHXL-CC1310 to act as slip radio for Raspberry Pi later.
2. Build Contiki-NG cc26x0-web-demo for LAUNCHXL-CC1310 on InstantContiki 3.0 or Cygwin
- 2.1 Apply Fixing cc26xx 6lbr client example patch first.
- 2.2 Switch to directory contiki-ng/examples/platform-specific/cc26xx/cc26x0-web-demo
- 2.3 Since 6lbr/Contiki-NG only supports RPL-CLASSIC now, we use "make
TARGET=srf06-cc26xx BOARD=launchpad/cc1310
MAKE_ROUTING=MAKE_ROUTING_RPL_CLASSIC
cc26xx-web-demo.bin" to build cc26xx-web-demo for LAUNCHXL-CC1310. - 2.4 Download cc26xx-web-demo.bin to another LAUNCHXL-CC1310 to join Raspberry Pi 6lbr later.
3. Build 6lbr/Contiki-NG on Rasperry Pi
- 3.1 SSH login to Raspberry Pi.
- 3.2 Change directory to home folder and git clone --recursive https://github.com/cetic/6lbr.git
- 3.3 Change directory to 6lbr folder and do "git submodule update --init"
git checkout contiki-ng - 3.4 Change directory to home folder and git clone --recursive https://github.com/cetic/contiki-ng.git
- 3.5 Change directory to contiki-ng folder and do "git submodule update --init"
git checkout sixlbr - 3.6 Change directory to 6lbr/examples/6lbr folder and run the following build command
"make WITH_CONTIKI=0 CONTIKI=~/contiki-ng WERROR=0 all" - 3.7 After build successfully, do "sudo make install". You will see "install: cannot stat ‘tools/nvm_tool’: No such file or directory" issue since nvm_tool doens't make properly for current version. It might be fixed later but you can use nvm_tool built by previous 6lbr to do the following steps.
- 3.8 Run "sudo /usr/lib/6lbr/bin/nvm_tool --update --channel 25 /etc/6lbr/nvm.dat" to change 6lbr/Contiki-NG to use channel 25.
- 3.9 Run "/usr/lib/6lbr/bin/nvm_tool --print /etc/6lbr/nvm.dat" to make sure it switches to channel 25.
- 3.10 Connect LAUNCHXL-CC1310 running slip radio to Raspberry Pi.
- 3.11 Run "sudo service 6lbr start" to start 6lbr/Contiki-NG and you can use Firefox to access to [bbbb::100]
4. Power on LAUNCHXL-CC1310 running cc26xx-web-demo and you will see it pops on sensors tab of 6lbr web page. You can test http or coap function on cc26xx-web-demo now.
Wednesday, January 3, 2018
How to create a new task in TI RTOS to use ICall service like osal_snv_write and osal_snv_read.
The following steps show you how to create a new task in TI RTOS to use ICall service like osal_snv_write and osal_snv_read. I will use ProjectZero in TI BLE Stack 2.2.1 as an example running on LAUNCHXL-CC2650 to do it.
1. Increase OSAL_MAX_NUM_PROXY_TASKS in BLE Stack project osal.c and rebuild Stack project to download it to your LAUNCHXL-CC2650.
2. Increase ICALL_MAX_NUM_TASKS and ICALL_MAX_NUM_ENTITIES in ProjectZero application Predefined Symbols.
3. Add the following Test_createTask function in ProjectZero.c and claim function prototype "extern void Test_createTask(void);" in ProjectZero.h
// Task configuration
#define TEST_TASK_STACK_SIZE 800
Task_Struct testTask;
Char testTaskStack[TEST_TASK_STACK_SIZE ];
void Test_createTask(void)
{
Task_Params taskParams;
// Configure task
Task_Params_init(&taskParams);
taskParams.stack = testTaskStack;
taskParams.stackSize = TEST_TASK_STACK_SIZE ;
taskParams.priority = 2;
Task_construct(&testTask, TestFunction, &taskParams, NULL);
}
4. Add the following TestFunction function in ProjectZero.c
// Entity ID globally used to check for source and/or destination of messages
static ICall_EntityID testEntity;
// Semaphore globally used to post events to the application thread
static ICall_Semaphore testsem;
uint8 status_snv;
uint8 write_buffer[10];
uint8 read_buffer[10];
static void TestFunction(UArg a0, UArg a1)
{
ICall_registerApp(&testEntity, &testsem);
while(1)
{
write_buffer[0] = 0x12;
write_buffer[1] = 0x12;
write_buffer[2] = 0x12;
write_buffer[3] = 0x12;
status_snv = osal_snv_write(0x80,10, (uint8_t *)write_buffer );
//Do ADC Polling and Data processing
read_buffer[0] = 0x0;
read_buffer[1] = 0x0;
read_buffer[2] = 0x0;
read_buffer[3] = 0x0;
status_snv = osal_snv_read(0x80,10, (uint8_t *)read_buffer );
}
5. Call "Test_createTask();" right after "ProjectZero_createTask();" to create TestFunction task to use ICall service for osal_snv_write/osal_snv_read.
1. Increase OSAL_MAX_NUM_PROXY_TASKS in BLE Stack project osal.c and rebuild Stack project to download it to your LAUNCHXL-CC2650.
2. Increase ICALL_MAX_NUM_TASKS and ICALL_MAX_NUM_ENTITIES in ProjectZero application Predefined Symbols.
3. Add the following Test_createTask function in ProjectZero.c and claim function prototype "extern void Test_createTask(void);" in ProjectZero.h
// Task configuration
#define TEST_TASK_STACK_SIZE 800
Task_Struct testTask;
Char testTaskStack[TEST_TASK_STACK_SIZE ];
void Test_createTask(void)
{
Task_Params taskParams;
// Configure task
Task_Params_init(&taskParams);
taskParams.stack = testTaskStack;
taskParams.stackSize = TEST_TASK_STACK_SIZE ;
taskParams.priority = 2;
Task_construct(&testTask, TestFunction, &taskParams, NULL);
}
4. Add the following TestFunction function in ProjectZero.c
// Entity ID globally used to check for source and/or destination of messages
static ICall_EntityID testEntity;
// Semaphore globally used to post events to the application thread
static ICall_Semaphore testsem;
uint8 status_snv;
uint8 write_buffer[10];
uint8 read_buffer[10];
static void TestFunction(UArg a0, UArg a1)
{
ICall_registerApp(&testEntity, &testsem);
while(1)
{
write_buffer[0] = 0x12;
write_buffer[1] = 0x12;
write_buffer[2] = 0x12;
write_buffer[3] = 0x12;
status_snv = osal_snv_write(0x80,10, (uint8_t *)write_buffer );
//Do ADC Polling and Data processing
read_buffer[0] = 0x0;
read_buffer[1] = 0x0;
read_buffer[2] = 0x0;
read_buffer[3] = 0x0;
status_snv = osal_snv_read(0x80,10, (uint8_t *)read_buffer );
}
5. Call "Test_createTask();" right after "ProjectZero_createTask();" to create TestFunction task to use ICall service for osal_snv_write/osal_snv_read.
Wednesday, November 29, 2017
Using Contiki UDP client to send ON/OFF command to remote UDP server to toggle LED on CC13xx/CC26xx.
The following steps show you how to revise Contiki UDP client/server examples to allow you send UART ON/OFF command to UDP client, UDP client sends ON/OFF command over the air to UDP server, and UDP server toggles red LED. The following tests are done using two LAUNCHXL-CC1310.
1. Revise the following red lines in udp-client.c
...
#include "net/ip/uip-udp-packet.h"
#include "sys/ctimer.h"
#include "dev/leds.h"
#ifdef WITH_COMPOWER
#include "powertrace.h"
#endif
#include
#include
...
static struct uip_udp_conn *client_conn;
static uip_ipaddr_t server_ipaddr;
char cmd[16];
/*---------------------------------------------------------------------------*/
PROCESS(udp_client_process, "UDP client process");
AUTOSTART_PROCESSES(&udp_client_process);
/*---------------------------------------------------------------------------*/
static int seq_id;
static int reply;
...
/*---------------------------------------------------------------------------*/
static void
send_packet(void *ptr)
{
char buf[MAX_PAYLOAD_LEN];
#ifdef SERVER_REPLY
uint8_t num_used = 0;
uip_ds6_nbr_t *nbr;
nbr = nbr_table_head(ds6_neighbors);
while(nbr != NULL) {
nbr = nbr_table_next(ds6_neighbors, nbr);
num_used++;
}
if(seq_id > 0) {
ANNOTATE("#A r=%d/%d,color=%s,n=%d %d\n", reply, seq_id,
reply == seq_id ? "GREEN" : "RED", uip_ds6_route_num_routes(), num_used);
}
#endif /* SERVER_REPLY */
seq_id++;
PRINTF("CMD:%s send to %d SEQ_ID:%d\n",cmd,
server_ipaddr.u8[sizeof(server_ipaddr.u8) - 1], seq_id);
sprintf(buf, "%s from the client SEQ_ID:%d ",cmd, seq_id); uip_udp_packet_sendto(client_conn, buf, strlen(buf),
&server_ipaddr, UIP_HTONS(UDP_SERVER_PORT));
}
/*---------------------------------------------------------------------------*/
...
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(udp_client_process, ev, data)
{
static struct etimer periodic;
static struct ctimer backoff_timer;
#if WITH_COMPOWER
static int print = 0;
#endif
PROCESS_BEGIN();
PROCESS_PAUSE();
cc26xx_uart_set_input(serial_line_input_byte);
set_global_address();
PRINTF("UDP client process started nbr:%d routes:%d\n",
NBR_TABLE_CONF_MAX_NEIGHBORS, UIP_CONF_MAX_ROUTES);
print_local_addresses();
/* new connection with remote host */
client_conn = udp_new(NULL, UIP_HTONS(UDP_SERVER_PORT), NULL);
if(client_conn == NULL) {
PRINTF("No UDP connection available, exiting the process!\n");
PROCESS_EXIT();
}
udp_bind(client_conn, UIP_HTONS(UDP_CLIENT_PORT));
PRINTF("Created a connection with the server ");
PRINT6ADDR(&client_conn->ripaddr);
PRINTF(" local/remote port %u/%u\n",
UIP_HTONS(client_conn->lport), UIP_HTONS(client_conn->rport));
#if WITH_COMPOWER
powertrace_sniff(POWERTRACE_ON);
#endif
etimer_set(&periodic, SEND_INTERVAL);
while(1) {
PROCESS_YIELD();
if(ev == tcpip_event) {
tcpip_handler();
}
if(ev == serial_line_event_message && data != NULL) {
printf("command received:%s\n",(char *)data);
if(strcmp(data,"ON")==0){
for(int i=0; i < 16 ; i=i+1) cmd[i]=0x0;
cmd[0]=0x4F;
cmd[1]=0x4E;
leds_on(LEDS_RED);
}else if(strcmp(data,"OFF")==0){
for(int i=0; i < 16 ; i=i+1) cmd[i]=0x0;
cmd[0]=0x4F;
cmd[1]=0x46;
cmd[2]=0x46;
leds_off(LEDS_RED);
}
send_packet(NULL);
}
if(etimer_expired(&periodic)) {
etimer_reset(&periodic);
ctimer_set(&backoff_timer, SEND_TIME, send_packet, NULL);
#if WITH_COMPOWER
if (print == 0) {
powertrace_print("#P");
}
if (++print == 3) {
print = 0;
}
#endif
}
}
PROCESS_END();
}
/*---------------------------------------------------------------------------*/
2. Build udp-client.bin by "make TARGET=srf06-cc26xx BOARD=launchpad/cc1310 udp-client.bin" and download udp-client.bin to one LAUNCHXL-CC1310.
3. Revise the following red lines in udp-server.c
...
#define DEBUG DEBUG_PRINT
#include "net/ip/uip-debug.h"
#include "dev/leds.h"
#define UIP_IP_BUF ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN])
...
/*---------------------------------------------------------------------------*/
static void
tcpip_handler(void)
{
char *appdata;
if(uip_newdata()) {
appdata = (char *)uip_appdata;
appdata[uip_datalen()] = 0;
PRINTF("DATA recv '%s' from ", appdata);
if(appdata[0]==0x4F && appdata[1]==0x4E ){
leds_on(LEDS_RED);
}
if(appdata[0]==0x4F && appdata[1]==0x46 && appdata[2]==0x46){
leds_off(LEDS_RED);
}
PRINTF("%d",
UIP_IP_BUF->srcipaddr.u8[sizeof(UIP_IP_BUF->srcipaddr.u8) - 1]);
PRINTF("\n");
#if SERVER_REPLY
PRINTF("DATA sending reply\n");
uip_ipaddr_copy(&server_conn->ripaddr, &UIP_IP_BUF->srcipaddr);
uip_udp_packet_send(server_conn, "Reply", sizeof("Reply"));
uip_create_unspecified(&server_conn->ripaddr);
#endif
}
}
/*---------------------------------------------------------------------------*/
...
4. Build udp-server.bin by "make TARGET=srf06-cc26xx BOARD=launchpad/cc1310 udp-server.bin" and download udp-server.bin to another LAUNCHXL-CC1310.
5. Start UDP server on one LAUNCHXL-CC1310 running udp-server.bin and start UDP client on another LAUNCHXL-CC1310 running udp-client.bin.
1. Revise the following red lines in udp-client.c
...
#include "net/ip/uip-udp-packet.h"
#include "sys/ctimer.h"
#include "dev/leds.h"
#ifdef WITH_COMPOWER
#include "powertrace.h"
#endif
#include
#include
...
static struct uip_udp_conn *client_conn;
static uip_ipaddr_t server_ipaddr;
char cmd[16];
/*---------------------------------------------------------------------------*/
PROCESS(udp_client_process, "UDP client process");
AUTOSTART_PROCESSES(&udp_client_process);
/*---------------------------------------------------------------------------*/
static int seq_id;
static int reply;
...
/*---------------------------------------------------------------------------*/
static void
send_packet(void *ptr)
{
char buf[MAX_PAYLOAD_LEN];
#ifdef SERVER_REPLY
uint8_t num_used = 0;
uip_ds6_nbr_t *nbr;
nbr = nbr_table_head(ds6_neighbors);
while(nbr != NULL) {
nbr = nbr_table_next(ds6_neighbors, nbr);
num_used++;
}
if(seq_id > 0) {
ANNOTATE("#A r=%d/%d,color=%s,n=%d %d\n", reply, seq_id,
reply == seq_id ? "GREEN" : "RED", uip_ds6_route_num_routes(), num_used);
}
#endif /* SERVER_REPLY */
seq_id++;
PRINTF("CMD:%s send to %d SEQ_ID:%d\n",cmd,
server_ipaddr.u8[sizeof(server_ipaddr.u8) - 1], seq_id);
sprintf(buf, "%s from the client SEQ_ID:%d ",cmd, seq_id); uip_udp_packet_sendto(client_conn, buf, strlen(buf),
&server_ipaddr, UIP_HTONS(UDP_SERVER_PORT));
}
/*---------------------------------------------------------------------------*/
...
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(udp_client_process, ev, data)
{
static struct etimer periodic;
static struct ctimer backoff_timer;
#if WITH_COMPOWER
static int print = 0;
#endif
PROCESS_BEGIN();
PROCESS_PAUSE();
cc26xx_uart_set_input(serial_line_input_byte);
set_global_address();
PRINTF("UDP client process started nbr:%d routes:%d\n",
NBR_TABLE_CONF_MAX_NEIGHBORS, UIP_CONF_MAX_ROUTES);
print_local_addresses();
/* new connection with remote host */
client_conn = udp_new(NULL, UIP_HTONS(UDP_SERVER_PORT), NULL);
if(client_conn == NULL) {
PRINTF("No UDP connection available, exiting the process!\n");
PROCESS_EXIT();
}
udp_bind(client_conn, UIP_HTONS(UDP_CLIENT_PORT));
PRINTF("Created a connection with the server ");
PRINT6ADDR(&client_conn->ripaddr);
PRINTF(" local/remote port %u/%u\n",
UIP_HTONS(client_conn->lport), UIP_HTONS(client_conn->rport));
#if WITH_COMPOWER
powertrace_sniff(POWERTRACE_ON);
#endif
etimer_set(&periodic, SEND_INTERVAL);
while(1) {
PROCESS_YIELD();
if(ev == tcpip_event) {
tcpip_handler();
}
if(ev == serial_line_event_message && data != NULL) {
printf("command received:%s\n",(char *)data);
if(strcmp(data,"ON")==0){
for(int i=0; i < 16 ; i=i+1) cmd[i]=0x0;
cmd[0]=0x4F;
cmd[1]=0x4E;
leds_on(LEDS_RED);
}else if(strcmp(data,"OFF")==0){
for(int i=0; i < 16 ; i=i+1) cmd[i]=0x0;
cmd[0]=0x4F;
cmd[1]=0x46;
cmd[2]=0x46;
leds_off(LEDS_RED);
}
send_packet(NULL);
}
if(etimer_expired(&periodic)) {
etimer_reset(&periodic);
ctimer_set(&backoff_timer, SEND_TIME, send_packet, NULL);
#if WITH_COMPOWER
if (print == 0) {
powertrace_print("#P");
}
if (++print == 3) {
print = 0;
}
#endif
}
}
PROCESS_END();
}
/*---------------------------------------------------------------------------*/
2. Build udp-client.bin by "make TARGET=srf06-cc26xx BOARD=launchpad/cc1310 udp-client.bin" and download udp-client.bin to one LAUNCHXL-CC1310.
3. Revise the following red lines in udp-server.c
...
#define DEBUG DEBUG_PRINT
#include "net/ip/uip-debug.h"
#include "dev/leds.h"
#define UIP_IP_BUF ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN])
...
/*---------------------------------------------------------------------------*/
static void
tcpip_handler(void)
{
char *appdata;
if(uip_newdata()) {
appdata = (char *)uip_appdata;
appdata[uip_datalen()] = 0;
PRINTF("DATA recv '%s' from ", appdata);
if(appdata[0]==0x4F && appdata[1]==0x4E ){
leds_on(LEDS_RED);
}
if(appdata[0]==0x4F && appdata[1]==0x46 && appdata[2]==0x46){
leds_off(LEDS_RED);
}
PRINTF("%d",
UIP_IP_BUF->srcipaddr.u8[sizeof(UIP_IP_BUF->srcipaddr.u8) - 1]);
PRINTF("\n");
#if SERVER_REPLY
PRINTF("DATA sending reply\n");
uip_ipaddr_copy(&server_conn->ripaddr, &UIP_IP_BUF->srcipaddr);
uip_udp_packet_send(server_conn, "Reply", sizeof("Reply"));
uip_create_unspecified(&server_conn->ripaddr);
#endif
}
}
/*---------------------------------------------------------------------------*/
...
4. Build udp-server.bin by "make TARGET=srf06-cc26xx BOARD=launchpad/cc1310 udp-server.bin" and download udp-server.bin to another LAUNCHXL-CC1310.
5. Start UDP server on one LAUNCHXL-CC1310 running udp-server.bin and start UDP client on another LAUNCHXL-CC1310 running udp-client.bin.
6. You can enter "ON" and "CTRL+Enter" to send ON command with end character "0x0A"
to COM port of LAUNCHXL-CC1310 running UDP client and you will see red led is turned ON on another LAUNCHXL-CC1310 running UDP server.
7. You can enter "OFF" and "CTRL+Enter" to send OFF command with end character "0x0A"
to COM port of LAUNCHXL-CC1310 running UDP client and you will see red led is turned OFF on another LAUNCHXL-CC1310 running UDP server.
Friday, March 3, 2017
How to run Contiki udp-server/udp-client on LAUNCHXL-CC2650.
The following steps show you how to run Contiki udp-server/udp-client on LAUNCHXL-CC2650.
1. Do "make TARGET=srf06-cc26xx BOARD=launchpad/cc2650 udp-server.bin" under /contiki/examples/ipv6/rpl-udp to build udp-server.bin and download it to one of LAUNCHXL-CC2650 using Flash Programmer 2.
2. Do "make TARGET=srf06-cc26xx BOARD=launchpad/cc2650 udp-client.bin" under /contiki/examples/ipv6/rpl-udp to build udp-client.bin and download it to another LAUNCHXL-CC2650 using Flash Programmer 2.
3. Start 6lbr on Raspberry Pi or BeagleBone and power on udp-server and udp-client on two different LAUNCHXL-CC2650. You will see two LAUNCHXL-CC2650 show on sensor list of 6lbr web page.
4. On UART output of two LAUNCHXL-CC2650, you can see udp-client sends Hello messages to udp-server.
1. Do "make TARGET=srf06-cc26xx BOARD=launchpad/cc2650 udp-server.bin" under /contiki/examples/ipv6/rpl-udp to build udp-server.bin and download it to one of LAUNCHXL-CC2650 using Flash Programmer 2.
2. Do "make TARGET=srf06-cc26xx BOARD=launchpad/cc2650 udp-client.bin" under /contiki/examples/ipv6/rpl-udp to build udp-client.bin and download it to another LAUNCHXL-CC2650 using Flash Programmer 2.
3. Start 6lbr on Raspberry Pi or BeagleBone and power on udp-server and udp-client on two different LAUNCHXL-CC2650. You will see two LAUNCHXL-CC2650 show on sensor list of 6lbr web page.
4. On UART output of two LAUNCHXL-CC2650, you can see udp-client sends Hello messages to udp-server.
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.
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.
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.
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.
Wednesday, July 20, 2016
How to use CC2650DK, CC2650 LaunchPad, or CC2650STK as Contiki 6LowPAN Sniffer.
The following steps show you how to use CC2650DK, CC2650 LaunchPad, or CC2650STK as Contiki 6LowPAN Sniffer.
1. git clone --recursive https://github.com/contiki-os/contiki
2. Change directory to /contiki/examples/sensniff
3. Use the following three make command to build sensniff.bin for CC2650DK, CC2650 LaunchPad, or CC2650ST.
a. make TARGET=srf06-cc26xx BOARD=srf06/cc26xx sensniff.bin -->CC2650DK
b. make TARGET=srf06-cc26xx BOARD=launchpad/cc2650 sensniff.bin --> CC2650LP
c. make TARGET=srf06-cc26xx BOARD=sensortag/cc2650 sensniff.bin --> CC2650STK
4. Use Flash Programmer 2 to download sensniff.bin to CC2650DK, CC2650 LaunchPad, or CC2650ST.
5. Download latest sensniff.py from https://github.com/g-oikonomou/sensniff and refer to here for running Wireshark to sniff packets.
1. git clone --recursive https://github.com/contiki-os/contiki
2. Change directory to /contiki/examples/sensniff
3. Use the following three make command to build sensniff.bin for CC2650DK, CC2650 LaunchPad, or CC2650ST.
a. make TARGET=srf06-cc26xx BOARD=srf06/cc26xx sensniff.bin -->CC2650DK
b. make TARGET=srf06-cc26xx BOARD=launchpad/cc2650 sensniff.bin --> CC2650LP
c. make TARGET=srf06-cc26xx BOARD=sensortag/cc2650 sensniff.bin --> CC2650STK
4. Use Flash Programmer 2 to download sensniff.bin to CC2650DK, CC2650 LaunchPad, or CC2650ST.
5. Download latest sensniff.py from https://github.com/g-oikonomou/sensniff and refer to here for running Wireshark to sniff packets.
How to use CC2650DK, CC2650 LaunchPad, or CC2650STK as Contiki 6LowPAN Sniffer.
The following steps show you how to use CC2650DK, CC2650 LaunchPad, or CC2650STK as Contiki 6LowPAN Sniffer.
1. git clone --recursive https://github.com/contiki-os/contiki
2. Change directory to /contiki/examples/sensniff
3. Use the following three make command to build sensniff.bin for CC2650DK, CC2650 LaunchPad, or CC2650ST.
a. make TARGET=srf06-cc26xx BOARD=srf06/cc26xx sniffer.bin -->CC2650DK
b. make TARGET=srf06-cc26xx BOARD=launchpad/cc2650 sniffer.bin --> CC2650LP
c. make TARGET=srf06-cc26xx BOARD=sensortag/cc2650 sensniff.bin --> CC2650STK
4. Use Flash Programmer 2 to download sensniff.bin to CC2650DK, CC2650 LaunchPad, or CC2650ST.
5. Download latest sensniff.py from https://github.com/g-oikonomou/sensniff and refer to here for running Wireshark to sniff packets.
1. git clone --recursive https://github.com/contiki-os/contiki
2. Change directory to /contiki/examples/sensniff
3. Use the following three make command to build sensniff.bin for CC2650DK, CC2650 LaunchPad, or CC2650ST.
a. make TARGET=srf06-cc26xx BOARD=srf06/cc26xx sniffer.bin -->CC2650DK
b. make TARGET=srf06-cc26xx BOARD=launchpad/cc2650 sniffer.bin --> CC2650LP
c. make TARGET=srf06-cc26xx BOARD=sensortag/cc2650 sensniff.bin --> CC2650STK
4. Use Flash Programmer 2 to download sensniff.bin to CC2650DK, CC2650 LaunchPad, or CC2650ST.
5. Download latest sensniff.py from https://github.com/g-oikonomou/sensniff and refer to here for running Wireshark to sniff packets.
Wednesday, June 29, 2016
How to debug two CC1310 or CC2650 LaunchPads at the same PC with two CCS instance.
The following steps show you how to debug two CC1310 or CC2650 LaunchPads at the
same PC with two CCS instance.
1. Connect CC1310/CC2650 LaunchPad to PC and start Flash Programmer 2 to get serial number of XDS110 embedded on LaunchPa. In my example, it's L2003001.
2. Start first CCS instance and open a CC1310/CC2650 example. In this case, I use CC1310 Collector node in TI-15.4-stack. Click CC1310F128.ccxml under targetConfigs folder in Project Explore and click "Target Configuration:" to proceed next step.
3. Choose "Select by serial number" in combobox "Debug Probe Selection".
4. Key in serial number "L2003001" which specifies the LaunchPad you intend to download and debug in this project and save.
5. Open another CCS and do the same steps to another example. In my case, I use CC1310 Sensor node in TI-15.4-stack.
6. You can download and debug Collector and Sensor node on the same PC with two CCS instances.
same PC with two CCS instance.
1. Connect CC1310/CC2650 LaunchPad to PC and start Flash Programmer 2 to get serial number of XDS110 embedded on LaunchPa. In my example, it's L2003001.
2. Start first CCS instance and open a CC1310/CC2650 example. In this case, I use CC1310 Collector node in TI-15.4-stack. Click CC1310F128.ccxml under targetConfigs folder in Project Explore and click "Target Configuration:" to proceed next step.
3. Choose "Select by serial number" in combobox "Debug Probe Selection".
4. Key in serial number "L2003001" which specifies the LaunchPad you intend to download and debug in this project and save.
5. Open another CCS and do the same steps to another example. In my case, I use CC1310 Sensor node in TI-15.4-stack.
6. You can download and debug Collector and Sensor node on the same PC with two CCS instances.
Wednesday, March 2, 2016
Basic example to use OPT3001 on CC2650 LaunchPad
1. Connect OPT3001EVM SCL to CC2650 IOID_6 and SDA to IOID_5.
2. Replace the following code to taskFxn in i2ctmp006.c (in CC26xx I2C TMP006 example) will make CC2650 LaunchPad to read OPT3001EVM Lux data.
Void taskFxn(UArg arg0, UArg arg1)
{
unsigned int i;
uint16_t lux;
uint8_t txBuffer[4];
uint8_t rxBuffer[4];
I2C_Handle i2c;
I2C_Params i2cParams;
I2C_Transaction i2cTransaction;
/* Create I2C for usage */
I2C_Params_init(&i2cParams);
i2cParams.bitRate = I2C_400kHz;
i2c = I2C_open(Board_I2C_TMP, &i2cParams);
if (i2c == NULL) {
System_abort("Error Initializing I2C\n");
}
else {
System_printf("I2C Initialized!\n");
}
Task_sleep(1000000 / Clock_tickPeriod);
//Read OPT3001 device ID
txBuffer[0] = 0x7F;
txBuffer[1] = 0x10;
txBuffer[2] = 0x00;
i2cTransaction.slaveAddress = 0x44;//OPT3001 ADDR;
i2cTransaction.writeBuf = txBuffer;
i2cTransaction.writeCount = 1;
i2cTransaction.readBuf = rxBuffer;
i2cTransaction.readCount = 2;
if (I2C_transfer(i2c, &i2cTransaction)){
System_printf("Device ID: %x%x\n", rxBuffer[0], rxBuffer[1]);
} else {
System_printf("Device ID fail!\n");
}
if (I2C_transfer(i2c, &i2cTransaction)){
System_printf("Device ID: %x%x\n", rxBuffer[0], rxBuffer[1]);
} else {
System_printf("Device ID fail!\n");
}
//Read OPT3001 ADDR Manufacture ID
txBuffer[0] = 0x7E;
i2cTransaction.slaveAddress = 0x44;//OPT3001 ADDR;
i2cTransaction.writeBuf = txBuffer;
i2cTransaction.writeCount = 1;
i2cTransaction.readBuf = rxBuffer;
i2cTransaction.readCount = 2;
if (I2C_transfer(i2c, &i2cTransaction)) {
System_printf("Manufacture ID: %x%x\n", rxBuffer[0], rxBuffer[1]);
} else {
System_printf("Manufacture ID fail!\n");
}
/* Take 20 samples and print them out onto the console */
for (i = 0; i < 20; i++) {
//Config OPT3001
txBuffer[0] = 0x01;
txBuffer[1] = 0xC4;
txBuffer[2] = 0x10;
i2cTransaction.slaveAddress = 0x44;//OPT3001 ADDR;
i2cTransaction.writeBuf = txBuffer;
i2cTransaction.writeCount = 3;
i2cTransaction.readBuf = rxBuffer;
i2cTransaction.readCount = 0;
if (I2C_transfer(i2c, &i2cTransaction)){
System_printf("Config write!\n");
//System_printf("Conf: 0x%x 0x%x (C)\n", rxBuffer[0], rxBuffer[1]);
} else {
System_printf("Config write fail!\n");
}
//Read OPT3001 Config
txBuffer[0] = 0x01;
i2cTransaction.slaveAddress = 0x44;//OPT3001 ADDR;
i2cTransaction.writeBuf = txBuffer;
i2cTransaction.writeCount = 1;
i2cTransaction.readBuf = rxBuffer;
i2cTransaction.readCount = 2;
if (I2C_transfer(i2c, &i2cTransaction)){
System_printf("Config read!\n");
System_printf("Conf %u: 0x%x 0x%x\n", i, rxBuffer[0], rxBuffer[1]);
} else {
System_printf("Config read fail!\n");
}
//Task_sleep(1000000 / Clock_tickPeriod);
txBuffer[0] = 0x00;
i2cTransaction.slaveAddress = 0x44;//OPT3001 ADDR;
i2cTransaction.writeBuf = txBuffer;
i2cTransaction.writeCount = 1;
i2cTransaction.readBuf = rxBuffer;
i2cTransaction.readCount = 2;
if (I2C_transfer(i2c, &i2cTransaction)) {
uint16_t e, m;
float val;
/* Extract degrees C from the received data */
lux = rxBuffer[0];
lux = (lux<<8 8="" br=""> | rxBuffer[1];
m = lux & 0x0FFF;
e = (lux & 0xF000) >> 12;
val= (float)m * (0.01 * exp2(e));
//System_printf("Lux %u: 0x%x 0x%x \n", i, rxBuffer[0], rxBuffer[1]);
System_printf("Lux %u: %d \n", i, (int)val);
}
else {
System_printf("I2C Bus fault\n");
}
System_flush();
Task_sleep(1000000 / Clock_tickPeriod);
}
/* Deinitialized I2C */
I2C_close(i2c);
System_printf("I2C closed!\n");
System_flush();
} 8>
2. Replace the following code to taskFxn in i2ctmp006.c (in CC26xx I2C TMP006 example) will make CC2650 LaunchPad to read OPT3001EVM Lux data.
Void taskFxn(UArg arg0, UArg arg1)
{
unsigned int i;
uint16_t lux;
uint8_t txBuffer[4];
uint8_t rxBuffer[4];
I2C_Handle i2c;
I2C_Params i2cParams;
I2C_Transaction i2cTransaction;
/* Create I2C for usage */
I2C_Params_init(&i2cParams);
i2cParams.bitRate = I2C_400kHz;
i2c = I2C_open(Board_I2C_TMP, &i2cParams);
if (i2c == NULL) {
System_abort("Error Initializing I2C\n");
}
else {
System_printf("I2C Initialized!\n");
}
Task_sleep(1000000 / Clock_tickPeriod);
//Read OPT3001 device ID
txBuffer[0] = 0x7F;
txBuffer[1] = 0x10;
txBuffer[2] = 0x00;
i2cTransaction.slaveAddress = 0x44;//OPT3001 ADDR;
i2cTransaction.writeBuf = txBuffer;
i2cTransaction.writeCount = 1;
i2cTransaction.readBuf = rxBuffer;
i2cTransaction.readCount = 2;
if (I2C_transfer(i2c, &i2cTransaction)){
System_printf("Device ID: %x%x\n", rxBuffer[0], rxBuffer[1]);
} else {
System_printf("Device ID fail!\n");
}
if (I2C_transfer(i2c, &i2cTransaction)){
System_printf("Device ID: %x%x\n", rxBuffer[0], rxBuffer[1]);
} else {
System_printf("Device ID fail!\n");
}
//Read OPT3001 ADDR Manufacture ID
txBuffer[0] = 0x7E;
i2cTransaction.slaveAddress = 0x44;//OPT3001 ADDR;
i2cTransaction.writeBuf = txBuffer;
i2cTransaction.writeCount = 1;
i2cTransaction.readBuf = rxBuffer;
i2cTransaction.readCount = 2;
if (I2C_transfer(i2c, &i2cTransaction)) {
System_printf("Manufacture ID: %x%x\n", rxBuffer[0], rxBuffer[1]);
} else {
System_printf("Manufacture ID fail!\n");
}
/* Take 20 samples and print them out onto the console */
for (i = 0; i < 20; i++) {
//Config OPT3001
txBuffer[0] = 0x01;
txBuffer[1] = 0xC4;
txBuffer[2] = 0x10;
i2cTransaction.slaveAddress = 0x44;//OPT3001 ADDR;
i2cTransaction.writeBuf = txBuffer;
i2cTransaction.writeCount = 3;
i2cTransaction.readBuf = rxBuffer;
i2cTransaction.readCount = 0;
if (I2C_transfer(i2c, &i2cTransaction)){
System_printf("Config write!\n");
//System_printf("Conf: 0x%x 0x%x (C)\n", rxBuffer[0], rxBuffer[1]);
} else {
System_printf("Config write fail!\n");
}
//Read OPT3001 Config
txBuffer[0] = 0x01;
i2cTransaction.slaveAddress = 0x44;//OPT3001 ADDR;
i2cTransaction.writeBuf = txBuffer;
i2cTransaction.writeCount = 1;
i2cTransaction.readBuf = rxBuffer;
i2cTransaction.readCount = 2;
if (I2C_transfer(i2c, &i2cTransaction)){
System_printf("Config read!\n");
System_printf("Conf %u: 0x%x 0x%x\n", i, rxBuffer[0], rxBuffer[1]);
} else {
System_printf("Config read fail!\n");
}
//Task_sleep(1000000 / Clock_tickPeriod);
txBuffer[0] = 0x00;
i2cTransaction.slaveAddress = 0x44;//OPT3001 ADDR;
i2cTransaction.writeBuf = txBuffer;
i2cTransaction.writeCount = 1;
i2cTransaction.readBuf = rxBuffer;
i2cTransaction.readCount = 2;
if (I2C_transfer(i2c, &i2cTransaction)) {
uint16_t e, m;
float val;
/* Extract degrees C from the received data */
lux = rxBuffer[0];
lux = (lux<<8 8="" br=""> | rxBuffer[1];
m = lux & 0x0FFF;
e = (lux & 0xF000) >> 12;
val= (float)m * (0.01 * exp2(e));
//System_printf("Lux %u: 0x%x 0x%x \n", i, rxBuffer[0], rxBuffer[1]);
System_printf("Lux %u: %d \n", i, (int)val);
}
else {
System_printf("I2C Bus fault\n");
}
System_flush();
Task_sleep(1000000 / Clock_tickPeriod);
}
/* Deinitialized I2C */
I2C_close(i2c);
System_printf("I2C closed!\n");
System_flush();
} 8>
Friday, February 26, 2016
Basic example to use HDC1080 on CC2650 LaunchPad
1. Connect HDC1080 SCL to CC2650 IOID_6 and SDA to IOID_5.
2. Replace the following code to taskFxn in i2ctmp006.c (in CC26xx I2C TMP006 example) will make CC2650 LaunchPad to read HDC1080 temperature/humidity data.
Void taskFxn(UArg arg0, UArg arg1)
{
unsigned int i;
uint16_t temperature;
uint16_t humidity;
uint8_t txBuffer[4];
uint8_t rxBuffer[4];
I2C_Handle i2c;
I2C_Params i2cParams;
I2C_Transaction i2cTransaction;
/* Create I2C for usage */
I2C_Params_init(&i2cParams);
i2cParams.bitRate = I2C_400kHz;
i2c = I2C_open(Board_I2C_TMP, &i2cParams);
if (i2c == NULL) {
System_abort("Error Initializing I2C\n");
}
else {
System_printf("I2C Initialized!\n");
}
//Read HDC1080 device ID
txBuffer[0] = 0xFF;
txBuffer[1] = 0x10;
txBuffer[2] = 0x00;
i2cTransaction.slaveAddress = 0x40;//HDC1080 ADDR;
i2cTransaction.writeBuf = txBuffer;
i2cTransaction.writeCount = 1;
i2cTransaction.readBuf = rxBuffer;
i2cTransaction.readCount = 2;
if (I2C_transfer(i2c, &i2cTransaction)){
System_printf("Device ID: %x%x\n", rxBuffer[0], rxBuffer[1]);
} else {
System_printf("Device ID fail!\n");
}
if (I2C_transfer(i2c, &i2cTransaction)){
System_printf("Device ID: %x%x\n", rxBuffer[0], rxBuffer[1]);
} else {
System_printf("Device ID fail!\n");
}
//Read HDC1080 ADDR Manufacture ID
txBuffer[0] = 0xFE;
i2cTransaction.slaveAddress = 0x40;//HDC1080 ADDR;
i2cTransaction.writeBuf = txBuffer;
i2cTransaction.writeCount = 1;
i2cTransaction.readBuf = rxBuffer;
i2cTransaction.readCount = 2;
if (I2C_transfer(i2c, &i2cTransaction)) {
System_printf("Manufacture ID: %x%x\n", rxBuffer[0], rxBuffer[1]);
} else {
System_printf("Manufacture ID fail!\n");
}
//Config HDC1080
txBuffer[0] = 0x02;
txBuffer[1] = 0x10;
txBuffer[2] = 0x00;
i2cTransaction.slaveAddress = 0x40;//Board_TMP006_ADDR;
i2cTransaction.writeBuf = txBuffer;
i2cTransaction.writeCount = 3;
i2cTransaction.readBuf = rxBuffer;
i2cTransaction.readCount = 0;
if (I2C_transfer(i2c, &i2cTransaction)){
System_printf("Config write!\n");
//System_printf("Conf: 0x%x 0x%x\n", rxBuffer[0], rxBuffer[1]);
} else {
System_printf("Config fail!\n");
}
//Read HDC1080 Config
txBuffer[0] = 0x02;
txBuffer[1] = 0x10;
txBuffer[2] = 0x00;
i2cTransaction.slaveAddress = 0x40;//Board_TMP006_ADDR;
i2cTransaction.writeBuf = txBuffer;
i2cTransaction.writeCount = 1;
i2cTransaction.readBuf = rxBuffer;
i2cTransaction.readCount = 2;
if (I2C_transfer(i2c, &i2cTransaction)){
System_printf("Config read!\n");
System_printf("Conf: 0x%x 0x%x\n", rxBuffer[0], rxBuffer[1]);
} else {
System_printf("Config fail!\n");
}
/* Take 20 samples and print them out onto the console */
for (i = 0; i < 20; i++) {
txBuffer[0] = 0x00;
i2cTransaction.slaveAddress = 0x40;//HDC1080 ADDR;
i2cTransaction.writeBuf = txBuffer;
i2cTransaction.writeCount = 1;
i2cTransaction.readBuf = rxBuffer;
i2cTransaction.readCount = 0;
if (I2C_transfer(i2c, &i2cTransaction)) {
System_printf("Temp/Humd!\n");
} else {
System_printf("Temp/Humd Fail!\n");
}
Task_sleep(1000000 / Clock_tickPeriod);
txBuffer[0] = 0x00;
i2cTransaction.slaveAddress = 0x40;//HDC1080 ADDR;
i2cTransaction.writeBuf = txBuffer;
i2cTransaction.writeCount = 0;
i2cTransaction.readBuf = rxBuffer;
i2cTransaction.readCount = 4;
if (I2C_transfer(i2c, &i2cTransaction)) {
/* Extract degrees C from the received data */
temperature = rxBuffer[0];
temperature = (temperature<<8 br=""> temperature |= rxBuffer[1];
temperature = ((double)(int16_t)temperature / 65536)*165 - 40;
System_printf("Temperature %u: %d (C)\n", i, temperature);
/* Extract humidity RH from the received data */
humidity = rxBuffer[2];
humidity = (humidity<<8 br=""> humidity |= rxBuffer[3];
//-- calculate relative humidity [%RH]
humidity = ((double)humidity / 65536)*100;
System_printf("Humidity %u: %d (RH)\n", i, humidity);
}
else {
System_printf("I2C Bus fault\n");
}
System_flush();
Task_sleep(1000000 / Clock_tickPeriod);
}
/* Deinitialized I2C */
I2C_close(i2c);
System_printf("I2C closed!\n");
System_flush();
}
8>8>
2. Replace the following code to taskFxn in i2ctmp006.c (in CC26xx I2C TMP006 example) will make CC2650 LaunchPad to read HDC1080 temperature/humidity data.
Void taskFxn(UArg arg0, UArg arg1)
{
unsigned int i;
uint16_t temperature;
uint16_t humidity;
uint8_t txBuffer[4];
uint8_t rxBuffer[4];
I2C_Handle i2c;
I2C_Params i2cParams;
I2C_Transaction i2cTransaction;
/* Create I2C for usage */
I2C_Params_init(&i2cParams);
i2cParams.bitRate = I2C_400kHz;
i2c = I2C_open(Board_I2C_TMP, &i2cParams);
if (i2c == NULL) {
System_abort("Error Initializing I2C\n");
}
else {
System_printf("I2C Initialized!\n");
}
//Read HDC1080 device ID
txBuffer[0] = 0xFF;
txBuffer[1] = 0x10;
txBuffer[2] = 0x00;
i2cTransaction.slaveAddress = 0x40;//HDC1080 ADDR;
i2cTransaction.writeBuf = txBuffer;
i2cTransaction.writeCount = 1;
i2cTransaction.readBuf = rxBuffer;
i2cTransaction.readCount = 2;
if (I2C_transfer(i2c, &i2cTransaction)){
System_printf("Device ID: %x%x\n", rxBuffer[0], rxBuffer[1]);
} else {
System_printf("Device ID fail!\n");
}
if (I2C_transfer(i2c, &i2cTransaction)){
System_printf("Device ID: %x%x\n", rxBuffer[0], rxBuffer[1]);
} else {
System_printf("Device ID fail!\n");
}
//Read HDC1080 ADDR Manufacture ID
txBuffer[0] = 0xFE;
i2cTransaction.slaveAddress = 0x40;//HDC1080 ADDR;
i2cTransaction.writeBuf = txBuffer;
i2cTransaction.writeCount = 1;
i2cTransaction.readBuf = rxBuffer;
i2cTransaction.readCount = 2;
if (I2C_transfer(i2c, &i2cTransaction)) {
System_printf("Manufacture ID: %x%x\n", rxBuffer[0], rxBuffer[1]);
} else {
System_printf("Manufacture ID fail!\n");
}
//Config HDC1080
txBuffer[0] = 0x02;
txBuffer[1] = 0x10;
txBuffer[2] = 0x00;
i2cTransaction.slaveAddress = 0x40;//Board_TMP006_ADDR;
i2cTransaction.writeBuf = txBuffer;
i2cTransaction.writeCount = 3;
i2cTransaction.readBuf = rxBuffer;
i2cTransaction.readCount = 0;
if (I2C_transfer(i2c, &i2cTransaction)){
System_printf("Config write!\n");
//System_printf("Conf: 0x%x 0x%x\n", rxBuffer[0], rxBuffer[1]);
} else {
System_printf("Config fail!\n");
}
//Read HDC1080 Config
txBuffer[0] = 0x02;
txBuffer[1] = 0x10;
txBuffer[2] = 0x00;
i2cTransaction.slaveAddress = 0x40;//Board_TMP006_ADDR;
i2cTransaction.writeBuf = txBuffer;
i2cTransaction.writeCount = 1;
i2cTransaction.readBuf = rxBuffer;
i2cTransaction.readCount = 2;
if (I2C_transfer(i2c, &i2cTransaction)){
System_printf("Config read!\n");
System_printf("Conf: 0x%x 0x%x\n", rxBuffer[0], rxBuffer[1]);
} else {
System_printf("Config fail!\n");
}
/* Take 20 samples and print them out onto the console */
for (i = 0; i < 20; i++) {
txBuffer[0] = 0x00;
i2cTransaction.slaveAddress = 0x40;//HDC1080 ADDR;
i2cTransaction.writeBuf = txBuffer;
i2cTransaction.writeCount = 1;
i2cTransaction.readBuf = rxBuffer;
i2cTransaction.readCount = 0;
if (I2C_transfer(i2c, &i2cTransaction)) {
System_printf("Temp/Humd!\n");
} else {
System_printf("Temp/Humd Fail!\n");
}
Task_sleep(1000000 / Clock_tickPeriod);
txBuffer[0] = 0x00;
i2cTransaction.slaveAddress = 0x40;//HDC1080 ADDR;
i2cTransaction.writeBuf = txBuffer;
i2cTransaction.writeCount = 0;
i2cTransaction.readBuf = rxBuffer;
i2cTransaction.readCount = 4;
if (I2C_transfer(i2c, &i2cTransaction)) {
/* Extract degrees C from the received data */
temperature = rxBuffer[0];
temperature = (temperature<<8 br=""> temperature |= rxBuffer[1];
temperature = ((double)(int16_t)temperature / 65536)*165 - 40;
System_printf("Temperature %u: %d (C)\n", i, temperature);
/* Extract humidity RH from the received data */
humidity = rxBuffer[2];
humidity = (humidity<<8 br=""> humidity |= rxBuffer[3];
//-- calculate relative humidity [%RH]
humidity = ((double)humidity / 65536)*100;
System_printf("Humidity %u: %d (RH)\n", i, humidity);
}
else {
System_printf("I2C Bus fault\n");
}
System_flush();
Task_sleep(1000000 / Clock_tickPeriod);
}
/* Deinitialized I2C */
I2C_close(i2c);
System_printf("I2C closed!\n");
System_flush();
}
8>8>
Subscribe to:
Posts (Atom)