哪位高手指点我的CORTEX M3 不能和串口调试助手通信,程序如下!!

[复制链接]
查看11 | 回复2 | 2011-3-14 17:12:06 | 显示全部楼层 |阅读模式
#include
#include
#include
#include
#include
unsigned longTheSysClock=12000000ul;

char c;
int main()
{

void uartputc(const char c) ;

void uartputs(const char *s) ;

char uartgetc();

SysCtlClockSet(SYSCTL_XTAL_8MHZ|
//SETthesystermclock

SYSCTL_OSC_MAIN |

SYSCTL_USE_PLL|

SYSCTL_SYSDIV_4 );
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART2 ); //enable systerm to theuart

SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);
// enablethegpioa
GPIOPinTypeUART(GPIO_PORTG_BASE,GPIO_PIN_0|GPIO_PIN_1); //conf the pin as UART

TheSysClock=SysCtlClockGet();


UARTConfigSet(UART2_BASE,115200,UART_CONFIG_WLEN_8|//Init theuart

UART_CONFIG_STOP_ONE|

UART_CONFIG_PAR_NONE);

UARTEnable(UART2_BASE);
//enable the uart0



uartgetc();


uartputc(c);
}
//send a charactor

void uartputc(const char c)


{

UARTCharPut(UART2_BASE, c);



}
//send a string

void uartputs(const char *s)


{

while(*s!='0')

uartputc( *s++);




}
//receive a charactor

char uartgetc()


{



c=UARTCharGet(UART2_BASE);

return (c);



}
//receivea string

回复

使用道具 举报

千问 | 2011-3-14 17:12:06 | 显示全部楼层
不知道你用的是NXP的还是STM的或者其他,不管哪种,建议还是要好好研究一下他们的例程。
回复

使用道具 举报

千问 | 2011-3-14 17:12:06 | 显示全部楼层
arm?建议去 大 的嵌入式 论坛 看看
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行