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.
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/gpio.h"
#include "driverlib/sysctl.h"
#define PINS GPIO_PIN_6
void delay(int d)
{
for(;d;--d);
}
void SysCtlClockSet(unsigned long ulConfig)
{}
void SysCtlPeripheralEnable (unsigned long ulPeripheral)
{}
void GPIODirModeSet(unsigned long ulPort,unsigned char ucPins,unsigned long ulPinIO)
{}
void GPIOPinWrite(unsigned long ulPort, unsigned char ucPins, unsigned char ucVal)
{}
int main(void)
{
unsigned int i;
SysCtlClockSet(SYSCTL_SYSDIV_1|SYSCTL_USE_OSC|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ);//直接使用外部晶振
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);//使能GPIO的PB模块
GPIODirModeSet(GPIO_PORTB_BASE,PINS,GPIO_DIR_MODE_OUT);//设置PB6输出
for(i=0;i<10;i++)
{
GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_6,1);//置PB6低电平
delay(20000);
GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_6,0);//置PB6高电平
delay(20000);
}
SysCtlClockSet(SYSCTL_SYSDIV_1|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ);//使用PLL
for(i=0;i<10;i++)
{GPIOPinWrite(GPIO_PORTB_BASE,PINS,~PINS);
delay(20000);
GPIOPinWrite(GPIO_PORTB_BASE,PINS,PINS);
delay(20000);
}
while(1);
// return 0;
}
GPIOB相应的寄存器数据不改变,单步运行没反应。板子是LM3S9B92 开发环境CCSV5
GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_6,0);
这个函数你什么都没定义,咋个可能有反应呢?
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/gpio.h"
#include "driverlib/sysctl.h"
//#define HWREG(x)
void main(void)
{
HWREG(0x400FE108)=1<<1;//使能GPIOB模块
HWREG(0x40005400)=0x00000040;//P6为输出
HWREG(0x400053FC)=0x00000040;//输出1
HWREG(0x400053FC)=0x00000000;//输出0
HWREG(0x400053FC)=1<<6;//输出1
HWREG(0x400053FC)=0<<6;//输出0
HWREG(0x400053FC)=0x1<<6;//输出1
HWREG(0x400053FC)=0x0<<6;//输出0
}
可以运行了,但是我想用GPIOPinWrite之类的语句写?怎么办呢
//基于驱动库的开发
//1、使能外设,以PA口为例子
MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
// 2、设置PA口引脚方向为输出
MAP_GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE,GPIO_PIN_6);
//3、设置PA6输出低电平
GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_6, 0x00);
//3、设置PA6输出高电平
GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_6, 0xFF);