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/CC2650: Button interrupt task with Simple peripheral.

Part Number: CC2650
Other Parts Discussed in Thread: CC1350

Tool/software: Code Composer Studio

Hello Team,

I have make a task which can work with simple peripheral example but its not working please help me where I am wrong. In this task my aim to work on GPIO interrput and blink LED. Source and header files are below.

Source (.c ) file:-

#include "Board.h"
#include <ti/sysbios/knl/Semaphore.h>
#include <ti/sysbios/knl/Task.h>
#include <ti/sysbios/knl/Clock.h>
#include <ti/sysbios/family/arm/m3/Hwi.h>
#include <ti/drivers/Power.h>
#include <ti/sysbios/BIOS.h>
#include <ti/drivers/power/PowerCC26XX.h>
#include <ti/drivers/PIN/PINCC26XX.h>
#include <ti/drivers/UART.h>
#include <xdc/std.h>
#include <xdc/runtime/System.h>
#include <ti/sysbios/knl/Event.h>
#include <driverlib/aux_wuc.h>
#include <inc/hw_aux_evctl.h>
#include "util.h"
#include "hci_tl.h"
#include "gatt.h"
#include "linkdb.h"
#include "gapgattserver.h"
#include "gattservapp.h"
#include "devinfoservice.h"
#include "simple_gatt_profile.h"
#include "copy.h"

/* TI-RTOS Header files */
#include <ti/drivers/PIN.h>


/**********************Macros**********************************/
#define TASK_STACK_SIZE                 512
#define TASK_PRI                        2
/**************************************************************/

/***********************Global variables****************************/
//copyParams   params;
uint8_t Count = 0;

/*Clock Variables*/
Clock_Struct clk0Struct;
Clock_Handle clk2Handle;

// Clock instances for internal periodic events.
static Clock_Struct periodicClock;

char taskStack[TASK_STACK_SIZE];
Task_Struct taskStruct;



/* Pin driver handles */
static PIN_Handle buttonPinHandle;
static PIN_Handle ledPinHandle;

/* Global memory storage for a PIN_Config table */
static PIN_State buttonPinState;
static PIN_State ledPinState;

PIN_Config ledPinTable[] = {
    Board_LED0 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MAX,
    Board_LED1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW  | PIN_PUSHPULL | PIN_DRVSTR_MAX,
    PIN_TERMINATE
};

/*
 * Application button pin configuration table:
 *   - Buttons interrupts are configured to trigger on falling edge.
 */
PIN_Config buttonPinTable[] = {
    Board_BUTTON0  | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_NEGEDGE,
    Board_BUTTON1  | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_NEGEDGE,
    PIN_TERMINATE
};


/****************************************************************/

void buttonCallbackFxn(PIN_Handle handle, PIN_Id pinId) {
    uint32_t currVal = 0;

    /* Debounce logic, only toggle if the button is still pushed (low) */
    CPUdelay(8000*50);
    if (!PIN_getInputValue(pinId)) {
        /* Toggle LED based on the button pressed */
        switch (pinId) {
            case Board_BUTTON0:
                currVal =  PIN_getOutputValue(Board_LED0);
                PIN_setOutputValue(ledPinHandle, Board_LED0, !currVal);
                break;

            case Board_BUTTON1:
                currVal =  PIN_getOutputValue(Board_LED1);
                PIN_setOutputValue(ledPinHandle, Board_LED1, !currVal);
                break;

            default:
                /* Do nothing */
                break;
        }
    }
}


void copy_createTask(void)
{
//Initialize task
  Task_Params params;
  Task_Params_init(&params);
  params.priority = TASK_PRI;
  params.stackSize = TASK_STACK_SIZE;
  params.stack = taskStack;
  Task_construct(&taskStruct, copytaskFxn, &params, NULL);
}


void copytaskFxn(UArg a0, UArg a1)
{  
    //***********************clock****************************
        /* Construct BIOS Objects */
         Clock_Params clkParams;

        /* Call driver init functions */
       // Board_initGeneral();

        Clock_Params_init(&clkParams);
        clkParams.period = 1000000/Clock_tickPeriod;
        clkParams.startFlag = TRUE;
       

        /* Construct a periodic Clock Instance */
        Clock_construct(&clk0Struct, (Clock_FuncPtr)copyIsr,
                        50000/Clock_tickPeriod, &clkParams);

        clkParams.period = 1000000/Clock_tickPeriod;
        clkParams.startFlag = FALSE;

    //**************************************************************
}


void copyIsr(void)
{
    ledPinHandle = PIN_open(&ledPinState, ledPinTable);
      if(!ledPinHandle) {
          System_abort("Error initializing board LED pins\n");
      }

      buttonPinHandle = PIN_open(&buttonPinState, buttonPinTable);
      if(!buttonPinHandle) {
          System_abort("Error initializing button pins\n");
      }

      if (PIN_registerIntCb(buttonPinHandle, &buttonCallbackFxn) != 0) {
                System_abort("Error registering button callback function");
            }

}

Header file:-

copy.h

  • My main loop is below

    int main()
    {
    #if defined( USE_FPGA )
    HWREG(PRCM_BASE + PRCM_O_PDCTL0) &= ~PRCM_PDCTL0_RFC_ON;
    HWREG(PRCM_BASE + PRCM_O_PDCTL1) &= ~PRCM_PDCTL1_RFC_ON;
    #endif // USE_FPGA

    /* Register Application callback to trap asserts raised in the Stack */
    RegisterAssertCback(AssertHandler);

    PIN_init(BoardGpioInitTable);

    #ifdef CC1350_LAUNCHXL
    // Enable 2.4GHz Radio
    radCtrlHandle = PIN_open(&radCtrlState, radCtrlCfg);

    #ifdef POWER_SAVING
    Power_registerNotify(&rFSwitchPowerNotifyObj,
    PowerCC26XX_ENTERING_STANDBY | PowerCC26XX_AWAKE_STANDBY,
    (Power_NotifyFxn) rFSwitchNotifyCb, NULL);
    #endif //POWER_SAVING
    #endif //CC1350_LAUNCHXL

    #if defined( USE_FPGA )
    // set RFC mode to support BLE
    // Note: This must be done before the RF Core is released from reset!
    SET_RFC_BLE_MODE(RFC_MODE_BLE);
    #endif // USE_FPGA

    // Enable iCache prefetching
    VIMSConfigure(VIMS_BASE, TRUE, TRUE);

    // Enable cache
    VIMSModeSet(VIMS_BASE, VIMS_MODE_ENABLED);

    #if !defined( POWER_SAVING ) || defined( USE_FPGA )
    /* Set constraints for Standby, powerdown and idle mode */
    // PowerCC26XX_SB_DISALLOW may be redundant
    Power_setConstraint(PowerCC26XX_SB_DISALLOW);
    Power_setConstraint(PowerCC26XX_IDLE_PD_DISALLOW);
    #endif // POWER_SAVING | USE_FPGA

    /* Initialize ICall module */
    ICall_init();

    /* Start tasks of external images - Priority 5 */
    ICall_createRemoteTasks();

    /* Kick off profile - Priority 3 */
    GAPRole_createTask();

    SimpleBLEPeripheral_createTask();
    copy_createTask();

    /* enable interrupts and start SYS/BIOS */
    BIOS_start();

    return 0;
    }