This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2650STK: Sensor controller soft-UART with Contiki

Part Number: CC2650STK
Other Parts Discussed in Thread: CC2538

Hi guys!

I've been trying to integrate the stock no-RTOS "UART emulation" code generated with the Sensor Controller Studio with a Contiki-based project.

*.- My first try with stock Contiki power control ends up in a reboot loop almost as soon as my SC code is executed.

*.- I then added a  LPM_MODULE(softuart_module, NULL, NULL, NULL, LPM_DOMAIN_PERIPH); and a lpm_register_module(&softuart_module); on my init code and then at least the MCU doesn't reboot, and I'm able to get a couple of characters out of the SC-based UART, but only two or three chars get transmitted OK, with every char increasing the possibility of corruption.

*.- I then disabled RF to see if there's something in the RF/comm code that might be interfering.... but no changes... 

*.- I then tested a more radical idea, did some changes on Contiki's LPM code (cpu/cc26xx-cc13xx/lpm.h / .c) to disable everything like its done on the cc2538 with the LPM_CONF_ENABLE definition. Results: With LPM disabled, now I get 6-10 characters OK on the SC-UART. There's some progress ....

*.- I then tried disabling interrupts: No changes at all. 

*.- Next tried disabling the RX/alert callback code to see if it helps: It doesn't. 

Now I ran out of ideas to test what could be interfering with the TX of my messages. 

Any ideas?

The current test code is something like this: 

LPM_MODULE(softuart_module, NULL, NULL, NULL, LPM_DOMAIN_PERIPH);

/*---------------------------------------------------------------------------*/
PROCESS_THREAD(cc26xx_my_process, ev, data)
{

  PROCESS_BEGIN();
  // let's turn radio off to see if helps
  NETSTACK_RDC.off(0);
  printf("CC26XX test v26\n");
  // to be used in the alert callback for RX
  softuart_event = process_alloc_event();
  // doesn't do anything since I killed the LPM at contiki's code level
  lpm_register_module(&softuart_module); 
  // AUX domain access
  scifOsalEnableAuxDomainAccess();
  // my alert callback
  scifOsalRegisterTaskAlertCallback(&uartAlertCallback);

  scifInit(&scifDriverSetup);
  // Start the UART emulator
  scifExecuteTasksOnceNbl(BV(SCIF_UART_EMULATOR_TASK_ID));
  // Enable baud rate generation
  scifUartSetBaudRate(9600);

  // Enable RX (10 idle bit periods required before enabling start bit detection)
  scifUartSetRxFifoThr(SCIF_UART_RX_FIFO_MAX_COUNT / 2);
  scifUartSetRxTimeout(10 * 2);
  scifUartSetRxEnableReqIdleCount(10 * 2);
  scifUartRxEnable(1);

  // Enable events (half full RX FIFO or 10 bit period timeout
  scifUartSetEventMask(BV_SCIF_UART_ALERT_RX_FIFO_ABOVE_THR | BV_SCIF_UART_ALERT_RX_BYTE_TIMEOUT);


  scifUartTxPutChars("Hello how's everything?\r\n",25);

TIA!

  • OK, a small update.

    After reading this post:
    e2e.ti.com/.../1949275

    and the comment on the Contiki mailing list:
    sourceforge.net/.../

    I proceeded to change my init code and also add a registration for AUX clocks when going to low power via aux_ctrl_register_consumer().

    With that, power management enabled and everything, no issues with reboots, but I still can get only about 6-8 characters "uncorrupted" out of the SC UART emulation.

    Oddly enough, SC UART emulation RX works like a charm. No corruption issues at all.

    Init code is now like this:

    static aux_consumer_module_t uart_aux = {
      NULL, AUX_WUC_SMPH_CLOCK | AUX_WUC_AIODIO0_CLOCK |
      	  AUX_WUC_AIODIO1_CLOCK | AUX_WUC_TIMER_CLOCK |
    	  AUX_WUC_ANAIF_CLOCK | AUX_WUC_TDCIF_CLOCK |
    	  AUX_WUC_OSCCTRL_CLOCK | AUX_WUC_ADI_CLOCK | AUX_WUC_TDC_CLOCK |
    	  AUX_WUC_ADC_CLOCK | AUX_WUC_REF_CLOCK
    };
    
    /*---------------------------------------------------------------------------*/
    PROCESS_THREAD(cc26xx_my_process, ev, data)
    {
    
      PROCESS_BEGIN();
      printf("CC26XX test v43\n");
      // to be used in the alert callback for RX
      softuart_event = process_alloc_event();
    
      ti_lib_sys_ctrl_power_everything();
    
      // Stop SC.
      ti_lib_aon_wuc_aux_image_invalid();
    
      // Run all clocks at full speed for now.
      ti_lib_prcm_inf_clock_configure_set(PRCM_CLOCK_DIV_1, PRCM_RUN_MODE);
      ti_lib_prcm_inf_clock_configure_set(PRCM_CLOCK_DIV_1, PRCM_SLEEP_MODE);
      ti_lib_prcm_inf_clock_configure_set(PRCM_CLOCK_DIV_1, PRCM_DEEP_SLEEP_MODE);
      // clock resources
      aux_ctrl_register_consumer(&uart_aux);
      AUXWUCClockFreqReq(AUX_WUC_CLOCK_HIFREQ);
      AUXWUCPowerCtrl(AUX_WUC_POWER_ACTIVE);
      aux_ctrl_power_up();
      // AUX domain access
      scifOsalEnableAuxDomainAccess();
      // Init SC driver
      scifInit(&scifDriverSetup);
      // Start the UART emulator
      scifExecuteTasksOnceNbl(BV(SCIF_UART_EMULATOR_TASK_ID));
      // Enable baud rate generation
      scifUartSetBaudRate(9600);
      // my alert callback
      scifOsalRegisterTaskAlertCallback(&uartAlertCallback);
      // Enable RX (10 idle bit periods required before enabling start bit detection)
      scifUartSetRxFifoThr(SCIF_UART_RX_FIFO_MAX_COUNT / 2);
      scifUartSetRxTimeout(10 * 2);
      scifUartSetRxEnableReqIdleCount(10 * 2);
      scifUartRxEnable(1);
    
      // Enable events (half full RX FIFO or 10 bit period timeout
      scifUartSetEventMask(BV_SCIF_UART_ALERT_RX_FIFO_ABOVE_THR | BV_SCIF_UART_ALERT_RX_BYTE_TIMEOUT);
    
      scifUartTxPutChars("Hello how's everything? This is a long string\r\n",47);
    

  • Oh, and also I can only do SC UART TX from the RX event processing; if I do TX triggered from a button press, not a single character comes out.
  • OK, the last code I posted before does indeed work like a charm for UART emulation in Contiki via the Sensor Controller.


    My TX corruption issue? dying USB<->UART interface connected to the UART emulation pins; replaced it with another, even with the same chipset, and voilá!

    It does work flawlessly, so yes, aux_ctrl_register_consumer() does indeed prevent any powerdowns of the required clocks on the SC.


    I included all AUX clocks, which I think must be trimmed to what the UART code uses, but it does work.