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.

RTOS/CC1310: Custom board cc1310 , only 1st line of if loop executes after button ISR and the code stops, the code also has semaphore

Part Number: CC1310

Tool/software: TI-RTOS

 while(1)
    {

        Semaphore_pend(semaphore_txTask, BIOS_WAIT_FOREVER);

        if (!txFreqHoppingEnabled & !rxFreqHoppingEnabled) {
                   
processRFState(); //receives the packet RX_ON is preset and RX_OFF set once transmitted if(transmit_flag == 1){ UART_write(uart, "n10\n", 4); rfState = TX_TURN_ON; //transmitting flag is set TX_ON and TX_OFF set once done transmitting processRFState(); transmit_flag = 0; } PIN_Status status = PIN_registerIntCb(buttonPinHandle, &buttonCallbackFxn); UART_write(uart, "no\n", 3); } } } void buttonCallbackFxn(PIN_Handle handle, PIN_Id pinId) { //CPUdelay(8000*50); // UART_write(uart, "inside1112\n", 11); if (!PIN_getInputValue(pinId)) { UART_write(uart, "n9\n", 3); transmit_flag = 1; Semaphore_post(semaphore_txTask); } }

I have this code which receives prints on UART and then transmits and prints the data on UART. This loop is working fine.

I want to implement button press in this where in my code also tests a button connected to mcu , the button functionality also is working and something prints too from the call back function.

Now I want to press the button to turn the mcu on (which works) and receive the data(works) but I have to press the button again and then transmit the data(doesn't work).

Right now the way it works is after button press the mcu receives data, waits for button to be pressed again, after button press goes to ISR prints n9 goes to main loop prints n10 and then it stops.

I am very new to RTOS hence probably missing something in my code. Any input would be very helpful.

Thank you.

  • Hi,
    I am working to find the appropriate expert to help you. I appreciate your patience.

    Regards,
  • Thank you will be waiting for the response.
  • I tried to debug it step by step. The code goes in this loop under PINCC26xx.c and then gives error as below.

  • Can I please get some help on this one. Basically I want to transmit some data after button press. I don't care if the button press is using ISR or just pin toggle.

    Thank you.
  • In my opinion this is not an optimal way to do this. A button push should only have one callback.

    What you can do is to let the callback post an event. Then you can have a state machine with the event as one of the states. Since you know which state the state machine is in at a given time, the next state from a button push is dependent which state you are in when a button is pushed.

    Look through the examples in the SDK, some of them has a state machine and you can take a look at the code.
  • if(butn_flag == true){
    UART_write(uart, "waiting for button press...\n", 28);
    PIN_registerIntCb(buttonPinHandle, &buttonCallbackFxn);
    while(txFreqHoppingEnabled){
    if(button_pressed == true){
    UART_write(uart, "button pressed\n", 15);
    __delay_cycles(80000000);
    PIN_setOutputValue(hPin, Board_LED1, 0);
    rfState = TX_TURN_ON; //transmitting
    processRFState();
    button_pressed = false;
    check_button = true;
    }
    UART_write(uart, "inside tx loop\n", 15);
    if(check_button == true)
    break;
    }
    butn_flag = false;
    }
    UART_write(uart, "outside while loop\n", 19);
    }
    }
    }
    
    
    void buttonCallbackFxn(PIN_Handle handle, PIN_Id pinId) {
    CPUdelay(80000 * 50);
    button_pressed = true;
    }

    Hi TER,

    I somehow got a fix around this issue. This is the fixed snippet of code, if anyone faces similar issues in future.

    Thank you