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.

CC1350: regarding sensor controller interrupts

Part Number: CC1350
Other Parts Discussed in Thread: CC1310

Good day

My issue is related to functionality of the sensor controller. Since OS im using is taking too much of a controller time i cant manipulate with General purpose timers (i also tried RTC) to count values up to 30 usec correctly. So i took a look at AUX and found out that there are two timers up there (one is 16 and one is 8 bit, which is more than i need). But im struggling with interupt that Timer 0 is generating after the count is completed. The algorithm is: to enable timer, to leave all register fields of it as 0 (which is manual reactivating, a common counting, not attached to any of the events) and set prescaler to 2; then im forwarding timeout event from aon to MCU programmable event 0 and here is the place where my code stops working. After uploading hex file the code stops right b4 enabling MCU_programmable_event0 as interrupt (despite of the timer configuration, was it or was it not configured before). But here is the thing after i reset my chip the program starts working and enables handler exactly 37 times (magic number?). Im sure im missing something. The code for contiki OS is attached below. I would be very glad if some one suggested a solution for me. 

P. S.: handler should've been activeted just once if all configs were right.

P. P. S.: the code 

#include "contiki.h"
#include <dev/leds.h>
#include <inc/hw_types.h>
#include <inc/hw_memmap.h>
#include <inc/hw_prcm.h>
#include "launchpad/cc1350/board.h"
#include <inc/hw_gpt.h>
#include "ac-dimmer.h"

#include <stdlib.h>
#include <string.h>
#include <stdio.h>

#include "aux_timer.h"
#include "aux_wuc.h"
#include "aux-ctrl.h"

static struct etimer timer_etimer;

#include "gpio.h"
#include "ioc.h"
#include "gpio-interrupt.h"
#include "interrupt.h"

static int sup;

/*--------------------------------------------------------------------------*/
static void
handler(void)
{
sup++;
printf("%d sup \n", sup);
}
/*---------------------------------------------------------------------------*/
PROCESS(ac_dim, "Hello world process");
AUTOSTART_PROCESSES(&ac_dim);//, &print_process);
PROCESS_THREAD(ac_dim, ev, data)
{
PROCESS_BEGIN();
ti_lib_aon_wuc_aux_wakeup_event(AONWUC_AUX_WAKEUP);
/*while(!(ti_lib_aon_wuc_power_status_get() & AONWUC_AUX_POWER_ON))
{
}
*/
//AUXWUCPowerCtrl(AUX_WUC_POWER_ACTIVE);
printf("welp its ok \n");
//aux_ctrl_register_consumer(AUX_WUC_TIMER_CLOCK);
ti_lib_aux_wuc_clock_enable(AUX_WUC_ADI_CLOCK | AUX_WUC_OSCCTRL_CLOCK | AUX_WUC_TDCIF_CLOCK | AUX_WUC_ANAIF_CLOCK | \
AUX_WUC_TIMER_CLOCK | AUX_WUC_AIODIO0_CLOCK | AUX_WUC_AIODIO1_CLOCK | AUX_WUC_SMPH_CLOCK | \
AUX_WUC_TDC_CLOCK | AUX_WUC_ADC_CLOCK | AUX_WUC_REF_CLOCK);
/*while(ti_lib_aux_wuc_clock_status(AUX_WUC_TIMER_CLOCK) != AUX_WUC_CLOCK_READY)
{
}*/
AUXTimerConfigure(AUX_TIMER_0, AUX_TIMER_CFG_ONE_SHOT); // | AUX_TIMER_CFG_TICK_SRC_RTC_4KHZ);
AUXTimerPrescaleSet(AUX_TIMER_0, AUX_TIMER_PRESCALE_DIV_1);
HWREG(AUX_TIMER_BASE + AUX_TIMER_O_T0TARGET) = 65530;
HWREG(AON_EVENT_BASE + 0x00000008)= 0x00000033;
//AONEventMcuSet(AON_EVENT_MCU_EVENT0, AON_EVENT_AUX_TIMER0_EV);
ti_lib_int_master_enable();
printf("been here \n");
ti_lib_int_enable(INT_AON_PROG0);
printf("stopped working \n");
IntRegister(INT_AON_PROG0, handler);
AUXTimerStart(AUX_TIMER_0);
etimer_set(&timer_etimer, 1 * CLOCK_SECOND);
while(1)
{
PROCESS_WAIT_EVENT_UNTIL(ev == PROCESS_EVENT_TIMER);
leds_toggle(LEDS_RED);
etimer_reset(&timer_etimer);
}
PROCESS_END();
}

  • Hi,

    I have never used the AUX timers, so I can't say much. But I wonder what is the reason for not using the General Purpose Timer unit?

  • Greetins, Richard

    Haven't i mentioned it? The reason is that the OS im using (Contiki OS) is using way too much system time, and i never get right values if im using GPT in one shot mode (i checked in oscilloscope driving pin from high to low). The values are always different, despite i put the same values, prescalers and so on. I've been adviced to use sensor controller for stuff such as AC-dimming (with zero cross). So now im trying to learn how to use sensor controller for different purposes.

    Best regards, Vladimir.

  • I wonder why you need interrupts for this use-case. Your application can run stand-alone on the Sensor Controller Engine (SCE) and you just need to control it from the main core via some user-defined flags in memory.

    To start with the sensor controller engine (SCE), I'd suggest to start with a TI-RTOS example, for instance the rfWsnNode example on a CC1310 launchpad. You have to develop the application in Sensor Controller Studio (SCS).

    SCS exports a binary image that is then loaded into the AUX_RAM. SCS also exports interface code (subfolder sce in the example). For Contiki, you would then either modify scif_osal_tirtos.h/c or you would refactor code of scif_framework.c/.h.

    For your use-case, use the "Button debouncer" example as a starting point. This one shows you how to run a SCE task on a GPIO event (your zero-crossing interrupt). Replace the debouncing logic with the code snippet from the timer0 documentation in SCS):

    // Generate timer event after 100 us
    timer0Start(TIMER0_MODE_SINGLE, 2400, 0);
    gpioSetOutput(AUXIO_O_LED);
    
    // Wait for the timeout
    timer0Wait();
    gpioClearOutput(AUXIO_O_LED); 

    You also need to make sure that the CC1310 does not go into standby while dimming (lpm mode in Contiki).

  • Greetings, Richard
    Thanks for ur tips

    That was exactly the way i planned to proceed. The only reason i was delaying this line of research is that i'm not familiar with, as you mentioned, refactoring code's that were compiled by sensor controller studio.
    And i want to clarify how does sensor controller alerts the main core at the end of it's timer0 count? I realised that i can run a standalone app, but if i want to use sensor controller for other tasks i have to study it a bit deeper than one use-case.

    Thanks in advance
    Vladimir

  • Hi,

    the sensor controller has an interrupt line where it can trigger events on the main core. But if you just want to use signal a timeout on the aux timer, then there is 0 benefit compared to using the GP timer main core because you may observe the same delays.

  • Yes, I see, as i said i want to know it for advanced research. Can you please specify which interrupts sc is using exactly? According to cc13xx CPU_MMAP register summary?
  • INT_AON_AUX_SWEV0 and INT_AON_AUX_SWEV1 are used. Please have a look at the code exported by Sensor Controller Studio.
  • Thanks a lot for your suggestions, Richard!

    with best regards
    Vladimir.