想做一个PIC18F87J60自动波特率的串口程序串口程序如下 没有见到想要的效果,测试时 先发送了55 过了几秒之后才发送的数据 可是依旧不能收到值,求指点一下
RCSTA2bits.SPEN = 0;// disable uart commutation
TXSTA2bits.SYNC = 0; // asynchronous mode
TXSTA2bits.BRGH = 1; // high speed
BAUDCON2bits.BRG16 = 1; // 16bits
RCSTA2bits.CREN = 1; // enable receive
TXSTA2bits.TXEN = 1; // tx enable
// EUSART2 rx int enable
IPR3bits.RC2IP = 1; // high priority
PIE3bits.RC2IE = 1; // enable
// EUSART2 tx int enable
IPR3bits.TX2IP = 1; // high priority
PIE3bits.TX2IE = 0; // disable
// Enable Interrupts
RCONbits.IPEN = 1; // Enable interrupt priorities
INTCONbits.GIEH = 1;
INTCONbits.GIEL = 1;
//Define RX_IO TX_IO
RCSTA2bits.SPEN = 0;// disable uart commutation
BAUDCON2bies.WUE = 0;
BAUDCON2bits.ABDEN =1;
//calculate baud rate
TRISGbits.TRISG2 = 1;
TRISGbits.TRISG1 = 0;
//enable uart
RCSTA2bits.SPEN = 1;//Enable uart commutation |