contiki-os / contiki

The official git repository for Contiki, the open source OS for the Internet of Things
http://www.contiki-os.org/
Other
3.71k stars 2.58k forks source link

simple LED and printf on cc2650 launchpad #2366

Open antigravity99 opened 6 years ago

antigravity99 commented 6 years ago

I am completely new to contiki and embedded development (just a little experience with Arduino).

I cloned contiki on an Ubuntu 17.10 VM and can compile and run simple applications to make an LED blink for a TelosB sky mote and I am trying to get the same simple application to run for the cc2650 Launchpad. It compiles just fine and the led turns on with the first 'leds_toggle(CC2650_RED_LED);' but never toggles off, which tells me something is going wrong but I have no idea as to what and 'printf' never outputs anything. I have tried using minicom connecting to both /dev/ttyACM0 and /dev/ttyACM1 but I get no printf serial output.

Here is the code:

#include "contiki.h"
#include "sys/etimer.h"
#include "dev/leds.h"
#include <stdio.h>

#define CC2650_RED_LED       LEDS_RED

PROCESS(test_process, "test process");
AUTOSTART_PROCESSES(&test_process);
PROCESS_THREAD(test_process, ev, data)
{
    PROCESS_BEGIN();

    leds_toggle(CC2650_RED_LED);

    static struct etimer et;

    etimer_set(&et, CLOCK_SECOND * 2);

    static int i = 1;
    static clock_time_t clockTime;

    while(i <= 100 )
    {
      etimer_set(&et, CLOCK_SECOND * 2);

      PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));

      clockTime = clock_time();

      printf("\rLoop %d     Clock Time %d", i++, (int)clockTime);
      leds_toggle(CC2650_RED_LED);

    }
    PROCESS_END();
}

I compile it with this command: 'sudo make clean TARGET=srf06-cc26xx BOARD=launchpad/cc2650 simple-test'

Again, this works just fine on a Sky mote, but the red led turns on and never turns off on the cc2650 launchpad and there is not printf serial output.

Any help will be greatly appreciated!

EDIT

I did some more googling around and found this page: http://sunmaysky.blogspot.com/2016/04/contiki-cc2650-adc-demo-using-dio23-as.html

I added '#define CLOCK_SECOND 128' as suggested and it now continues to run and toggle the LED off and on but I still get no printf serial output!

FIXED After I added '#define CLOCK_SECOND 128', I didn't double check my serial connection settings and baud rate was not 115200 and flow control was on. I changed the settings to 115200 8N1 None and I now get serial output on /dev/ttyACM0.

chenek commented 6 years ago

Try to refer to http://sunmaysky.blogspot.tw/2017/10/using-cc13xxcc26xx-running-contiki-os.html

xioabudian commented 6 years ago

in platform/srf06-cc26xx fold,different board has different peripherals configuration file,named board.h,and you can find UART pins,eg BOARD_IOID_UART_RX,BOARD_IOID_UART_TX, and try it on with USBTTL

xioabudian commented 6 years ago
etimer_set(&et,CLOCK_SECOND * 2);
while(true){
PROCESS_YIELD_UNTIL(ev==PROCESS_EVENT_TIMER);
if(etimer_expired(&et)){
leds_toggle(LEDS_RED);
etimer_reset(&et);
}

}