谢谢你的兴趣。这是我的oART1AL接收到的中断({空)/接收中断{if(u1rrrist.Piif=1){xnxl++;}(U1Errrist.Piif=0){xnDAT++);}添加UART1自定义代码UART1RXBuff[UART1RXHead ++]=U1RXB;if(SIZOF(UART1RxBuffels<= UART1RXHORD){UART1R)XHOLD=0;} UART1RXCOUNT+++;而(UART1RXCOUNT & GT;0)//读取所有清除缓冲区{DALILATATATUD= UART1YARAD();}当PIIF位高时,XNXL变量增加,如果PIIF低,则XNDATA变量增加。这就是我知道PiIF位是高还是低的原因。因此,PurIF位总是很高,即使它接收到一个后置帧或一个前向帧。这是MyR初始化ODAR1Y初始化(空隙){//禁止中断,然后改变StistePi3BITS.U1RXYE=0;Py3BITS.U1TXYE=0;Py3BITS.U1EEE=0;/ /将UART1模块设置为选项SCORE。1L 0;U1P1L= 0x00;/U1P1H=0x00;/U2PL=0x00;/U2PH=0x00;//P3L 0;U1P3L= 0x00;//P3H 0;U1P3H=0x00;/BRGS高速;模式DALI控制设备模式;启用RXEN;启用AXDN;U1CON0= 0xB8;//RXBIMD设置RXBKIF;用户界面中的TED。输入;BRKOVR禁用;SDENB禁用;启用;U1CON1=0x80;//TXPOL倒置;F0ON校验和模式0;RXPOL倒置;RUNOVF RX输入移位器停止所有活动;STP发送1-停止位,接收机验证第一停止位;U1CON2= 0x44;/BRGL 20;U1BRGL= 0x14;//BRGH 52;U1;U1;BRGH=0x34;//STPMD在第一停止位中途;TXWRE无错误;U1FIFO=0x00;/ABDIF自动波特未启用或不完整;WUIF WUE未由软件启用;AUDIE禁用;U1UIR=0X00;/ABODVF未溢出;TXCIF 0;RXBKIF未检测到;RXFIF未溢出;CIEIF无校验和错误;U1ErrII= 0x00;//TXCIE禁用;TXMIT禁用;AcdoVE禁用;RXFIE禁用;Pele禁用;RXBKE禁用;U1ErReE=0x00;/ /初始化驱动程序StutuTAR1TxHead=0;UART1TXXTRAY=0;UART1TXBuffeREST = SIZEOF(UART1TXBASH);UART1RXHORD=0;UART1RXTAIL=0;UART1RXCOUNT=0;//启用接收中断PTE3BITS U1RXYE=1;//启用错误中断PTE3BITS U1EEE=1;}
以上来自于百度翻译
以下为原文
Thank you for your interest
This is my code
void UART1_Receive_ISR (void) // Receive interrupt
{
if (U1ERRIRbits.PERIF == 1)
{
xnxl ++;
}
if (U1ERRIRbits.PERIF == 0)
{
xndata ++;
}
add your UART1 custom code
uart1RxBuffer [uart1RxHead ++] = U1RXB;
if (sizeof (uart1RxBuffer) <= uart1RxHead)
{
uart1RxHead = 0;
}
uart1RxCount ++;
while (uart1RxCount> 0) // read all to clear buffer
{
DALI_DATA = UART1_Read ();
}
}
When the PERIF bit is high, the xnxl variable increases and if the PERIF is low then the xndata variable increases. That is how I know the PERIF bit is high or low. As a result, the PERIF bit is always high, even if it receives a back frame or a forward frame.
and this is my Initialize code
void UART1_Initialize(void)
{
// Disable interrupts before changing states
PIE3bits.U1RXIE = 0;
PIE3bits.U1TXIE = 0;
PIE3bits.U1EIE = 0;
// Set the UART1 module to the options selected in the user interface.
// P1L 0;
U1P1L = 0x00;
// P1H 0;
U1P1H = 0x00;
// P2L 0;
U1P2L = 0x00;
// P2H 0;
U1P2H = 0x00;
// P3L 0;
U1P3L = 0x00;
// P3H 0;
U1P3H = 0x00;
// BRGS high speed; MODE DALI Control Device mode; RXEN enabled; TXEN enabled; ABDEN disabled;
U1CON0 = 0xB8;
// RXBIMD Set RXBKIF on rising RX input; BRKOVR disabled; WUE disabled; SENDB disabled; ON enabled;
U1CON1 = 0x80;
// TXPOL inverted; FLO off; C0EN Checksum Mode 0; RXPOL inverted; RUNOVF RX input shifter stops all activity; STP Transmit 1Stop bit, receiver verifies first Stop bit;
U1CON2 = 0x44;
// BRGL 20;
U1BRGL = 0x14;
// BRGH 52;
U1BRGH = 0x34;
// STPMD in middle of first Stop bit; TXWRE No error;
U1FIFO = 0x00;
// ABDIF Auto-baud not enabled or not complete; WUIF WUE not enabled by software; ABDIE disabled;
U1UIR = 0x00;
// ABDOVF Not overflowed; TXCIF 0; RXBKIF No Break detected; RXFOIF not overflowed; CERIF No Checksum error;
U1ERRIR = 0x00;
// TXCIE disabled; FERIE disabled; TXMTIE disabled; ABDOVE disabled; CERIE disabled; RXFOIE disabled; PERIE disabled; RXBKIE disabled;
U1ERRIE = 0x00;
// initializing the driver state
uart1TxHead = 0;
uart1TxTail = 0;
uart1TxBufferRemaining = sizeof(uart1TxBuffer);
uart1RxHead = 0;
uart1RxTail = 0;
uart1RxCount = 0;
// enable receive interrupt
PIE3bits.U1RXIE = 1;
// enable error interrupt
PIE3bits.U1EIE = 1;
}
谢谢你的兴趣。这是我的oART1AL接收到的中断({空)/接收中断{if(u1rrrist.Piif=1){xnxl++;}(U1Errrist.Piif=0){xnDAT++);}添加UART1自定义代码UART1RXBuff[UART1RXHead ++]=U1RXB;if(SIZOF(UART1RxBuffels&lt;= UART1RXHORD){UART1R)XHOLD=0;} UART1RXCOUNT+++;而(UART1RXCOUNT & GT;0)//读取所有清除缓冲区{DALILATATATUD= UART1YARAD();}当PIIF位高时,XNXL变量增加,如果PIIF低,则XNDATA变量增加。这就是我知道PiIF位是高还是低的原因。因此,PurIF位总是很高,即使它接收到一个后置帧或一个前向帧。这是MyR初始化ODAR1Y初始化(空隙){//禁止中断,然后改变StistePi3BITS.U1RXYE=0;Py3BITS.U1TXYE=0;Py3BITS.U1EEE=0;/ /将UART1模块设置为选项SCORE。1L 0;U1P1L= 0x00;/U1P1H=0x00;/U2PL=0x00;/U2PH=0x00;//P3L 0;U1P3L= 0x00;//P3H 0;U1P3H=0x00;/BRGS高速;模式DALI控制设备模式;启用RXEN;启用AXDN;U1CON0= 0xB8;//RXBIMD设置RXBKIF;用户界面中的TED。输入;BRKOVR禁用;SDENB禁用;启用;U1CON1=0x80;//TXPOL倒置;F0ON校验和模式0;RXPOL倒置;RUNOVF RX输入移位器停止所有活动;STP发送1-停止位,接收机验证第一停止位;U1CON2= 0x44;/BRGL 20;U1BRGL= 0x14;//BRGH 52;U1;U1;BRGH=0x34;//STPMD在第一停止位中途;TXWRE无错误;U1FIFO=0x00;/ABDIF自动波特未启用或不完整;WUIF WUE未由软件启用;AUDIE禁用;U1UIR=0X00;/ABODVF未溢出;TXCIF 0;RXBKIF未检测到;RXFIF未溢出;CIEIF无校验和错误;U1ErrII= 0x00;//TXCIE禁用;TXMIT禁用;AcdoVE禁用;RXFIE禁用;Pele禁用;RXBKE禁用;U1ErReE=0x00;/ /初始化驱动程序StutuTAR1TxHead=0;UART1TXXTRAY=0;UART1TXBuffeREST = SIZEOF(UART1TXBASH);UART1RXHORD=0;UART1RXTAIL=0;UART1RXCOUNT=0;//启用接收中断PTE3BITS U1RXYE=1;//启用错误中断PTE3BITS U1EEE=1;}
以上来自于百度翻译
以下为原文
Thank you for your interest
This is my code
void UART1_Receive_ISR (void) // Receive interrupt
{
if (U1ERRIRbits.PERIF == 1)
{
xnxl ++;
}
if (U1ERRIRbits.PERIF == 0)
{
xndata ++;
}
add your UART1 custom code
uart1RxBuffer [uart1RxHead ++] = U1RXB;
if (sizeof (uart1RxBuffer) <= uart1RxHead)
{
uart1RxHead = 0;
}
uart1RxCount ++;
while (uart1RxCount> 0) // read all to clear buffer
{
DALI_DATA = UART1_Read ();
}
}
When the PERIF bit is high, the xnxl variable increases and if the PERIF is low then the xndata variable increases. That is how I know the PERIF bit is high or low. As a result, the PERIF bit is always high, even if it receives a back frame or a forward frame.
and this is my Initialize code
void UART1_Initialize(void)
{
// Disable interrupts before changing states
PIE3bits.U1RXIE = 0;
PIE3bits.U1TXIE = 0;
PIE3bits.U1EIE = 0;
// Set the UART1 module to the options selected in the user interface.
// P1L 0;
U1P1L = 0x00;
// P1H 0;
U1P1H = 0x00;
// P2L 0;
U1P2L = 0x00;
// P2H 0;
U1P2H = 0x00;
// P3L 0;
U1P3L = 0x00;
// P3H 0;
U1P3H = 0x00;
// BRGS high speed; MODE DALI Control Device mode; RXEN enabled; TXEN enabled; ABDEN disabled;
U1CON0 = 0xB8;
// RXBIMD Set RXBKIF on rising RX input; BRKOVR disabled; WUE disabled; SENDB disabled; ON enabled;
U1CON1 = 0x80;
// TXPOL inverted; FLO off; C0EN Checksum Mode 0; RXPOL inverted; RUNOVF RX input shifter stops all activity; STP Transmit 1Stop bit, receiver verifies first Stop bit;
U1CON2 = 0x44;
// BRGL 20;
U1BRGL = 0x14;
// BRGH 52;
U1BRGH = 0x34;
// STPMD in middle of first Stop bit; TXWRE No error;
U1FIFO = 0x00;
// ABDIF Auto-baud not enabled or not complete; WUIF WUE not enabled by software; ABDIE disabled;
U1UIR = 0x00;
// ABDOVF Not overflowed; TXCIF 0; RXBKIF No Break detected; RXFOIF not overflowed; CERIF No Checksum error;
U1ERRIR = 0x00;
// TXCIE disabled; FERIE disabled; TXMTIE disabled; ABDOVE disabled; CERIE disabled; RXFOIE disabled; PERIE disabled; RXBKIE disabled;
U1ERRIE = 0x00;
// initializing the driver state
uart1TxHead = 0;
uart1TxTail = 0;
uart1TxBufferRemaining = sizeof(uart1TxBuffer);
uart1RxHead = 0;
uart1RxTail = 0;
uart1RxCount = 0;
// enable receive interrupt
PIE3bits.U1RXIE = 1;
// enable error interrupt
PIE3bits.U1EIE = 1;
}
举报