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.

CC1352R: Event Trigger Mapping, tasks and Sensor controller.

Part Number: CC1352R

Hi!

I have two tasks in a sensor controller project.

- Task 1: an event handler waiting for interruptions from an external pin.

- Task 2: "Hall Effect Sensor for LPSTK" example ( an event handler waiting for interruptions from an external pin and a timer).

If both task are enable, timer doesn't work.

If only task 2 is enable, both interruptions work perfectly.

Sensor controller help say: "The CC13x2/CC26x2 and CC13x4/CC26x4 chip families support up to 3 event triggers in total per project"

In the panel task you can't change the event index so the 3 event triggers have to be in SAME task?

Thanks in advance

Andrés

  • Hi Andres,

    Sorry for the delay in the response, but we are very constrained in term of bandwidth over the month of July. 

    Could you share your code from sensor controller studio to help in the debug?

    The sensor controller for those families of devices supports a total of 3 event triggers shared among all the tasks in the project. Therefore if have 1 event in task 1 and 2 events in task 2 you should have enough resources available. Also please note that the task's event indexes are specific to each task: that is to say that event index 0 in task 1 is different than event index 0 in task 2. 

    Regards,

    Fausto

  • Hi Fausto,

    <?xml version="1.0" encoding="UTF-8"?>
    <project name="Water Meter for SPILBA PCB Alter" version="2.9.0.208">
        <desc><![CDATA[]]></desc>
        <pattr name="Apply default power mode">0</pattr>
        <pattr name="Board">CC1310 LaunchPad</pattr>
        <pattr name="Chip name">CC1352R1F3</pattr>
        <pattr name="Chip package">QFN48 7x7 RGZ</pattr>
        <pattr name="Chip revision">E</pattr>
        <pattr name="Clock in active mode">0</pattr>
        <pattr name="Code prefix"></pattr>
        <pattr name="Default power mode">0</pattr>
        <pattr name="Operating system">TI-RTOS</pattr>
        <pattr name="Output directory">C:/Users/ryzen5-PC/Google Drive (admin@rayce.com.ar)/Proyecto Medidores SPILBA/Sensor Controller Studio/output</pattr>
        <pattr name="RTC tick interval (16.16 format)">1000</pattr>
        <pattr name="Run-time logging UART RX pin"></pattr>
        <pattr name="Run-time logging UART TX pin"></pattr>
        <task name="Medicion">
            <desc><![CDATA[]]></desc>
            <tattr name="EVTMG2_OPCODE" desc="EVTMG2 Command (08h). The EVTMG2 command initiates the event timing mode 2 advanced automatic measurement feature. This timing 2 mode performs automatic TOF_DIFF measurements as described in the Event Timing Operation section." type="expr_hex" content="const" scope="task" min="0" max="65535">0x0008</tattr>
            <tattr name="EVTMG_TOF_COMPLETE_MASK" type="expr_hex" content="const" scope="task" min="0" max="65535">0x0200</tattr>
            <tattr name="HALT_OPCODE" desc="The HALT command is sent to the MAX35103 to stop any of the three EVTMG1/2/3 commands. All register data content is frozen and the SPI is then made available for access by the host microcontroller for commands, memory access, and register access." type="expr_hex" content="const" scope="task" min="0" max="65535">0x000A</tattr>
            <tattr name="INT_ROPCODE" desc="Interrupt Status Register" type="expr_hex" content="const" scope="task" min="0" max="65535">0x00FE</tattr>
            <tattr name="INT_STATUS_MASK" type="expr_hex" content="const" scope="task" min="0" max="65535">0xC6B8</tattr>
            <tattr name="TOF_DIFF_ROPCODE" type="expr_hex" content="const" scope="task" min="0" max="65535">0x00E5</tattr>
            <tattr name="output.intStatus" type="expr_hex" content="struct" scope="task" min="0" max="65535">0x000</tattr>
            <tattr name="output.tofDiffAvgFrac" type="expr_hex" content="struct" scope="task" min="0" max="65535">0</tattr>
            <tattr name="output.tofDiffAvgInt" type="expr_hex" content="struct" scope="task" min="0" max="65535">0</tattr>
            <tattr name="state.intStatus" type="expr_hex" content="struct" scope="task" min="0" max="65535">0</tattr>
            <tattr name="state.prueba" type="expr_hex" content="struct" scope="task" min="0" max="65535">0x00</tattr>
            <resource_ref name="ADC" enabled="0"/>
            <resource_ref name="AON Domain Functionality" enabled="0"/>
            <resource_ref name="Accumulator-Based Math" enabled="0"/>
            <resource_ref name="Analog Open-Drain Pins" enabled="0"/>
            <resource_ref name="Analog Open-Source Pins" enabled="0"/>
            <resource_ref name="Analog Pins" enabled="0"/>
            <resource_ref name="COMPA" enabled="0"/>
            <resource_ref name="COMPA Event Trigger" enabled="0"/>
            <resource_ref name="COMPB" enabled="0"/>
            <resource_ref name="COMPB Event Trigger" enabled="0"/>
            <resource_ref name="Delay Insertion" enabled="1"/>
            <resource_ref name="Differential Output Pins" enabled="0"/>
            <resource_ref name="Digital Input Pins" enabled="1">
                <io_usage name="MAX35103_INT" label="MAX35103 Interrupt">
                    <uattr name="Configuration on initialization">1</uattr>
                    <uattr name="Configuration on uninitialization">1</uattr>
                    <uattr name="Pin count">0</uattr>
                    <uattr name="Pin/0000">DIO4</uattr>
                    <uattr name="Pin/0001"></uattr>
                    <uattr name="Pin/0002"></uattr>
                    <uattr name="Pin/0003"></uattr>
                    <uattr name="Pin/0004"></uattr>
                    <uattr name="Pin/0005"></uattr>
                    <uattr name="Pin/0006"></uattr>
                    <uattr name="Pin/0007"></uattr>
                    <uattr name="Pin/0008"></uattr>
                    <uattr name="Pin/0009"></uattr>
                    <uattr name="Pin/0010"></uattr>
                    <uattr name="Pin/0011"></uattr>
                    <uattr name="Pin/0012"></uattr>
                    <uattr name="Pin/0013"></uattr>
                    <uattr name="Pin/0014"></uattr>
                    <uattr name="Pin/0015"></uattr>
                    <uattr name="Pin/0016"></uattr>
                    <uattr name="Pin/0017"></uattr>
                    <uattr name="Pin/0018"></uattr>
                    <uattr name="Pin/0019"></uattr>
                    <uattr name="Pin/0020"></uattr>
                    <uattr name="Pin/0021"></uattr>
                    <uattr name="Pin/0022"></uattr>
                    <uattr name="Pin/0023"></uattr>
                    <uattr name="Pin/0024"></uattr>
                    <uattr name="Pin/0025"></uattr>
                    <uattr name="Pin/0026"></uattr>
                    <uattr name="Pin/0027"></uattr>
                    <uattr name="Pin/0028"></uattr>
                    <uattr name="Pin/0029"></uattr>
                    <uattr name="Pin/0030"></uattr>
                    <uattr name="Pin/0031"></uattr>
                </io_usage>
            </resource_ref>
            <resource_ref name="Digital Open-Drain Pins" enabled="0"/>
            <resource_ref name="Digital Open-Source Pins" enabled="0"/>
            <resource_ref name="Digital Output Pins" enabled="1">
                <io_usage name="MAX35103_RST" label="MAX35103 RESET">
                    <uattr name="Configuration on uninitialization">1</uattr>
                    <uattr name="Output drive strength">0</uattr>
                    <uattr name="Output value on initialization">1</uattr>
                    <uattr name="Pin count">0</uattr>
                    <uattr name="Pin/0000">DIO24</uattr>
                    <uattr name="Pin/0001"></uattr>
                    <uattr name="Pin/0002"></uattr>
                    <uattr name="Pin/0003"></uattr>
                    <uattr name="Pin/0004"></uattr>
                    <uattr name="Pin/0005"></uattr>
                    <uattr name="Pin/0006"></uattr>
                    <uattr name="Pin/0007"></uattr>
                    <uattr name="Pin/0008"></uattr>
                    <uattr name="Pin/0009"></uattr>
                    <uattr name="Pin/0010"></uattr>
                    <uattr name="Pin/0011"></uattr>
                    <uattr name="Pin/0012"></uattr>
                    <uattr name="Pin/0013"></uattr>
                    <uattr name="Pin/0014"></uattr>
                    <uattr name="Pin/0015"></uattr>
                    <uattr name="Pin/0016"></uattr>
                    <uattr name="Pin/0017"></uattr>
                    <uattr name="Pin/0018"></uattr>
                    <uattr name="Pin/0019"></uattr>
                    <uattr name="Pin/0020"></uattr>
                    <uattr name="Pin/0021"></uattr>
                    <uattr name="Pin/0022"></uattr>
                    <uattr name="Pin/0023"></uattr>
                    <uattr name="Pin/0024"></uattr>
                    <uattr name="Pin/0025"></uattr>
                    <uattr name="Pin/0026"></uattr>
                    <uattr name="Pin/0027"></uattr>
                    <uattr name="Pin/0028"></uattr>
                    <uattr name="Pin/0029"></uattr>
                    <uattr name="Pin/0030"></uattr>
                    <uattr name="Pin/0031"></uattr>
                </io_usage>
            </resource_ref>
            <resource_ref name="Dynamic Power Control" enabled="0"/>
            <resource_ref name="GPIO Event Trigger" enabled="1"/>
            <resource_ref name="I2C Master" enabled="0">
                <rattr name="SCL frequency">0</rattr>
                <rattr name="SCL stretch timeout">1</rattr>
                <io_usage>
                    <uattr name="Output drive strength">1</uattr>
                    <uattr name="SCL pin/0000"></uattr>
                    <uattr name="SDA pin/0000"></uattr>
                </io_usage>
            </resource_ref>
            <resource_ref name="ISRC" enabled="0"/>
            <resource_ref name="LCD Controller" enabled="0">
                <rattr name="Waveform state count">8</rattr>
                <io_usage>
                    <uattr name="Output drive strength">0</uattr>
                    <uattr name="Pin count">20</uattr>
                    <uattr name="Pin/0000"></uattr>
                    <uattr name="Pin/0001"></uattr>
                    <uattr name="Pin/0002"></uattr>
                    <uattr name="Pin/0003"></uattr>
                    <uattr name="Pin/0004"></uattr>
                    <uattr name="Pin/0005"></uattr>
                    <uattr name="Pin/0006"></uattr>
                    <uattr name="Pin/0007"></uattr>
                    <uattr name="Pin/0008"></uattr>
                    <uattr name="Pin/0009"></uattr>
                    <uattr name="Pin/0010"></uattr>
                    <uattr name="Pin/0011"></uattr>
                    <uattr name="Pin/0012"></uattr>
                    <uattr name="Pin/0013"></uattr>
                    <uattr name="Pin/0014"></uattr>
                    <uattr name="Pin/0015"></uattr>
                    <uattr name="Pin/0016"></uattr>
                    <uattr name="Pin/0017"></uattr>
                    <uattr name="Pin/0018"></uattr>
                    <uattr name="Pin/0019"></uattr>
                    <uattr name="Pin/0020"></uattr>
                    <uattr name="Pin/0021"></uattr>
                    <uattr name="Pin/0022"></uattr>
                    <uattr name="Pin/0023"></uattr>
                    <uattr name="Pin/0024"></uattr>
                    <uattr name="Pin/0025"></uattr>
                    <uattr name="Pin/0026"></uattr>
                    <uattr name="Pin/0027"></uattr>
                    <uattr name="Pin/0028"></uattr>
                    <uattr name="Pin/0029"></uattr>
                    <uattr name="Pin/0030"></uattr>
                    <uattr name="Pin/0031"></uattr>
                </io_usage>
            </resource_ref>
            <resource_ref name="Math and Logic" enabled="0"/>
            <resource_ref name="Multi-Buffered Output Data Exchange" enabled="0">
                <rattr name="Buffer count">2</rattr>
                <rattr name="Indicate overflow at buffer check">1</rattr>
                <rattr name="Indicate overflow at buffer switch">0</rattr>
                <rattr name="Prevent overflow at buffer switch">1</rattr>
            </resource_ref>
            <resource_ref name="Peripheral Sharing" enabled="0"/>
            <resource_ref name="Pulse Counter" enabled="0"/>
            <resource_ref name="RTC Multi-Event Capture" enabled="0"/>
            <resource_ref name="RTC-Based Execution Scheduling" enabled="0"/>
            <resource_ref name="Reference DAC" enabled="0"/>
            <resource_ref name="Run-Time Logging" enabled="0"/>
            <resource_ref name="SPI Chip Select" enabled="1">
                <io_usage name="MAX35103_CS" label="MAX35103 chip select">
                    <uattr name="CSN configuration when idle">0</uattr>
                    <uattr name="CSN pin/0000">DIO5</uattr>
                </io_usage>
            </resource_ref>
            <resource_ref name="SPI Data Transfer" enabled="1">
                <rattr name="Bit rate">0</rattr>
                <rattr name="MISO configuration when inactive">-1</rattr>
                <rattr name="MOSI configuration on initialization">0</rattr>
                <rattr name="MOSI configuration on uninitialization">0</rattr>
                <rattr name="SCLK configuration on initialization">0</rattr>
                <rattr name="SCLK configuration on uninitialization">0</rattr>
                <io_usage>
                    <uattr name="MISO pin/0000">DIO28</uattr>
                    <uattr name="MOSI pin/0000">DIO29</uattr>
                    <uattr name="SCLK pin/0000">DIO30</uattr>
                </io_usage>
            </resource_ref>
            <resource_ref name="Signal Observation" enabled="0"/>
            <resource_ref name="System CPU Alert" enabled="1"/>
            <resource_ref name="System Event Trigger" enabled="0"/>
            <resource_ref name="TDC" enabled="0"/>
            <resource_ref name="Timer 0" enabled="0"/>
            <resource_ref name="Timer 0 Event Trigger" enabled="0"/>
            <resource_ref name="Timer 1" enabled="0"/>
            <resource_ref name="Timer 1 Event Trigger" enabled="0"/>
            <resource_ref name="Timer 2" enabled="0"/>
            <resource_ref name="Timer 2 Event Trigger" enabled="0"/>
            <resource_ref name="UART Emulator" enabled="0">
                <rattr name="RX buffer size">64</rattr>
                <rattr name="Required idle period before enabling RX">11</rattr>
                <rattr name="TX buffer size">64</rattr>
                <io_usage>
                    <uattr name="RX pin/0000"></uattr>
                    <uattr name="TX pin/0000"></uattr>
                </io_usage>
            </resource_ref>
            <sccode name="event0" init_power_mode="0"><![CDATA[//Lee el registro de interrupciones.
    spiCfg(SPI_POL0_PHA1, 4);
    spiBegin(AUXIO_SPI_CSN_MAX35103_CS);
    spiTx8bit(INT_ROPCODE); //0x00FE
    spiRx16bit(state.intStatus);
    spiEnd(AUXIO_SPI_CSN_MAX35103_CS);
    
    
    U16 evtmgTest = 0;
    
    evtmgTest = (state.intStatus & EVTMG_TOF_COMPLETE_MASK); //0x0200 máscara para solo atender la interrupción cuando hay un TOF_EVTMG (Event Timing TOF Completed)
    
    if (evtmgTest == EVTMG_TOF_COMPLETE_MASK) {
    
        output.intStatus = state.intStatus & INT_STATUS_MASK;
        spiCfg(SPI_POL0_PHA1, 4);
        spiBegin(AUXIO_SPI_CSN_MAX35103_CS);
        spiTx8bit(TOF_DIFF_ROPCODE);        //0x00E5 ADDRESS TOF_DIFF AVG
        spiRx16bit(output.tofDiffAvgInt);   //16-bit fixed-point two’s-complement integer portion of the average of the accumulated TOF_DIFF measurements
        spiRx16bit(output.tofDiffAvgFrac);  //16-bit fractional portion of the two’s-complement average of the accumulated TOF_DIFF measurements
        spiEnd(AUXIO_SPI_CSN_MAX35103_CS);
        fwGenAlertInterrupt();
    
        //**********************************************************
        output.tofDiffAvgInt=0x64;
        output.tofDiffAvgFrac=0x00;
        state.prueba = state.prueba + 1;
        //**********************************************************
    }
    
    //re-inicializa la interrupcion
    
    evhSetupGpioTrigger( 0, AUXIO_I_MAX35103_INT, 0, EVH_GPIO_TRIG_ON_MATCH);]]></sccode>
            <sccode name="event1" init_power_mode="0"><![CDATA[]]></sccode>
            <sccode name="event2" init_power_mode="0"><![CDATA[]]></sccode>
            <sccode name="event3" init_power_mode="0"><![CDATA[]]></sccode>
            <sccode name="execute" init_power_mode="0"><![CDATA[]]></sccode>
            <sccode name="initialize" init_power_mode="0"><![CDATA[//Lee el pin de interrupciones.
    
    spiCfg(SPI_POL0_PHA1, 4);
    spiBegin(AUXIO_SPI_CSN_MAX35103_CS);
    spiTx8bit(INT_ROPCODE); //0x00FE
    spiRx16bit(state.intStatus);
    spiEnd(AUXIO_SPI_CSN_MAX35103_CS);
    
    //Manda el codigo para iniciar la medicion continua.
    spiCfg(SPI_POL0_PHA1, 4);
    spiBegin(AUXIO_SPI_CSN_MAX35103_CS);
    spiTx8bit(EVTMG2_OPCODE);
    spiEnd(AUXIO_SPI_CSN_MAX35103_CS);
    
    //inicializa la interrupcion
    
    //evhSetupGpioTrigger
    //
    //Prototype: evhSetupGpioTrigger(#evIndex, #auxio, #level, #type)
    //
    //Sets up a GPIO pin to generate an Event Handler Code trigger. Event indexes are mapped to event handlers in the task panel. The trigger is one-shot.
    //
    //The trigger occurs as soon as the GPIO pin matches or transitions to the selected level. The Event Handler Code block that matches the specified event index then starts when the Sensor Controller is idle or in standby mode.
    //
    //The GPIO pin is sampled at 32 kHz, and must be held active for at least 2 x 32 kHz periods to be captured safely.
    //Parameter value(s)
    //
    //    #evIndex - Event index to be triggered
    //    #auxio - The GPIO pin that shall generate the trigger (index of AUX I/O pin)
    //    #level - The pin level that shall generate the trigger (1 = high level / rising edge, 0 = low level / falling edge)
    //    #type - GPIO trigger type (EVH_GPIO_TRIG_ON_MATCH to trigger immediately on match, or EVH_GPIO_TRIG_ON_EDGE to wait for a transition to the level)
    
    evhSetupGpioTrigger( 0, AUXIO_I_MAX35103_INT, 0, EVH_GPIO_TRIG_ON_MATCH);
    
    // AUXIO_I_MAX35103_INT = 14 AUX I/O pin ---> DIO4
    
    //EVH_GPIO_TRIG_ON_MATCH ---> GPIO trigger type: Generated on match, edge from inverse level is not required]]></sccode>
            <sccode name="terminate" init_power_mode="0"><![CDATA[//Termination Code will only run once when task is stopped by the application processor (scifStopTasksNbl()) or at the end of a single iteration for all task code blocks (scifExecuteTasksOnceNbl()).
    
    //AED:  Nunca va a correr esto, porque no se llaman a ninguna de la dos funciones de arriba. En principio porque desde el micro principal yo accedo a la ram del micro secundario
    //      no interrogo por SPI al MAX35103
    
    //Cancela la interrupcion
    evhCancelTrigger(0);
    
    //Manda el comando de HALT
    //The HALT command is sent to the MAX35103 to stop any
    //of the three EVTMG1/2/3 commands. All register data
    //content is frozen and the SPI is then made available for
    //access by the host microcontroller for commands, memory access, and register access.
    
    
    spiCfg(SPI_POL0_PHA1, 4);
    spiBegin(AUXIO_SPI_CSN_MAX35103_CS);
    spiTx8bit(HALT_OPCODE); //0x0A
    spiEnd(AUXIO_SPI_CSN_MAX35103_CS);
    
    //Delay para que confirme que se freno la medicion
    //The HALT command takes time to execute.
    fwDelayUs(1500);
    
    //Lee la interrupcion
    spiCfg(SPI_POL0_PHA1, 4);
    spiBegin(AUXIO_SPI_CSN_MAX35103_CS);
    spiTx8bit(INT_ROPCODE);
    spiRx16bit(state.intStatus);
    spiEnd(AUXIO_SPI_CSN_MAX35103_CS);
    
    state.intStatus=0x000b;
    
    //Genera el alert para el micro
    fwGenAlertInterrupt();]]></sccode>
            <event_trigger active_count="1">0,1,2,3</event_trigger>
            <tt_iter>if_event0trigset_start,run_event0,if_event0trigset_end</tt_iter>
            <tt_struct>output.intStatus,state.intStatus,state.prueba</tt_struct>
            <rtl_struct></rtl_struct>
            <rtl_task_sel en="1" struct_log_list="output"/>
        </task>
        <task name="Config MAX35103">
            <desc><![CDATA[]]></desc>
            <tattr name="INT_ROPCODE" desc="Interrupt Status Register" type="expr_hex" content="const" scope="task" min="0" max="65535">0x00FE</tattr>
            <tattr name="MAX3510X_OPCODE_FLASH" type="expr_hex" content="const" scope="task" min="0" max="65535">0x0006</tattr>
            <tattr name="MAX3510X_OPCODE_FLASH_TO_MASK" type="expr_hex" content="const" scope="task" min="0" max="65535">0x0080</tattr>
            <tattr name="MAX3510X_OPCODE_INITIALIZE" type="expr_hex" content="const" scope="task" min="0" max="65535">0x0005</tattr>
            <tattr name="MAX3510X_OPCODE_LDO_ON" type="expr_hex" content="const" scope="task" min="0" max="65535">0x000C</tattr>
            <tattr name="MAX3510X_REG_INTERRUPT_STATUS_INVALID" desc="state machine in reset" type="expr_hex" content="const" scope="task" min="0" max="65535">0xFFFF</tattr>
            <tattr name="TOF1_WOPCODE" type="expr_hex" content="const" scope="task" min="0" max="65535">0x0038</tattr>
            <tattr name="cfg.EVTMG1" type="expr_hex" content="struct" scope="task" min="0" max="65535">0</tattr>
            <tattr name="cfg.EVTMG2" type="expr_hex" content="struct" scope="task" min="0" max="65535">0</tattr>
            <tattr name="cfg.TOF1" type="expr_hex" content="struct" scope="task" min="0" max="65535">0</tattr>
            <tattr name="cfg.TOF2" type="expr_hex" content="struct" scope="task" min="0" max="65535">0</tattr>
            <tattr name="cfg.TOF3" type="expr_hex" content="struct" scope="task" min="0" max="65535">0</tattr>
            <tattr name="cfg.TOF4" type="expr_hex" content="struct" scope="task" min="0" max="65535">0</tattr>
            <tattr name="cfg.TOF5" type="expr_hex" content="struct" scope="task" min="0" max="65535">0</tattr>
            <tattr name="cfg.TOF6" type="expr_hex" content="struct" scope="task" min="0" max="65535">0</tattr>
            <tattr name="cfg.TOF7" type="expr_hex" content="struct" scope="task" min="0" max="65535">0</tattr>
            <tattr name="cfg.TOFMeasDelay" type="expr_hex" content="struct" scope="task" min="0" max="65535">0</tattr>
            <tattr name="output.intStatus" type="expr_hex" content="struct" scope="task" min="0" max="65535">0x0000</tattr>
            <resource_ref name="ADC" enabled="0"/>
            <resource_ref name="AON Domain Functionality" enabled="0"/>
            <resource_ref name="Accumulator-Based Math" enabled="0"/>
            <resource_ref name="Analog Open-Drain Pins" enabled="0"/>
            <resource_ref name="Analog Open-Source Pins" enabled="0"/>
            <resource_ref name="Analog Pins" enabled="0"/>
            <resource_ref name="COMPA" enabled="0"/>
            <resource_ref name="COMPA Event Trigger" enabled="0"/>
            <resource_ref name="COMPB" enabled="0"/>
            <resource_ref name="COMPB Event Trigger" enabled="0"/>
            <resource_ref name="Delay Insertion" enabled="1"/>
            <resource_ref name="Differential Output Pins" enabled="0"/>
            <resource_ref name="Digital Input Pins" enabled="0"/>
            <resource_ref name="Digital Open-Drain Pins" enabled="0"/>
            <resource_ref name="Digital Open-Source Pins" enabled="0"/>
            <resource_ref name="Digital Output Pins" enabled="1">
                <io_usage name="MAX35103_RST" label="MAX35103 RESET">
                    <uattr name="Configuration on uninitialization">1</uattr>
                    <uattr name="Output drive strength">0</uattr>
                    <uattr name="Output value on initialization">1</uattr>
                    <uattr name="Pin count">0</uattr>
                    <uattr name="Pin/0000">DIO24</uattr>
                    <uattr name="Pin/0001"></uattr>
                    <uattr name="Pin/0002"></uattr>
                    <uattr name="Pin/0003"></uattr>
                    <uattr name="Pin/0004"></uattr>
                    <uattr name="Pin/0005"></uattr>
                    <uattr name="Pin/0006"></uattr>
                    <uattr name="Pin/0007"></uattr>
                    <uattr name="Pin/0008"></uattr>
                    <uattr name="Pin/0009"></uattr>
                    <uattr name="Pin/0010"></uattr>
                    <uattr name="Pin/0011"></uattr>
                    <uattr name="Pin/0012"></uattr>
                    <uattr name="Pin/0013"></uattr>
                    <uattr name="Pin/0014"></uattr>
                    <uattr name="Pin/0015"></uattr>
                    <uattr name="Pin/0016"></uattr>
                    <uattr name="Pin/0017"></uattr>
                    <uattr name="Pin/0018"></uattr>
                    <uattr name="Pin/0019"></uattr>
                    <uattr name="Pin/0020"></uattr>
                    <uattr name="Pin/0021"></uattr>
                    <uattr name="Pin/0022"></uattr>
                    <uattr name="Pin/0023"></uattr>
                    <uattr name="Pin/0024"></uattr>
                    <uattr name="Pin/0025"></uattr>
                    <uattr name="Pin/0026"></uattr>
                    <uattr name="Pin/0027"></uattr>
                    <uattr name="Pin/0028"></uattr>
                    <uattr name="Pin/0029"></uattr>
                    <uattr name="Pin/0030"></uattr>
                    <uattr name="Pin/0031"></uattr>
                </io_usage>
            </resource_ref>
            <resource_ref name="Dynamic Power Control" enabled="0"/>
            <resource_ref name="GPIO Event Trigger" enabled="0"/>
            <resource_ref name="I2C Master" enabled="0">
                <rattr name="SCL frequency">0</rattr>
                <rattr name="SCL stretch timeout">1</rattr>
                <io_usage>
                    <uattr name="Output drive strength">1</uattr>
                    <uattr name="SCL pin/0000"></uattr>
                    <uattr name="SDA pin/0000"></uattr>
                </io_usage>
            </resource_ref>
            <resource_ref name="ISRC" enabled="0"/>
            <resource_ref name="LCD Controller" enabled="0">
                <rattr name="Waveform state count">8</rattr>
                <io_usage>
                    <uattr name="Output drive strength">0</uattr>
                    <uattr name="Pin count">20</uattr>
                    <uattr name="Pin/0000"></uattr>
                    <uattr name="Pin/0001"></uattr>
                    <uattr name="Pin/0002"></uattr>
                    <uattr name="Pin/0003"></uattr>
                    <uattr name="Pin/0004"></uattr>
                    <uattr name="Pin/0005"></uattr>
                    <uattr name="Pin/0006"></uattr>
                    <uattr name="Pin/0007"></uattr>
                    <uattr name="Pin/0008"></uattr>
                    <uattr name="Pin/0009"></uattr>
                    <uattr name="Pin/0010"></uattr>
                    <uattr name="Pin/0011"></uattr>
                    <uattr name="Pin/0012"></uattr>
                    <uattr name="Pin/0013"></uattr>
                    <uattr name="Pin/0014"></uattr>
                    <uattr name="Pin/0015"></uattr>
                    <uattr name="Pin/0016"></uattr>
                    <uattr name="Pin/0017"></uattr>
                    <uattr name="Pin/0018"></uattr>
                    <uattr name="Pin/0019"></uattr>
                    <uattr name="Pin/0020"></uattr>
                    <uattr name="Pin/0021"></uattr>
                    <uattr name="Pin/0022"></uattr>
                    <uattr name="Pin/0023"></uattr>
                    <uattr name="Pin/0024"></uattr>
                    <uattr name="Pin/0025"></uattr>
                    <uattr name="Pin/0026"></uattr>
                    <uattr name="Pin/0027"></uattr>
                    <uattr name="Pin/0028"></uattr>
                    <uattr name="Pin/0029"></uattr>
                    <uattr name="Pin/0030"></uattr>
                    <uattr name="Pin/0031"></uattr>
                </io_usage>
            </resource_ref>
            <resource_ref name="Math and Logic" enabled="0"/>
            <resource_ref name="Multi-Buffered Output Data Exchange" enabled="0">
                <rattr name="Buffer count">2</rattr>
                <rattr name="Indicate overflow at buffer check">1</rattr>
                <rattr name="Indicate overflow at buffer switch">0</rattr>
                <rattr name="Prevent overflow at buffer switch">1</rattr>
            </resource_ref>
            <resource_ref name="Peripheral Sharing" enabled="0"/>
            <resource_ref name="Pulse Counter" enabled="0"/>
            <resource_ref name="RTC Multi-Event Capture" enabled="0"/>
            <resource_ref name="RTC-Based Execution Scheduling" enabled="0"/>
            <resource_ref name="Reference DAC" enabled="0"/>
            <resource_ref name="Run-Time Logging" enabled="0"/>
            <resource_ref name="SPI Chip Select" enabled="1">
                <io_usage name="MAX35103_CS" label="MAX35103 chip select">
                    <uattr name="CSN configuration when idle">0</uattr>
                    <uattr name="CSN pin/0000">DIO5</uattr>
                </io_usage>
            </resource_ref>
            <resource_ref name="SPI Data Transfer" enabled="1">
                <rattr name="Bit rate">0</rattr>
                <rattr name="MISO configuration when inactive">-1</rattr>
                <rattr name="MOSI configuration on initialization">0</rattr>
                <rattr name="MOSI configuration on uninitialization">0</rattr>
                <rattr name="SCLK configuration on initialization">0</rattr>
                <rattr name="SCLK configuration on uninitialization">0</rattr>
                <io_usage>
                    <uattr name="MISO pin/0000">DIO28</uattr>
                    <uattr name="MOSI pin/0000">DIO29</uattr>
                    <uattr name="SCLK pin/0000">DIO30</uattr>
                </io_usage>
            </resource_ref>
            <resource_ref name="Signal Observation" enabled="0"/>
            <resource_ref name="System CPU Alert" enabled="1"/>
            <resource_ref name="System Event Trigger" enabled="0"/>
            <resource_ref name="TDC" enabled="0"/>
            <resource_ref name="Timer 0" enabled="0"/>
            <resource_ref name="Timer 0 Event Trigger" enabled="0"/>
            <resource_ref name="Timer 1" enabled="0"/>
            <resource_ref name="Timer 1 Event Trigger" enabled="0"/>
            <resource_ref name="Timer 2" enabled="0"/>
            <resource_ref name="Timer 2 Event Trigger" enabled="0"/>
            <resource_ref name="UART Emulator" enabled="0">
                <rattr name="RX buffer size">64</rattr>
                <rattr name="Required idle period before enabling RX">11</rattr>
                <rattr name="TX buffer size">64</rattr>
                <io_usage>
                    <uattr name="RX pin/0000"></uattr>
                    <uattr name="TX pin/0000"></uattr>
                </io_usage>
            </resource_ref>
            <sccode name="event0" init_power_mode="0"><![CDATA[]]></sccode>
            <sccode name="event1" init_power_mode="0"><![CDATA[]]></sccode>
            <sccode name="event2" init_power_mode="0"><![CDATA[]]></sccode>
            <sccode name="event3" init_power_mode="0"><![CDATA[]]></sccode>
            <sccode name="execute" init_power_mode="0"><![CDATA[//U16 prueba;
    
    // Paso 1: take the MAX35103 out of reset
    // lo hago inicializando el pin de reset con 1
    
    //gpioSetOutput(25);
    
    // Paso 2: after issuing max3510x_reset(), this function can be used to delay until the chip has completed reset.
    // lo hago leyendo el registro de interrupción con un while para que esperar que salga del state machine in reset
    
    spiCfg(SPI_POL0_PHA1, 4);
    spiBegin(AUXIO_SPI_CSN_MAX35103_CS);
    
    spiTx8bit(INT_ROPCODE);     //0xFE
    spiRx16bit(output.intStatus);
    while ( output.intStatus == MAX3510X_REG_INTERRUPT_STATUS_INVALID){
        spiRx16bit(output.intStatus);
    }
    spiEnd(AUXIO_SPI_CSN_MAX35103_CS);
    
    // Paso 3: configure the MAX3510x according transducer requirements
    //Se manda todos los datos de configuracion en forma continua.
    //Se podria agregar un flag para usar el mismo codigo para actualizar parcialmente los datos
    
    
    //************************************************************************************************************************
    //************************************************************************************************************************
    //cfg.TOF1          = 0x0E10;      //Fecuencia de los sensores, cantidad de pulsos que emite, polaridad y tiempo de carga.
    //cfg.TOF2          = 0xA272;      //Cantidad de hits, numero de hit a partir del que medir, duty para TOF_DIFF
    //cfg.TOF3          = 0x0708;      //Hits de las wave 1 y 2.
    //cfg.TOF4          = 0x090A;      //Hits de las wave 3 y 4.
    //cfg.TOF5          = 0x0B0C;      //Hits de las wave 5 y 6.
    //cfg.TOF6          = 0xFC6F;      //Offsets de los comparadores.
    //cfg.TOF7          = 0xFC6F;      //Offsets de los comparadores.
    //cfg.EVTMG1        = 0x1480;      //Frecuencia de medicion, cantidad de mediciones a promediar y multiplicador. //cada 1 seg
    //cfg.EVTMG2        = 0x7E7F;      //Configuracion de la calibracion.
    //cfg.TOFMeasDelay  = 0x00C8;      //Delay desde que se envia el pulso hasta que se empieza a sensar para recibirlo.
    //************************************************************************************************************************
    //************************************************************************************************************************
    
    spiCfg(SPI_POL0_PHA1, 4);
    spiBegin(AUXIO_SPI_CSN_MAX35103_CS);
    spiTx8bit(TOF1_WOPCODE);        //0x38
    spiTx16bit(cfg.TOF1);           //0x0E10
    spiTx16bit(cfg.TOF2);           //0xA272
    spiTx16bit(cfg.TOF3);
    spiTx16bit(cfg.TOF4);
    spiTx16bit(cfg.TOF5);
    spiTx16bit(cfg.TOF6);
    spiTx16bit(cfg.TOF7);
    spiTx16bit(cfg.EVTMG1);         //0x1480 --- 0001 0100 1000 0000 --- 0001 01001 000000 0 ---
    spiTx16bit(cfg.EVTMG2);         //0x7E7F
    spiTx16bit(cfg.TOFMeasDelay);   //0x00C8 --- 0111 1110 0111 1111 ---
    spiTx16bit(0x0380);             //Calibration and Control
    spiTx16bit(0x0000);             //Real-Time Clock
    spiEnd(AUXIO_SPI_CSN_MAX35103_CS);
    
    //EVTMG1 -> 0xF4FE -->rate TOF Difference Measurement Frequency:8s, rate Temperature Measurement Frequency:64s
    
    //                                    TOF Difference Measurement Frequency              Rate = 0.5s + (TDF[3:0] x 0.5s)
    //                                          TOF Difference Measurements                 Cycles = 1+ TDM[4:0]
    //                                                Temperature Measurement Frequency     Rate = 1.0s + (TMF[3:0] x 1.0s) ---- > TMF MAX: 63
    //                                    1s   10ci   1s
    //0x1480 --- 0001 0100 1000 0000 --- 0001 01001 000000 0 ---
    
    // Paso 4: give the MAX35103 some time to init
    fwDelayUs(9000);
    
    
    //Paso 5 ldo_mode_on, creo que solo se hace si se necesita leer la flash
    //spiCfg(SPI_POL0_PHA1, 4);
    //spiBegin(AUXIO_SPI_CSN_MAX35103_CS);
    //spiTx8bit(MAX3510X_OPCODE_LDO_ON); //0x0C
    //spiEnd(AUXIO_SPI_CSN_MAX35103_CS);
    
    
    // Paso 6 AED Se pasa la configuracion a la memoria flash.
    spiCfg(SPI_POL0_PHA1, 4);
    spiBegin(AUXIO_SPI_CSN_MAX35103_CS);
    spiTx8bit(MAX3510X_OPCODE_FLASH); //0x06
    spiEnd(AUXIO_SPI_CSN_MAX35103_CS);
    
    fwDelayUs(49000);
    
    // Paso 7 AED Initialize Command
    spiCfg(SPI_POL0_PHA1, 4);
    spiBegin(AUXIO_SPI_CSN_MAX35103_CS);
    spiTx8bit(MAX3510X_OPCODE_INITIALIZE); //0x05
    spiEnd(AUXIO_SPI_CSN_MAX35103_CS);
    
    fwDelayUs(49000);
    
    //Lee el Interrupt Status Register.
    spiCfg(SPI_POL0_PHA1, 4);
    //Controlar que se haya pasado la informacion a la memoria flash
    spiBegin(AUXIO_SPI_CSN_MAX35103_CS);
    spiTx8bit(INT_ROPCODE);
    //spiTx8bit(0xc2);
    spiRx16bit(output.intStatus);
    //output.intStatus = prueba;
    spiEnd(AUXIO_SPI_CSN_MAX35103_CS);
    
    
    //AED:Habría que agregar el chequeo de que todo esta como debe ser y confirmarle al micro con un fwGenAlertInterrupt()
    
    //This resource allows the task code running on the Sensor Controller to generate an ALERT callback via the SCIF driver to the application running on the System CPU. If the System CPU is sleeping at that time, it will wake up.
    //Generates an ALERT interrupt to the System CPU application. Generates an ALERT interrupt to the System CPU application.
    fwGenAlertInterrupt(); //Avisa al MCU que termino la tarea.]]></sccode>
            <sccode name="initialize" init_power_mode="0"><![CDATA[]]></sccode>
            <sccode name="terminate" init_power_mode="0"><![CDATA[]]></sccode>
            <event_trigger active_count="1">0,1,2,3</event_trigger>
            <tt_iter>run_execute</tt_iter>
            <tt_struct>output.intStatus</tt_struct>
            <rtl_struct></rtl_struct>
            <rtl_task_sel en="1" struct_log_list="output"/>
        </task>
        <task name="Tapa Monitor">
            <desc><![CDATA[The Sensor Controller samples a single ADC channel and monitor and maintains a bit-vector that indicates whether the ADC value is:
    - Below a configurable low threshold
    - Above a configurable high threshold
    
    The System CPU application is notified when the bit-vector (the monitoring state) changes.]]></desc>
            <tattr name="TAPA_CLOSE_MASK" desc="Bit vector: ADC value is above cfg.adcHighLevel" type="expr_hex" content="const" scope="task" min="0" max="65535">0xFFFE</tattr>
            <tattr name="TAPA_OPEN_MASK" desc="Bit vector: ADC value is above cfg.adcWindowLow" type="expr_hex" content="const" scope="task" min="0" max="65535">0x0001</tattr>
            <tattr name="cfg.adcHighLevel" desc="Window low voltage" type="expr" content="struct" scope="task" min="0" max="65535">0</tattr>
            <tattr name="cfg.adcLowLevel" desc="Window high ADC value" type="expr" content="struct" scope="task" min="0" max="65535">0</tattr>
            <tattr name="output.adcValue" desc="Last ADC value" type="dec" content="struct" scope="task" min="0" max="65535">0</tattr>
            <tattr name="output.intStatus" desc="Bit 0 indicates low, bit 1 indicates high" type="expr" content="struct" scope="task" min="0" max="65535">0</tattr>
            <tattr name="state.tapaStatus" desc="Estado de la tapa" type="expr" content="struct" scope="task" min="0" max="65535">0</tattr>
            <resource_ref name="ADC" enabled="1"/>
            <resource_ref name="AON Domain Functionality" enabled="0"/>
            <resource_ref name="Accumulator-Based Math" enabled="0"/>
            <resource_ref name="Analog Open-Drain Pins" enabled="0"/>
            <resource_ref name="Analog Open-Source Pins" enabled="0"/>
            <resource_ref name="Analog Pins" enabled="1">
                <io_usage name="SENSOR_OUTPUT" label="Sensor output">
                    <uattr name="Pin count">0</uattr>
                    <uattr name="Pin/0000">DIO26</uattr>
                    <uattr name="Pin/0001"></uattr>
                    <uattr name="Pin/0002"></uattr>
                    <uattr name="Pin/0003"></uattr>
                    <uattr name="Pin/0004"></uattr>
                    <uattr name="Pin/0005"></uattr>
                    <uattr name="Pin/0006"></uattr>
                    <uattr name="Pin/0007"></uattr>
                </io_usage>
            </resource_ref>
            <resource_ref name="COMPA" enabled="0"/>
            <resource_ref name="COMPA Event Trigger" enabled="0"/>
            <resource_ref name="COMPB" enabled="0"/>
            <resource_ref name="COMPB Event Trigger" enabled="0"/>
            <resource_ref name="Delay Insertion" enabled="1"/>
            <resource_ref name="Differential Output Pins" enabled="0"/>
            <resource_ref name="Digital Input Pins" enabled="0"/>
            <resource_ref name="Digital Open-Drain Pins" enabled="0"/>
            <resource_ref name="Digital Open-Source Pins" enabled="0"/>
            <resource_ref name="Digital Output Pins" enabled="1">
                <io_usage name="SENSOR_SUPPLY" label="Levanta el pin para estar en 3V3">
                    <uattr name="Configuration on uninitialization">-1</uattr>
                    <uattr name="Output drive strength">0</uattr>
                    <uattr name="Output value on initialization">0</uattr>
                    <uattr name="Pin count">0</uattr>
                    <uattr name="Pin/0000">DIO27</uattr>
                    <uattr name="Pin/0001"></uattr>
                    <uattr name="Pin/0002"></uattr>
                    <uattr name="Pin/0003"></uattr>
                    <uattr name="Pin/0004"></uattr>
                    <uattr name="Pin/0005"></uattr>
                    <uattr name="Pin/0006"></uattr>
                    <uattr name="Pin/0007"></uattr>
                    <uattr name="Pin/0008"></uattr>
                    <uattr name="Pin/0009"></uattr>
                    <uattr name="Pin/0010"></uattr>
                    <uattr name="Pin/0011"></uattr>
                    <uattr name="Pin/0012"></uattr>
                    <uattr name="Pin/0013"></uattr>
                    <uattr name="Pin/0014"></uattr>
                    <uattr name="Pin/0015"></uattr>
                    <uattr name="Pin/0016"></uattr>
                    <uattr name="Pin/0017"></uattr>
                    <uattr name="Pin/0018"></uattr>
                    <uattr name="Pin/0019"></uattr>
                    <uattr name="Pin/0020"></uattr>
                    <uattr name="Pin/0021"></uattr>
                    <uattr name="Pin/0022"></uattr>
                    <uattr name="Pin/0023"></uattr>
                    <uattr name="Pin/0024"></uattr>
                    <uattr name="Pin/0025"></uattr>
                    <uattr name="Pin/0026"></uattr>
                    <uattr name="Pin/0027"></uattr>
                    <uattr name="Pin/0028"></uattr>
                    <uattr name="Pin/0029"></uattr>
                    <uattr name="Pin/0030"></uattr>
                    <uattr name="Pin/0031"></uattr>
                </io_usage>
            </resource_ref>
            <resource_ref name="Dynamic Power Control" enabled="0"/>
            <resource_ref name="GPIO Event Trigger" enabled="0"/>
            <resource_ref name="I2C Master" enabled="0">
                <rattr name="SCL frequency">0</rattr>
                <rattr name="SCL stretch timeout">1</rattr>
                <io_usage>
                    <uattr name="Output drive strength">1</uattr>
                    <uattr name="SCL pin/0000"></uattr>
                    <uattr name="SDA pin/0000"></uattr>
                </io_usage>
            </resource_ref>
            <resource_ref name="ISRC" enabled="0"/>
            <resource_ref name="LCD Controller" enabled="0">
                <rattr name="Waveform state count">8</rattr>
                <io_usage>
                    <uattr name="Output drive strength">0</uattr>
                    <uattr name="Pin count">20</uattr>
                    <uattr name="Pin/0000"></uattr>
                    <uattr name="Pin/0001"></uattr>
                    <uattr name="Pin/0002"></uattr>
                    <uattr name="Pin/0003"></uattr>
                    <uattr name="Pin/0004"></uattr>
                    <uattr name="Pin/0005"></uattr>
                    <uattr name="Pin/0006"></uattr>
                    <uattr name="Pin/0007"></uattr>
                    <uattr name="Pin/0008"></uattr>
                    <uattr name="Pin/0009"></uattr>
                    <uattr name="Pin/0010"></uattr>
                    <uattr name="Pin/0011"></uattr>
                    <uattr name="Pin/0012"></uattr>
                    <uattr name="Pin/0013"></uattr>
                    <uattr name="Pin/0014"></uattr>
                    <uattr name="Pin/0015"></uattr>
                    <uattr name="Pin/0016"></uattr>
                    <uattr name="Pin/0017"></uattr>
                    <uattr name="Pin/0018"></uattr>
                    <uattr name="Pin/0019"></uattr>
                    <uattr name="Pin/0020"></uattr>
                    <uattr name="Pin/0021"></uattr>
                    <uattr name="Pin/0022"></uattr>
                    <uattr name="Pin/0023"></uattr>
                    <uattr name="Pin/0024"></uattr>
                    <uattr name="Pin/0025"></uattr>
                    <uattr name="Pin/0026"></uattr>
                    <uattr name="Pin/0027"></uattr>
                    <uattr name="Pin/0028"></uattr>
                    <uattr name="Pin/0029"></uattr>
                    <uattr name="Pin/0030"></uattr>
                    <uattr name="Pin/0031"></uattr>
                </io_usage>
            </resource_ref>
            <resource_ref name="Math and Logic" enabled="0"/>
            <resource_ref name="Multi-Buffered Output Data Exchange" enabled="0">
                <rattr name="Buffer count">2</rattr>
                <rattr name="Indicate overflow at buffer check">1</rattr>
                <rattr name="Indicate overflow at buffer switch">0</rattr>
                <rattr name="Prevent overflow at buffer switch">1</rattr>
            </resource_ref>
            <resource_ref name="Peripheral Sharing" enabled="0"/>
            <resource_ref name="Pulse Counter" enabled="0"/>
            <resource_ref name="RTC Multi-Event Capture" enabled="0"/>
            <resource_ref name="RTC-Based Execution Scheduling" enabled="1"/>
            <resource_ref name="Reference DAC" enabled="0"/>
            <resource_ref name="Run-Time Logging" enabled="1"/>
            <resource_ref name="SPI Chip Select" enabled="0"/>
            <resource_ref name="SPI Data Transfer" enabled="0">
                <rattr name="Bit rate">0</rattr>
                <rattr name="MISO configuration when inactive">-1</rattr>
                <rattr name="MOSI configuration on initialization">0</rattr>
                <rattr name="MOSI configuration on uninitialization">0</rattr>
                <rattr name="SCLK configuration on initialization">0</rattr>
                <rattr name="SCLK configuration on uninitialization">0</rattr>
                <io_usage>
                    <uattr name="MISO pin/0000"></uattr>
                    <uattr name="MOSI pin/0000"></uattr>
                    <uattr name="SCLK pin/0000"></uattr>
                </io_usage>
            </resource_ref>
            <resource_ref name="Signal Observation" enabled="0"/>
            <resource_ref name="System CPU Alert" enabled="1"/>
            <resource_ref name="System Event Trigger" enabled="0"/>
            <resource_ref name="TDC" enabled="0"/>
            <resource_ref name="Timer 0" enabled="0"/>
            <resource_ref name="Timer 0 Event Trigger" enabled="0"/>
            <resource_ref name="Timer 1" enabled="0"/>
            <resource_ref name="Timer 1 Event Trigger" enabled="0"/>
            <resource_ref name="Timer 2" enabled="0"/>
            <resource_ref name="Timer 2 Event Trigger" enabled="0"/>
            <resource_ref name="UART Emulator" enabled="0">
                <rattr name="RX buffer size">64</rattr>
                <rattr name="Required idle period before enabling RX">11</rattr>
                <rattr name="TX buffer size">64</rattr>
                <io_usage>
                    <uattr name="RX pin/0000"></uattr>
                    <uattr name="TX pin/0000"></uattr>
                </io_usage>
            </resource_ref>
            <sccode name="event0" init_power_mode="0"><![CDATA[]]></sccode>
            <sccode name="event1" init_power_mode="0"><![CDATA[]]></sccode>
            <sccode name="event2" init_power_mode="0"><![CDATA[]]></sccode>
            <sccode name="event3" init_power_mode="0"><![CDATA[]]></sccode>
            <sccode name="execute" init_power_mode="0"><![CDATA[// Set SENSOR SUPPLY Pin
    gpioSetOutput(AUXIO_O_SENSOR_SUPPLY);
    
    // Enable the ADC
    adcEnableSync(ADC_REF_FIXED, ADC_SAMPLE_TIME_2P7_US, ADC_TRIGGER_MANUAL);
    
    // launchxl-cc26x2r1-sensor-control-can-t-run-for-more-than-5-minutes
    fwDelayUs(1);
    
    
    // Sample the sensor
    U16 adcValue;
    adcGenManualTrigger();
    adcReadFifo(adcValue);
    output.adcValue = adcValue;
    
    //cfg.adcHighLevel    = 2000;
    //cfg.adcLowLevel     = 1500;
    
    
    // Disable the ADC
    adcDisable();
    
    // Clear SENSOR SUPPLY Pin
    gpioClearOutput(AUXIO_O_SENSOR_SUPPLY);
    
    // Determine if the ADC value is below the low threshold or above the high threshold
    if (state.tapaStatus == 0){
        if (adcValue < cfg.adcLowLevel){
            state.tapaStatus = 1;
            output.intStatus = output.intStatus | TAPA_OPEN_MASK;
            fwGenAlertInterrupt();
        }
    } else {
        if(adcValue > cfg.adcHighLevel){
            state.tapaStatus = 0;
            output.intStatus = output.intStatus & TAPA_CLOSE_MASK;
            fwGenAlertInterrupt();
        }
    }
    
    //Every time the Sensor Controller wakes up it will check if a task is scheduled to run its execution code.
    //If the previously run Sensor Controller code scheduled an execution with argument 1:
    
    // Schedule execution at the next Sensor Controller RTC scheduled wakeup
    // in other words the task is scheduled to run for every tick
    fwScheduleTask(1);]]></sccode>
            <sccode name="initialize" init_power_mode="0"><![CDATA[// Select ADC input
    adcSelectGpioInput(AUXIO_A_SENSOR_OUTPUT);
    
    // Clear SENSOR SUPPLY Pin
    gpioClearOutput(AUXIO_O_SENSOR_SUPPLY);
    
    // Schedule the first execution
    fwScheduleTask(1);]]></sccode>
            <sccode name="terminate" init_power_mode="0"><![CDATA[]]></sccode>
            <event_trigger active_count="1">0,1,2,3</event_trigger>
            <tt_iter>run_execute</tt_iter>
            <tt_struct>output.adcValue,output.intStatus,state.tapaStatus</tt_struct>
            <rtl_struct>output.adcValue,output.bvWindowState</rtl_struct>
            <rtl_task_sel en="1" struct_log_list="output"/>
            <rtl_cfg_slider name="High threshold" struct_member="cfg.adcLowLevel" min="0" max="800" value="560"><![CDATA[value = slider;]]></rtl_cfg_slider>
            <rtl_cfg_slider name="Low threshold" struct_member="cfg.adcHighLevel" min="0" max="800" value="460"><![CDATA[value = slider;]]></rtl_cfg_slider>
        </task>
        <task name="Hall Effect Sensor">
            <desc><![CDATA[Monitors the DRV5032FB hall effect sensor on the LaunchPad SensorTag Kit (LPSTK), and detects changes from the initial state that last longer than a configurable duration.
    
    For ease of use, the normal state is the same as the initial state:
    - If the magnet is missing at startup, the task will alert the application when the magnet has been present continuously for more than a configurable duration (cfg.alertTimeoutMs).
    - If the magnet is present at startup, the task will alert the application when the magnet has been missing continuously for more than a configurable duration (cfg.alertTimeoutMs).
    
    Note that the hall effect sensor is only sensitive to a magnetic field along one axis.
    
    The task uses a GPIO Event Trigger to detect sensor output changes, and Timer 1 Event Trigger to generate timeout when the output is in the alert state.]]></desc>
            <tattr name="cfg.alertTimeoutMs" desc="Alert timeout in milliseconds" type="expr" content="struct" scope="task" min="0" max="65535">1000</tattr>
            <tattr name="output.alertTimeoutCount" desc="Number of alert timeouts that have occurred" type="expr" content="struct" scope="task" min="0" max="65535">0</tattr>
            <tattr name="output.detectMagnetMissing" desc="0 when detecting present magnet, 1 when detecting missing magnet" type="expr" content="struct" scope="task" min="0" max="65535">0</tattr>
            <tattr name="state.alertOnMagnetMissing" desc="0 to generate alert on present magnet, 1 to generate alert on missing magnet" type="expr" content="struct" scope="task" min="0" max="65535">0</tattr>
            <resource_ref name="ADC" enabled="0"/>
            <resource_ref name="AON Domain Functionality" enabled="0"/>
            <resource_ref name="Accumulator-Based Math" enabled="0"/>
            <resource_ref name="Analog Open-Drain Pins" enabled="0"/>
            <resource_ref name="Analog Open-Source Pins" enabled="0"/>
            <resource_ref name="Analog Pins" enabled="0"/>
            <resource_ref name="COMPA" enabled="0"/>
            <resource_ref name="COMPA Event Trigger" enabled="0"/>
            <resource_ref name="COMPB" enabled="0"/>
            <resource_ref name="COMPB Event Trigger" enabled="0"/>
            <resource_ref name="Delay Insertion" enabled="1"/>
            <resource_ref name="Differential Output Pins" enabled="0"/>
            <resource_ref name="Digital Input Pins" enabled="1">
                <io_usage name="HALL_OUT" label="Hall effect sensor output">
                    <uattr name="Configuration on initialization">1</uattr>
                    <uattr name="Configuration on uninitialization">1</uattr>
                    <uattr name="Pin count">0</uattr>
                    <uattr name="Pin/0000">DIO19</uattr>
                    <uattr name="Pin/0001"></uattr>
                    <uattr name="Pin/0002"></uattr>
                    <uattr name="Pin/0003"></uattr>
                    <uattr name="Pin/0004"></uattr>
                    <uattr name="Pin/0005"></uattr>
                    <uattr name="Pin/0006"></uattr>
                    <uattr name="Pin/0007"></uattr>
                    <uattr name="Pin/0008"></uattr>
                    <uattr name="Pin/0009"></uattr>
                    <uattr name="Pin/0010"></uattr>
                    <uattr name="Pin/0011"></uattr>
                    <uattr name="Pin/0012"></uattr>
                    <uattr name="Pin/0013"></uattr>
                    <uattr name="Pin/0014"></uattr>
                    <uattr name="Pin/0015"></uattr>
                    <uattr name="Pin/0016"></uattr>
                    <uattr name="Pin/0017"></uattr>
                    <uattr name="Pin/0018"></uattr>
                    <uattr name="Pin/0019"></uattr>
                    <uattr name="Pin/0020"></uattr>
                    <uattr name="Pin/0021"></uattr>
                    <uattr name="Pin/0022"></uattr>
                    <uattr name="Pin/0023"></uattr>
                    <uattr name="Pin/0024"></uattr>
                    <uattr name="Pin/0025"></uattr>
                    <uattr name="Pin/0026"></uattr>
                    <uattr name="Pin/0027"></uattr>
                    <uattr name="Pin/0028"></uattr>
                    <uattr name="Pin/0029"></uattr>
                    <uattr name="Pin/0030"></uattr>
                    <uattr name="Pin/0031"></uattr>
                </io_usage>
            </resource_ref>
            <resource_ref name="Digital Open-Drain Pins" enabled="0"/>
            <resource_ref name="Digital Open-Source Pins" enabled="0"/>
            <resource_ref name="Digital Output Pins" enabled="1">
                <io_usage name="HALL_SUPPLY" label="Hall sensor supply">
                    <uattr name="Configuration on uninitialization">-1</uattr>
                    <uattr name="Output drive strength">0</uattr>
                    <uattr name="Output value on initialization">0</uattr>
                    <uattr name="Pin count">0</uattr>
                    <uattr name="Pin/0000">DIO25</uattr>
                    <uattr name="Pin/0001"></uattr>
                    <uattr name="Pin/0002"></uattr>
                    <uattr name="Pin/0003"></uattr>
                    <uattr name="Pin/0004"></uattr>
                    <uattr name="Pin/0005"></uattr>
                    <uattr name="Pin/0006"></uattr>
                    <uattr name="Pin/0007"></uattr>
                    <uattr name="Pin/0008"></uattr>
                    <uattr name="Pin/0009"></uattr>
                    <uattr name="Pin/0010"></uattr>
                    <uattr name="Pin/0011"></uattr>
                    <uattr name="Pin/0012"></uattr>
                    <uattr name="Pin/0013"></uattr>
                    <uattr name="Pin/0014"></uattr>
                    <uattr name="Pin/0015"></uattr>
                    <uattr name="Pin/0016"></uattr>
                    <uattr name="Pin/0017"></uattr>
                    <uattr name="Pin/0018"></uattr>
                    <uattr name="Pin/0019"></uattr>
                    <uattr name="Pin/0020"></uattr>
                    <uattr name="Pin/0021"></uattr>
                    <uattr name="Pin/0022"></uattr>
                    <uattr name="Pin/0023"></uattr>
                    <uattr name="Pin/0024"></uattr>
                    <uattr name="Pin/0025"></uattr>
                    <uattr name="Pin/0026"></uattr>
                    <uattr name="Pin/0027"></uattr>
                    <uattr name="Pin/0028"></uattr>
                    <uattr name="Pin/0029"></uattr>
                    <uattr name="Pin/0030"></uattr>
                    <uattr name="Pin/0031"></uattr>
                </io_usage>
            </resource_ref>
            <resource_ref name="Dynamic Power Control" enabled="0"/>
            <resource_ref name="GPIO Event Trigger" enabled="1"/>
            <resource_ref name="I2C Master" enabled="0">
                <rattr name="SCL frequency">400</rattr>
                <rattr name="SCL stretch timeout">1</rattr>
                <io_usage>
                    <uattr name="Output drive strength">1</uattr>
                    <uattr name="SCL pin/0000"></uattr>
                    <uattr name="SDA pin/0000"></uattr>
                </io_usage>
            </resource_ref>
            <resource_ref name="ISRC" enabled="0"/>
            <resource_ref name="LCD Controller" enabled="0">
                <rattr name="Waveform state count">8</rattr>
                <io_usage>
                    <uattr name="Output drive strength">0</uattr>
                    <uattr name="Pin count">20</uattr>
                    <uattr name="Pin/0000"></uattr>
                    <uattr name="Pin/0001"></uattr>
                    <uattr name="Pin/0002"></uattr>
                    <uattr name="Pin/0003"></uattr>
                    <uattr name="Pin/0004"></uattr>
                    <uattr name="Pin/0005"></uattr>
                    <uattr name="Pin/0006"></uattr>
                    <uattr name="Pin/0007"></uattr>
                    <uattr name="Pin/0008"></uattr>
                    <uattr name="Pin/0009"></uattr>
                    <uattr name="Pin/0010"></uattr>
                    <uattr name="Pin/0011"></uattr>
                    <uattr name="Pin/0012"></uattr>
                    <uattr name="Pin/0013"></uattr>
                    <uattr name="Pin/0014"></uattr>
                    <uattr name="Pin/0015"></uattr>
                    <uattr name="Pin/0016"></uattr>
                    <uattr name="Pin/0017"></uattr>
                    <uattr name="Pin/0018"></uattr>
                    <uattr name="Pin/0019"></uattr>
                    <uattr name="Pin/0020"></uattr>
                    <uattr name="Pin/0021"></uattr>
                    <uattr name="Pin/0022"></uattr>
                    <uattr name="Pin/0023"></uattr>
                    <uattr name="Pin/0024"></uattr>
                    <uattr name="Pin/0025"></uattr>
                    <uattr name="Pin/0026"></uattr>
                    <uattr name="Pin/0027"></uattr>
                    <uattr name="Pin/0028"></uattr>
                    <uattr name="Pin/0029"></uattr>
                    <uattr name="Pin/0030"></uattr>
                    <uattr name="Pin/0031"></uattr>
                </io_usage>
            </resource_ref>
            <resource_ref name="Math and Logic" enabled="0"/>
            <resource_ref name="Multi-Buffered Output Data Exchange" enabled="0">
                <rattr name="Buffer count">2</rattr>
                <rattr name="Indicate overflow at buffer check">1</rattr>
                <rattr name="Indicate overflow at buffer switch">0</rattr>
                <rattr name="Prevent overflow at buffer switch">1</rattr>
            </resource_ref>
            <resource_ref name="Peripheral Sharing" enabled="0"/>
            <resource_ref name="Pulse Counter" enabled="0"/>
            <resource_ref name="RTC Multi-Event Capture" enabled="0"/>
            <resource_ref name="RTC-Based Execution Scheduling" enabled="1"/>
            <resource_ref name="Reference DAC" enabled="0"/>
            <resource_ref name="Run-Time Logging" enabled="1"/>
            <resource_ref name="SPI Chip Select" enabled="0"/>
            <resource_ref name="SPI Data Transfer" enabled="0">
                <rattr name="Bit rate">0</rattr>
                <rattr name="MISO configuration when inactive">-1</rattr>
                <rattr name="MOSI configuration on initialization">0</rattr>
                <rattr name="MOSI configuration on uninitialization">0</rattr>
                <rattr name="SCLK configuration on initialization">0</rattr>
                <rattr name="SCLK configuration on uninitialization">0</rattr>
                <io_usage>
                    <uattr name="MISO pin/0000"></uattr>
                    <uattr name="MOSI pin/0000"></uattr>
                    <uattr name="SCLK pin/0000"></uattr>
                </io_usage>
            </resource_ref>
            <resource_ref name="Signal Observation" enabled="0"/>
            <resource_ref name="System CPU Alert" enabled="1"/>
            <resource_ref name="System Event Trigger" enabled="0"/>
            <resource_ref name="TDC" enabled="0"/>
            <resource_ref name="Timer 0" enabled="0"/>
            <resource_ref name="Timer 0 Event Trigger" enabled="0"/>
            <resource_ref name="Timer 1" enabled="0"/>
            <resource_ref name="Timer 1 Event Trigger" enabled="1"/>
            <resource_ref name="Timer 2" enabled="0"/>
            <resource_ref name="Timer 2 Event Trigger" enabled="0"/>
            <resource_ref name="UART Emulator" enabled="0">
                <rattr name="RX buffer size">64</rattr>
                <rattr name="Required idle period before enabling RX">11</rattr>
                <rattr name="TX buffer size">64</rattr>
                <io_usage>
                    <uattr name="RX pin/0000"></uattr>
                    <uattr name="TX pin/0000"></uattr>
                </io_usage>
            </resource_ref>
            <sccode name="event0" init_power_mode="0"><![CDATA[// If the hall effect sensor output has changed state ...
    U16 bvEventTrigger;
    evhGetActiveTrigger(bvEventTrigger);
    if (bvEventTrigger == 0x01) {
    
        // The hall effect sensor output changed state
        U16 isMagnetMissing = output.detectMagnetMissing;
        if (isMagnetMissing == 1) {
            output.detectMagnetMissing = 0;
            evhSetupGpioTrigger(0, AUXIO_I_HALL_OUT, 0, EVH_GPIO_TRIG_ON_MATCH);
        } else {
            output.detectMagnetMissing = 1;
            evhSetupGpioTrigger(0, AUXIO_I_HALL_OUT, 1, EVH_GPIO_TRIG_ON_MATCH);
        }
    
        // If in the alert state ...
        if (isMagnetMissing == state.alertOnMagnetMissing) {
    
            // Start the timeout. The alert will be generated if the timeout expires.
            evhSetupTimer1Trigger(1, cfg.alertTimeoutMs, 2);
    
        // Otherwise ...
        } else {
    
            // Cancel the timeout
            evhCancelTrigger(1);
        }
    
    // Otherwise the alert timeout has occurred ...
    } else {
    
        // Alert the application!
        fwGenAlertInterrupt();
        output.alertTimeoutCount += 1;
    }
    
    // Log the output data structure
    rtlLogStructs(BV_RTL_LOG_OUTPUT);]]></sccode>
            <sccode name="event1" init_power_mode="0"><![CDATA[]]></sccode>
            <sccode name="event2" init_power_mode="0"><![CDATA[]]></sccode>
            <sccode name="event3" init_power_mode="0"><![CDATA[]]></sccode>
            <sccode name="execute" init_power_mode="0"><![CDATA[]]></sccode>
            <sccode name="initialize" init_power_mode="0"><![CDATA[// Find whether the magnet is present or missing now
    U16 isMagnetMissing;
    gpioGetInputValue(AUXIO_I_HALL_OUT; isMagnetMissing);
    
    // For ease of use, the normal condition is the condition at startup. Find the normal condition:
    // - If the magnet is missing now, the application shall be alerted when the magnet is present
    // - If the magnet is present now, the application shall be alerted when the magnet is missing
    if (isMagnetMissing == 1) {
        output.detectMagnetMissing = 0;
        state.alertOnMagnetMissing = 0;
        evhSetupGpioTrigger(0, AUXIO_I_HALL_OUT, 0, EVH_GPIO_TRIG_ON_MATCH);
    } else {
        output.detectMagnetMissing = 1;
        state.alertOnMagnetMissing = 1;
        evhSetupGpioTrigger(0, AUXIO_I_HALL_OUT, 1, EVH_GPIO_TRIG_ON_MATCH);
    }
    
    // Clear SENSOR SUPPLY Pin
    gpioClearOutput(AUXIO_O_HALL_SUPPLY);
    
    
    gpioSetOutput(AUXIO_O_HALL_SUPPLY);
    
    
    // Log the state data structure
    rtlLogStructs(BV_RTL_LOG_STATE);]]></sccode>
            <sccode name="terminate" init_power_mode="0"><![CDATA[// Cancel any active event triggers
    evhCancelTrigger(0);
    evhCancelTrigger(1);]]></sccode>
            <event_trigger active_count="2">0,0,2,3</event_trigger>
            <tt_iter>if_event0trigset_start,run_event0,if_event0trigset_end,if_event1trigset_start,run_event1,if_event1trigset_end</tt_iter>
            <tt_struct>output.alertTimeoutCount,output.detectMagnetMissing</tt_struct>
            <rtl_struct>output.alertTimeoutCount,output.detectMagnetMissing,state.alertOnMagnetMissing</rtl_struct>
            <rtl_task_sel en="1" struct_log_list="output,state"/>
        </task>
    </project>
    

    Thanks in advance

    Andrés

  • Hi Andres,

    Sorry for the very delayed response but we are very limited in term of support bandwidth in the month of July. I will give you an answer by tomorrow. Have you had any development regarding this issue in the meantime?

    Regards,

    Fausto

  • Hi Fausto,

    I found a partial solution that it is merging those 2 tasks.

    Regards

  • Thank you for your update. I will close the thread then. Fell free to post any other relevant question to re-open it in the future.

    Regards,

    Fausto