写了个小程序想试一下串口通信,串口助手就是没有接收到数据,大神们帮帮忙吧
#include <pic18.h>
#include "config.h" //PEIZHI
void usart_init()
{
TRISB0=0;
TRISC6=0; //TX
TRISC7=1; //RX
SPBRG2=25;
BAUDCON2=0x00;
TXSTA2=0x20;
RCSTA2=0x90;
}
void delay(int c)
{
int x,y;
for(x=0;x<110;x++)
for(y=0;y<c;y++);
}
void main()
{
usart_init();
while(1)
{
delay(1000);
PORTBbits.RB0=~PORTBbits.RB0;
TXREG2=0x45;
}
}
|