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.

CCS/CC1310: Problem in the PIN interrupt callback register

Part Number: CC1310


Tool/software: Code Composer Studio

Good morning,

I'm having a problem during the PIN initialization of the CC1310 device. in particular I want to configure a couple of pin as interupt and I'm using the LaunchPad board for test before moving on my target.

In particular if I call directly this function:

void vPinInit(void)
{
    PIN_Handle tLocalPinHandle = NULL;
    PIN_State tLocalPinState;
    /* open button pin */
    tLocalPinHandle = PIN_open(&tLocalPinState, tEncoderPinTable);
    if (!tLocalPinHandle)
    {
        // System_abort("Error initializing button pins\n");
    }
    /* setup callback for button pins */
    if (PIN_registerIntCb(tLocalPinHandle, &vEncoderCallback) != 0)
    {
        // System_abort("Error registering button callback function");
    }
    return;
}

/* vEncoderCallback */
static void vEncoderCallback(PIN_Handle tPinHandle, PIN_Id tPinId)
{
    /* AS_TBD u32Counter counts the number of interrupt, used during the debug phase */
    static uint32_t u32Counter = 0;

    u32Counter++;
    return;
}

I haven't any problem, I can see the callback function working correctly.

Then I would like modify the code introducing a small layer of software in order to have a better organization of the code, so I have the new function eEncoderInit:

/* eEncoderInit */
void eEncoderInit(void)
{
    vPinInit();
    return;
}

which calls exactly the same vPinInit I copied before. Nothing else changes, but I can see that the callback function is nevere executed and I think that the code loses its right order of operations.

I have verified that debugging the code, the function:

PIN_swi

is correctly executed, but when the function

callbackFxn(handle, eventCounter);

is called, something is not correct. I have also verified that during the register callback, the table:

pinHandleTable[eventCounter]

is initilialized well, but when the first interrupt is deteceted, the element of the table corresponding to my pin is not correct anymore: it seems that something corrupts it.

Have you got an idea about this behaviour? Ia tell you that I have tried to increment the stack size but nothing changes.

Thanks in advance, Andrea.

 

 

  • Hi Andrea,

    When posting code onto the forum, please use the code formatting tool marked by the </> button. This allows the code to be easily read and can help you get support faster on the forums. I've modified your previous post to reflect the use of the tool.

    Could you show me tEncoderPinTable? Also, you should allocate the tLocalPinState statically, either as a global variable or as a static variable in the vPinInit() function.
  • Hi Edvard,

    thank you very much for your answer, I solved the problem declaring tLocalPinState global.

    Excuse me also if I didn't used the </> button for the code, I'll do in the next post.

    Thanks again, Andrea.