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.

关于在CC3200评估板用程序控制管脚输出



我想在板子的丝印P15对应的管脚输出一个高低电平信号,参考例子代码,这样写对吗:

MAP_PRCMPeripheralClkEnable(PRCM_GPIOA2,PRCM_RUN_MODE_CLK);

MAP_PinTypeGPIO(PIN_15,PIN_MODE_0, false);

MAP_GPIODirModeSet(GPIOA2_BASE,GPIO_PIN_6, GPIO_DIR_MODE_OUT);

While(1)
{
GPIOPinWrite(GPIOA2_BASE,GPIO_PIN_6,GPIO_PIN_6);
MAP_UtilsDelay(10000);
GPIOPinWrite(GPIOA2_BASE,GPIO_PIN_6,0);
MAP_UtilsDelay(10000);
}
  • 看不出有什么问题,跑一下试试看有效没

  • 好像那个

    GPIOPinWrite(GPIOA2_BASE,GPIO_PIN_6,GPIO_PIN_6);

    这句有问题吧,第三个参数应该是1比较合适吧。

    因为

    void
    GPIO_IF_Set(unsigned char ucPin,
    unsigned int uiGPIOPort,
    unsigned char ucGPIOPin,
    unsigned char ucGPIOValue)
    {
    //
    // Set the corresponding bit in the bitmask
    //
    ucGPIOValue = ucGPIOValue << (ucPin % 8);

    //
    // Invoke the API to set the value
    //
    MAP_GPIOPinWrite(uiGPIOPort,ucGPIOPin,ucGPIOValue);
    }

    所以知道这个函数的第4个参数就是你那个函数的第三个参数。

    而例程中有:

    /* Switch ON RED LED */
    GPIO_IF_Set(GPIO_LED1, g_uiLED1Port, g_ucLED1Pin, 1);
    break;

    因此我们知道,如果输出高电平在IF SET里第4个参数是1,所以在pin WRITE函数里,第三个参数也是1.