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

1 comment:

  1. Hi,
    I'm working with ubuntu 18.04 and gcc-arm-none-eabi (last from launchpad) I've compiled your code without any error and uploaded it to CC2650 Launchpad ver 1.3 but there's no communication with the terminal (teraterm 115200 8N1) I tried to use an timer based event to toggle the leds but also no results. is there any difference between cc2650 Launchpad ver 1.0 and ver 1.3 or the problem is somewhere else.
    Thank you in advance

    ReplyDelete