本帖最后由 lcy89815 于 2015-12-11 09:52 编辑
这两天在试PIC18F4520串口自动收发功能,发现在串口调试小助手只能发送28个以内的字符,超过的只能显示前28个,之后就无法接收,这会是什么原因造成的呢,谢谢大家了!
void main(void)
{
OSCCON = 0x72; //8MHz,Internal oscillator, however its actual value is 0x76
/*16-bit,asynchronous mode, desired baud rate = Fosc / (4 * ([SPBRGH:SPBRGL] + 1))*/
SYNC = 0; //asynchronous mode
BRG16 = 1; //16-bit baud rate generator is used
BRGH = 1; //high speed
SPBRGH = 0x00; //baud rate 9600
SPBRG = 0xcf;
/*enable receiver*/
SPEN = 1; //enable eusart
TRISC6 = 1;
TRISC7 = 1;
CREN = 1; //enable receiver circuitry of eusart
TXEN = 1; //enable transmitter circuitry of eusart
RCIE = 1; //enable usart receiver interrupt
GIE = 1; //enable all active interrupts
PEIE = 1; //enable all active peripheral interrupts
while(1)
{
;
}
return;
}
void interrupt INT_ISR(void)
{
if(RCIF && RCIE)
{
TXREG = RCREG;
while(!TRMT);
}
}
|