#include <LM3S9B96.h>
#include "hw_memmap.h"
#include "hw_types.h"
#include "gpio.h"
#include "sysctl.h"
int i;
int main(void)
{
SysCtlClockSet(SYSCTL_SYSDIV_1|SYSCTL_USE_OSC|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);//16MHZ,主频,不分频
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);//使能PF口
GPIODirModeSet(GPIO_PORTF_BASE,GPIO_PIN_3,GPIO_DIR_MODE_OUT); //PF3为输出
GPIOPadConfigSet(GPIO_PORTF_BASE,GPIO_PIN_3,GPIO_STRENGTH_4MA,GPIO_PIN_TYPE_STD);//端口配置/驱动电流4MA/推挽管脚
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOJ); //使能PJ口
GPIODirModeSet(GPIO_PORTJ_BASE,GPIO_PIN_7,GPIO_DIR_MODE_IN); //PJ设为输入
GPIOPadConfigSet(GPIO_PORTJ_BASE,GPIO_PIN_7,GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD);//端口配置
while(1)
{
if(GPIOPinRead(GPIO_PORTJ_BASE,GPIO_PIN_7)==0x00) //判断PJ_7是否为0
{
GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_3,GPIO_PIN_3);//点亮LED
}
else //否则熄灭LED
{
GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_3,~GPIO_PIN_3);
}
for(i=0;i<0xffff;i++);
}
}
此帖出自
小平头技术问答
把 GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_3,~GPIO_PIN_3);
变成 GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_3,0);试试
Fri Sep 21, 2012 15:27:26: JTAG Speed is set to: 500 kHz
Fri Sep 21, 2012 15:27:26: JTAG IDCODE = 0x4BA00477
Fri Sep 21, 2012 15:27:26: AHB-AP ID = 0x24770011
Fri Sep 21, 2012 15:27:26: AHB-AP ROM = 0xE00FF003
Fri Sep 21, 2012 15:27:26: ROM Component ID = 0xB105100D
Fri Sep 21, 2012 15:27:26: Device ID = 0x0000006F (Unknown)
Fri Sep 21, 2012 15:27:26: Software reset was performed
Fri Sep 21, 2012 15:27:26: Initial reset was performed
Fri Sep 21, 2012 15:27:26: Turning off watchdog
Fri Sep 21, 2012 15:27:26: 512 bytes downloaded and verified (5.32 Kbytes/sec)
Fri Sep 21, 2012 15:27:26: Loaded debugee: C:Program Files (x86)IAR SystemsEmbedded Workbench 6.4 Kickstart_2armconfigflashloaderTexasInstrumentsFlashLM3SxxxRAM32K.out
Fri Sep 21, 2012 15:27:26: Target reset
Fri Sep 21, 2012 15:27:27: Downloaded C:UsersAdministrator.XZ51YFJMITBHWEUDesktoplxDebugExelx.out to flash memory.
Fri Sep 21, 2012 15:27:27: Software reset was performed
Fri Sep 21, 2012 15:27:27: 488 bytes downloaded into FLASH and verified (0.46 Kbytes/sec)
Fri Sep 21, 2012 15:27:27: Loaded debugee: C:UsersAdministrator.XZ51YFJMITBHWEUDesktoplxDebugExelx.out
Fri Sep 21, 2012 15:27:28: Software reset was performed
Fri Sep 21, 2012 15:27:28: Target reset
Fri Sep 21, 2012 15:27:45: Software reset was performed
Fri Sep 21, 2012 15:27:45: Target reset
Fri Sep 21, 2012 15:27:54: Software reset was performed
Fri Sep 21, 2012 15:27:54: Target reset
一周热门 更多>