Other Parts Discussed in Thread: CC2650, SYSBIOS, BLE-STACK
Tool/software: Code Composer Studio
Hello,
I have been working on CC2650Moda and trying to use GPIO pins to turn ON/OFF the leds off-board. The example I am working with is in Code Composer Studio, TI-RTOS CC2650 Launchpad. And the GPIO-write(pin,on/off) is not working. Also, I enabled the pin using this command:
const PIN_Config BoardGpioInitTable[] = {
IOID_6 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MAX,
I am not sure what is the reason that I cannot control leds with GPIO-write command and I would appreciate if someone help me to how to turn ON/OFF off-board leds.
Thanks in advance for your time,
Farinaz
This is the pwm code that I am using:
* ======== pwmled.c ========
*/
/* XDCtools Header files */
#include <xdc/std.h>
#include <xdc/runtime/System.h>
/* BIOS Header files */
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Task.h>
/* TI-RTOS Header files */
#include <ti/drivers/GPIO.h>
#include <ti/drivers/PWM.h>
/* Example/Board Header files */
#include "Board.h"
#include <ti/drivers/GPIO.h> // has been added this line
#define TASKSTACKSIZE 512
#include "driverlib/gpio.h" // has been added this line
Task_Struct tsk0Struct;
UInt16 tsk0Stack[TASKSTACKSIZE];
Task_Handle task;
/*
* ======== pwmLEDFxn ========
* Task periodically increments the PWM duty for the on board LED.
*/
Void pwmLEDFxn(UArg arg0, UArg arg1, UArg arg2, UArg arg3)
{
PWM_Handle pwm1;
PWM_Handle pwm2;
PWM_Handle pwm3;
PWM_Handle pwm4;
PWM_Handle pwm5;
PWM_Params params;
uint16_t pwmPeriod = 30000; // Period and duty in microseconds
uint16_t duty = 80;
uint16_t dutyInc = 10;
PWM_Params_init(¶ms);
params.dutyUnits = PWM_DUTY_US;
params.dutyValue = 0;
params.periodUnits = PWM_PERIOD_US;
params.periodValue = pwmPeriod;
pwm1 = PWM_open(Board_PWM0, ¶ms);
pwm2 = PWM_open(Board_PWM1, ¶ms);
pwm3 = PWM_open(Board_PWM2, ¶ms);
pwm4 = PWM_open(Board_PWM3, ¶ms);
pwm5 = PWM_open(Board_PWM4, ¶ms);
if (pwm1 == NULL) {
System_abort("Board_PWM0 did not open");
}
PWM_start(pwm1);
PWM_start(pwm2);
PWM_start(pwm3);
PWM_start(pwm4);
PWM_start(pwm5);
/* Loop forever incrementing the PWM duty */
while (1) {
PWM_setDuty(pwm1, duty);
PWM_setDuty(pwm2, duty);
PWM_setDuty(pwm3, duty);
PWM_setDuty(pwm4, duty);
PWM_setDuty(pwm5, duty);
duty = (duty + dutyInc);
if (duty == pwmPeriod || (!duty)) {
dutyInc = - dutyInc;
}
Task_sleep((UInt) arg0);
}
}
/*======== main ========*/
int main(void)
{
Task_Params tskParams;
/* Call board init functions.*/
Board_initGeneral();
Board_initGPIO();
Board_initPWM();
/*Construct LED Task thread*/
Task_Params_init(&tskParams);
tskParams.stackSize = TASKSTACKSIZE;
tskParams.stack = &tsk0Stack;
tskParams.arg0 = 50;
Task_construct(&tsk0Struct, (Task_FuncPtr)pwmLEDFxn, &tskParams, NULL);
/* Obtain instance handle*/
task = Task_handle(&tsk0Struct);
/* Turn on user LED*/
GPIO_write(IOID_6, 1);
GPIO_write(IOID_3, 0;
GPIO_write(IOID_5, 1);
//System_printf("Starting the example\nSystem provider is set to SysMin. "
// "Halt the target to view any SysMin contents in ROV.\n");
/*SysMin will only print to the console when you call flush or exit*/
System_flush();
/* Start BIOS*/
BIOS_start();
return (0);
}