非常简单的实例主程序
#define HWREG(x) (*((volatile unsigned long *)(x)))
#define SYSCTL_BASE 0x400FE000
#define RCGC2 (SYSCTL_BASE + 0x108)
#define GPIOA_BASE 0x40004000
#define GPIOA_DATA (GPIOA_BASE + 0x000)
#define GPIOA_DIR (GPIOA_BASE + 0x400)
#define GPIOA_AFSEL (GPIOA_BASE + 0x420)
#define GPIOA_DR2R (GPIOA_BASE + 0x500)
#define GPIOA_DR4R (GPIOA_BASE + 0x504)
#define GPIOA_DR8R (GPIOA_BASE + 0x508)
#define GPIOA_ODR (GPIOA_BASE + 0x50C)
#define GPIOA_PUR (GPIOA_BASE + 0x510)
#define GPIOA_PDR (GPIOA_BASE + 0x514)
#define GPIOA_SLR (GPIOA_BASE + 0x518)
#define GPIOA_DEN (GPIOA_BASE + 0x51C)
int main(void)
{
//void jtagWait(void)
//jtagWait( );
HWREG(RCGC2) |= 0x01; /* 使能GPIOA端口 */
HWREG(GPIOA_DIR) |= 0x08; /* 设置方向和模式 */
HWREG(GPIOA_AFSEL) &= ~0x08;
HWREG(GPIOA_DR2R) |= 0x08; /* 设置驱动强度 */
HWREG(GPIOA_DR4R) &= ~0x08;
HWREG(GPIOA_DR8R) &= ~0x08;
HWREG(GPIOA_SLR) &= ~0x08;
HWREG(GPIOA_ODR) &= ~0x08; /* 设置管脚类型 */
HWREG(GPIOA_PUR) &= ~0x08;
HWREG(GPIOA_PDR) &= ~0x08;
HWREG(GPIOA_DEN) |= 0x08;
HWREG(GPIOA_DATA+ (0x08 << 2)) = 0x00; /* PA3输出低电平 */
for (;;);
}
compile和make都没有错误
下载时出错
提示:Could not power up debug port :Control/Status register reads 000000F0
继而出现:
Fatal error:Incalid core ID. Session aborted!
debug框中显示:
Tue Jul 20 16:27:33 2010: DLL version: V4.10i, compiled Jan 25 2010 14:43:57
Tue Jul 20 16:27:33 2010: Firmware: J-Link ARM V7 compiled Jun 30 2009 11:05:27
Tue Jul 20 16:27:33 2010: JTAG speed is initially set to: 32 kHz
Tue Jul 20 16:27:33 2010: TotalIRLen = 4, IRPrint = 0x01
Tue Jul 20 16:29:20 2010: Hardware reset with strategy 0 was performed
Tue Jul 20 16:29:20 2010: Initial reset was performed
Tue Jul 20 16:29:20 2010: Fatal error: Invalid core Id. (0)
Session aborted!
此帖出自
小平头技术问答
错误的内核ID,可能是V7的不支持。上V8 的JLINK吧。
一周热门 更多>