首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >不工作,读一个开关,并将它写到EK-TM4C123GXL上的LED上?

不工作,读一个开关,并将它写到EK-TM4C123GXL上的LED上?
EN

Stack Overflow用户
提问于 2021-12-30 00:41:19
回答 1查看 72关注 0票数 1

Tiva Arm板EK-TM4C123GXL无法运行以下程序。需要帮助调试,它的教科书程序,图书链接:http://www.microdigitaled.com/ARM/TI_ARM_books.htm

代码语言:javascript
复制
/*  p2_7.c: Read a switch and write it to the LED */

/*  This program reads SW1 of Tiva LaunchPad and writes the inverse of the value to the green LED. SW1 is low when pressed (Normally High). LED is on when high. */


#include "TM4C123GH6PM.h"

int main(void)
{
    unsigned int value;
    SYSCTL->RCGCGPIO |= 0x20;   /* enable clock to GPIOF */
    GPIOF->DIR = 0x08;          /* set PORTF3 pin as output (LED) pin */
                                /* and PORTF4 as input, SW1 is on PORTF4 */
    GPIOF->DEN = 0x18;          /* set PORTF pins 4-3 as digital pins */
    GPIOF->PUR = 0x10;          /* enable pull up for pin 4 */

    while(1)
    {   
        value = GPIOF->DATA;    /* read data from PORTF */
        value = ~value;         /* switch is low active; LED is high active */
        value = value >> 1;     /* shift it right to display on green LED */
        GPIOF->DATA = value;    /* put it on the green LED */
    }
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-12-30 01:12:41

将编译器还原回v5后工作。http://www.microdigitaled.com/commonMaterials/compiler%20version.pdf

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70526389

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档