TI中文支持网
TI专业的中文技术问题搜集分享网站

CC1310 GPIO 配置不输出相应电平?????

1.cc1310 使用SDK版本号为:4.10.01.01

1.参考事件为:gpiointerrupt(TI—RTOS)工程

2.在下面数组中添加自己想输出的IO,为CC1310_LAUNCHXL_DIO22口输出高低电平

const PIN_Config BoardGpioInitTable[] = {

CC1310_LAUNCHXL_PIN_RLED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* LED initially off */
CC1310_LAUNCHXL_PIN_GLED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* LED initially off */

CC1310_LAUNCHXL_DIO22 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, /*NST001上拉电阻供电口 my add  */

CC1310_LAUNCHXL_PIN_BTN1 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS, /* Button is active low */
CC1310_LAUNCHXL_PIN_BTN2 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS, /* Button is active low */
CC1310_LAUNCHXL_SPI_FLASH_CS | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MIN, /* External flash chip select */
CC1310_LAUNCHXL_UART_RX | PIN_INPUT_EN | PIN_PULLDOWN, /* UART RX via debugger back channel */
CC1310_LAUNCHXL_UART_TX | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL, /* UART TX via debugger back channel */
CC1310_LAUNCHXL_SPI0_MOSI | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI master out – slave in */
CC1310_LAUNCHXL_SPI0_MISO | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI master in – slave out */
CC1310_LAUNCHXL_SPI0_CLK | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI clock */

PIN_TERMINATE
};

3.在gpiointerrupt.c文件中的void *mainThread(void *arg0)任务回调函数内添加如下代码(无法按预期输出电平??????)

void *mainThread(void *arg0)
{
         /* Call driver init functions */
         GPIO_init();

/* Configure the LED and button pins */
GPIO_setConfig(Board_GPIO_LED0, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);
GPIO_setConfig(Board_GPIO_LED1, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);
GPIO_setConfig(Board_GPIO_BUTTON0, GPIO_CFG_IN_PU | GPIO_CFG_IN_INT_FALLING);

//add lhj
GPIO_setConfig(Board_DIO22, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_HIGH);//my add 测量IO电平不起作用

GPIO_write(Board_DIO22, Board_GPIO_LED_OFF);//my add 测量IO电平不起作用

GPIO_write(Board_DIO22, Board_GPIO_LED_ON);//my add 测量IO电平不起作用
//add lhj

/* Turn on user LED */
GPIO_write(Board_GPIO_LED0, Board_GPIO_LED_ON);//LED 灯输出OK

GPIO_write(Board_GPIO_LED0, Board_GPIO_LED_OFF);

/* install Button callback */
GPIO_setCallback(Board_GPIO_BUTTON0, gpioButtonFxn0);

/* Enable interrupts */
GPIO_enableInt(Board_GPIO_BUTTON0);

/*
* If more than one input pin is available for your device, interrupts
* will be enabled on Board_GPIO_BUTTON1.
*/
if (Board_GPIO_BUTTON0 != Board_GPIO_BUTTON1) {
/* Configure BUTTON1 pin */
GPIO_setConfig(Board_GPIO_BUTTON1, GPIO_CFG_IN_PU | GPIO_CFG_IN_INT_FALLING);

/* Install Button callback */
GPIO_setCallback(Board_GPIO_BUTTON1, gpioButtonFxn1);
GPIO_enableInt(Board_GPIO_BUTTON1);
}

return (NULL);
}

4.问题如下

   a.对于RLED驱动的引角:  在BoardGpioInitTable[]中配置的是CC1310_LAUNCHXL_PIN_RLED==IOID_6,但是在 GPIO_setConfig(Board_GPIO_LED0, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW)和 GPIO_write(Board_GPIO_LED0, Board_GPIO_LED_ON);中确使用的是Board_GPIO_LED0,那IO的索引到底是怎么配置的,CC1310_LAUNCHXL_PIN_RLED和

Board_GPIO_LED0两之间有什么关联啊????????因此处没有搞明白,IO输出可能配置不正确?????????

const PIN_Config BoardGpioInitTable[] = {

CC1310_LAUNCHXL_PIN_RLED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* LED initially off */

……

}

b.

fghj dfghjk:

b.自己添加配置的DIO22没有输出,GPIO_setConfig()和GPIO_write()中的index使用#define Board_DIO22CC1310_LAUNCHXL_DIO22
正不正确?????
//add lhj
GPIO_setConfig(Board_DIO22, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_HIGH);//my add 测量IO电平不起作用

GPIO_write(Board_DIO22, Board_GPIO_LED_OFF);//my add 测量IO电平不起作用

GPIO_write(Board_DIO22, Board_GPIO_LED_ON);//my add 测量IO电平不起作用

Kevin Qiu1:

回复 fghj dfghjk:

IO映射关系都在Board.h和CC1310_LAUNCHXL.h中,看起来应该是没有IO配置成功
将Board_DIO22, Board_GPIO_LED_ON修改下试试
比如CC1350_LAUNCHXL_DIO22和1

fghj dfghjk:

回复 Kevin Qiu1:

谢谢回复。
1.不明白自己添加IO的流程
2.把自己想配置的IO首先添加到BoardGpioInitTable[]中。那gpioPinConfigs[]中需要修改?????
3.在任务中调用如下,不知道对流程对不对啊???GPIO_write()中的第1个形参是index,那这个index是对应用的IOID_22????如果是的话,事件代码中驱动RLED的IO是IOID_6,但是 GPIO_write(Board_GPIO_LED0, Board_GPIO_LED_ON);Board_GPIO_LED0==5??????为什么又是取了枚举成员中的5啊????GPIO_init();
//add lhj
GPIO_setConfig(CC1350_LAUNCHXL_DIO22, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_HIGH);//my add 测量IO电平不起作用

GPIO_write(CC1350_LAUNCHXL_DIO22, Board_GPIO_LED_OFF);//my add 测量IO电平不起作用

GPIO_write(CC1350_LAUNCHXL_DIO22, Board_GPIO_LED_ON);//my add 测量IO电平不起作用

4.现在用CC9编译一次CC1310代RTOS的代码,每修改一处编译一次,都需要好几分钟或十几分钟的时间,感觉开发完这个得花好几年的时间,这个编译本身就是这么慢,还是有什么问题啊,能不能修改哪个东西,让变快啊?????

Kevin Qiu1:

回复 fghj dfghjk:

可以先从main函数看起,初始化Board_init(); 然后查找,初始化IO
BoardGpioInitTable[]配置了之后,gpioPinConfigs[]中不需要配置
编译速度和电脑内存,CPU等都有关,第一次编译慢一点,之后挺快的
速度慢看这里e2e.ti.com/…/831258

fghj dfghjk:

回复 Kevin Qiu1:

驱动LED的IO和按键的IO,在使用下面配置时/* Configure the LED and button pins */GPIO_setConfig(Board_GPIO_LED0, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);GPIO_setConfig(Board_GPIO_LED1, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);GPIO_setConfig(Board_GPIO_BUTTON0, GPIO_CFG_IN_PU | GPIO_CFG_IN_INT_FALLING);

Board_GPIO_LED0 Board_GPIO_LED1 和 Board_GPIO_BUTTON0都是下面的枚举变量。这和 Board_init(void)中配置的LED的IO是对应不上的,事例运行确是OK的。自己按照事例添加就是没有输出。????这个IO索引到底是程序对应的IOID_XX嘛????怎么事例程序LED和按键的IO初始化时的应用不上?????自己配置的就是不输出,还有没有什么可能没配置的啊??????
/*!*@defCC1310_LAUNCHXL_GPIOName*@briefEnum of GPIO names*/
typedef enum CC1310_LAUNCHXL_GPIOName {CC1310_LAUNCHXL_GPIO_S1 = 0,CC1310_LAUNCHXL_GPIO_S2,CC1310_LAUNCHXL_SPI_MASTER_READY,CC1310_LAUNCHXL_SPI_SLAVE_READY,CC1310_LAUNCHXL_GPIO_LED_GREEN,CC1310_LAUNCHXL_GPIO_LED_RED,CC1310_LAUNCHXL_GPIO_TMP116_EN,CC1310_LAUNCHXL_GPIO_SPI_FLASH_CS,CC1310_LAUNCHXL_SDSPI_CS,CC1310_LAUNCHXL_GPIO_LCD_CS,CC1310_LAUNCHXL_GPIO_LCD_POWER,CC1310_LAUNCHXL_GPIO_LCD_ENABLE,CC1310_LAUNCHXL_GPIOCOUNT
} CC1310_LAUNCHXL_GPIOName;

Kevin Qiu1:

回复 fghj dfghjk:

将CC1310_LAUNCHXL_DIO22加到BoardGpioInitTable和typedef enum CC1310_LAUNCHXL_GPIOName中试试

fghj dfghjk:

回复 Kevin Qiu1:

是把CC1310_LAUNCHXL_DIO22 加到CC1310_LAUNCHXL_GPIOName 中吧,我的代码中没有,CC2640R2_LAUNCHXL_DIO22和CC2640R2_LAUNCHXL_GPIOName啊,用GPIO_write(CC1350_LAUNCHXL_DIO22, Board_GPIO_LED_OFF);操作IO时,IO索引需要往CC1310_LAUNCHXL_GPIOName中添加嘛?????事例程序中的LED和按键对应的IO索引和CC1310_LAUNCHXL_GPIOName里面的是不对应的这个为什么不对应,为什么还要这做其它的IO也需要像这样做嘛??????,就在刚刚我用PIN_open(&ledPinState, pinTable);把IO索引添加到pinTable中就能正常输出。——————-为什么用GPIO_write确不用????????????????????????????????????????????????????????????

Kevin Qiu1:

回复 fghj dfghjk:

两种实现方式不同,通过GPIO_write实现看下下面的方法:

在const PIN_Config BoardGpioInitTable[]中加上

CC1310_LAUNCHXL_DIO22 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,     

对应的是typedef enum CC1310_LAUNCHXL_GPIOName中的

 CC1310_LAUNCHXL_GPIO_LCD_POWER,

最后在main中

GPIO_setConfig( CC1310_LAUNCHXL_GPIO_LCD_POWER, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);

GPIO_write( CC1310_LAUNCHXL_GPIO_LCD_POWER, Board_GPIO_LED_ON);

(PS:CC1310_LAUNCHXL_GPIO_LCD_POWER名称可以根据需要自己更改)

fghj dfghjk:

回复 fghj dfghjk:

***问题解决!!!!!

注意:@@@@@@ 在使用GPIO_setConfig()  GPIO_write()  GPIO_setCallback()来配置驱动IO口时,需要下面数组和下面的枚举结构元素下标一一对应@@@@  不知道为什么这么设计,这么隐藏不知道其它人有没有遇到过此问题!!!

一.调试IO口1.调试NST1001时需要2个IO,一个供电,一个为中断2.在gpiointterupt-rtos工程中,仿照LED的IO配置使用不行,最后发现有如下规律: 在使用GPIO_setConfig GPIO_write GPIO_setCallback来配置驱动IO口时,需要下面数据和下面的枚举结构元素下标一一对应 GPIO_PinConfig gpioPinConfigs[] = { /* Input pins */ GPIOCC26XX_DIO_13 | GPIO_DO_NOT_CONFIG, /* Button 0 */ GPIOCC26XX_DIO_14 | GPIO_DO_NOT_CONFIG, /* Button 1 */

GPIOCC26XX_DIO_15 | GPIO_DO_NOT_CONFIG, /* CC1310_LAUNCHXL_SPI_MASTER_READY */ GPIOCC26XX_DIO_21 | GPIO_DO_NOT_CONFIG, /* CC1310_LAUNCHXL_SPI_SLAVE_READY */

/* Output pins */ GPIOCC26XX_DIO_07 | GPIO_DO_NOT_CONFIG, /* Green LED */ GPIOCC26XX_DIO_06 | GPIO_DO_NOT_CONFIG, /* Red LED */ GPIOCC26XX_DIO_30 | GPIO_DO_NOT_CONFIG, /* TMP116_EN */

/* SPI Flash CSN */ GPIOCC26XX_DIO_20 | GPIO_DO_NOT_CONFIG,

/* SD CS */ GPIOCC26XX_DIO_21 | GPIO_DO_NOT_CONFIG,

/* Sharp Display – GPIO configurations will be done in the Display files */ GPIOCC26XX_DIO_24 | GPIO_DO_NOT_CONFIG, /* SPI chip select */ GPIOCC26XX_DIO_22 | GPIO_DO_NOT_CONFIG, /* LCD power control */ GPIOCC26XX_DIO_23 | GPIO_DO_NOT_CONFIG, /*LCD enable */

};和/*! * @def CC1310_LAUNCHXL_GPIOName * @brief Enum of GPIO names */typedef enum CC1310_LAUNCHXL_GPIOName { CC1310_LAUNCHXL_GPIO_S1 = 0, CC1310_LAUNCHXL_GPIO_S2, CC1310_LAUNCHXL_SPI_MASTER_READY, CC1310_LAUNCHXL_SPI_SLAVE_READY, CC1310_LAUNCHXL_GPIO_LED_GREEN, CC1310_LAUNCHXL_GPIO_LED_RED, CC1310_LAUNCHXL_GPIO_TMP116_EN, CC1310_LAUNCHXL_GPIO_SPI_FLASH_CS, CC1310_LAUNCHXL_SDSPI_CS, CC1310_LAUNCHXL_GPIO_LCD_CS, CC1310_LAUNCHXL_GPIO_LCD_POWER, CC1310_LAUNCHXL_GPIO_LCD_ENABLE, CC1310_LAUNCHXL_GPIOCOUNT} CC1310_LAUNCHXL_GPIOName;

如: GPIO_setConfig(CC1310_LAUNCHXL_GPIO_S1, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW); 此时配置CC1310_LAUNCHXL_GPIO_S1就是 GPIOCC26XX_DIO_13IO,直接使用GPIOCC26XX_DIO_13IO是不行的。

在如:GPIO_setConfig(CC1310_LAUNCHXL_SDSPI_CS, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);

CC1310_LAUNCHXL_SDSPI_CS对应的IO就是gpioPinConfigs【】数组的GPIOCC26XX_DIO_21,要是在GPIO_setConfig中直接输入GPIOCC26XX_DIO_21就不起作用

Kevin Qiu1:

回复 fghj dfghjk:

是的,感谢提供反馈

赞(0)
未经允许不得转载:TI中文支持网 » CC1310 GPIO 配置不输出相应电平?????
分享到: 更多 (0)