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();
}