0
#define InitUART( BRGVal, BRGHighVal )      {                       \
                        UARTTxD = UARTTxDInit;                  \
                        DirUARTTxD = DirOutput;                 \
                        DirUARTRxD = DirInput;                  \
                        SPBRG2 = BRGVal;                        \
                        TXSTA2bits.BRGH = BRGHighVal;           \
                        TXSTA2bits.SYNC = 0;                    \
                        TXSTA2bits.TX9 = 0;                     \
                        TXSTA2bits.TXEN = 1;                    \
                        RCSTA2bits.SPEN = 1;                    \
                        RCSTA2bits.RX9 = 0;                     \
                        IPR3bits.RC2IP = 1;                     \
                        IPR3bits.TX2IP = 0;                     \
                        PIE3bits.TX2IE = 0;                     \
                        PIE3bits.RC2IE = 1;                     \
                        RCSTA2bits.CREN = 0;                    \
                        }

对于最后一行,我不明白为什么要清除我使用 PIC18LF6722 的 RECEIVE ENABLE FLAG

4

1 回答 1

0

CREN is the Continuous Receive Enable Bit, which means that in a receive routine, in asynchronous mode, the receive buffer will always clears itself after it's full, allowing a continuous receive of UART characters. In synchronous mode, it's used for other purpose, which you may look at in your PIC'S datasheet.

于 2014-07-14T11:37:17.057 回答