怎样裸机调试串口,能通过那个仅有USB转接调试吗
我想用J-link裸机调试下串口,请问怎么配置。那个仅有口能调试, ;代码============================
;init.S============================
IMPORT main
AREA Init, CODE, READONLY
ENTRY
start
bl main
end
//*main.c===========================
/* xmain.c */
/* GPIO registers */
#define GPACON (*(volatile unsigned long *)0x7F008000)
#define GPADAT (*(volatile unsigned long *)0x7F008004)
#define GPAUP (*(volatile unsigned long *)0x7F008008)
/*UART registers*/
#define ULCON0 (*(volatile unsigned long *)0x7F005000)
#define UCON0 (*(volatile unsigned long *)0x7F005004)
#define UFCON0 (*(volatile unsigned long *)0x7F005008)
#define UMCON0 (*(volatile unsigned long *)0x7F00500c)
#define UTRSTAT0 (*(volatile unsigned long *)0x7F005010)
#define UTXH0 (*(volatile unsigned char *)0x7F005020)
#define URXH0 (*(volatile unsigned char *)0x7F005024)
#define UBRDIV0 (*(volatile unsigned long *)0x7F005028)
#define TXD0READY (1<<2)//发送数据状态OK
#define RXD0READY (1) //接收数据状态OK
/* UART串口初始化 */
void uart_init( )
{
GPACON |= 0x1111; //GPH2,GPH3 used as TXD0,RXD0
GPAUP = 0xaa; //GPH2,GPH3内部上拉
ULCON0 = 0x03; //8位数据位,无校验,普通模式,一位停止位
UCON0 = 0x05; //查询方式为轮询或中断;时钟选择为PCLK
UFCON0 = 0x00; //不使用FIFO
UMCON0 = 0x00; //不使用流控
UBRDIV0 = 36; //波特率为57600,PCLK=12Mhz
}
/* UART串口单个字符打印函数 */
extern void putc(unsigned char c)
{
//while( ! (UTRSTAT0 & TXD0READY) );
UTXH0 = c;
}
/* UART串口接受单个字符函数 */
extern unsigned char getc(void)
{
//while( ! (UTRSTAT0 & RXD0READY) );
return URXH0;
}
/* UART串口字符串打印函数 */
extern int printk(const char* str)
{
int i = 0;
while( str ){
putc( (unsigned char) str );
}
return i;
}
__inline void delay(int msec)
{
int i, j;
for(i = 1000; i > 0; i--)
for(j = msec*10; j > 0; j--)
/* do nothing */;
}
/* xmain 通过UART串口打印字符串 */
void main(void)
{
uart_init();
while(1)
{
//delay(10);
printk("Uart串口打印试验\r\n");
}
}
页:
[1]