Microchip
直播中

王丽丽

7年用户 169经验值
私信 关注
[问答]

使用dali模式的uart1有问题

大家好,我正在做一个在DALI模式下使用UART 1的应用程序,我使用PIC18LF26K83.我知道,当FIFO顶部接收正向帧时,U1ErrR寄存器的PurIF位将被设置,当FIFO顶部接收到后部帧时,PURIF位位被清除。但是,当我检查PrIF位时,总是设置为接收回帧。我不知道我的代码出了什么问题。我用MCC来创建这个项目。那么MCC能创建错误的代码吗?提前感谢你的帮助

以上来自于百度翻译


      以下为原文

    Hi everybody.
I am doing an application that uses uart 1 in dali mode.i used PIC18lf26k83. I know that the PERIF bit of the U1ERRIR register will be set when the Forward Frame is received at the FiFo top and the PERIF bit bit is cleared when the Back Frame is received at the FiFo top. However, when I check the PERIF bit is always set to receive the Back Frame. I do not know what's wrong with my code. I used mcc to create this project. So can mcc create the wrong code?
Thanks in advance for your help

回帖(4)

tijing忽忽

2018-10-19 16:25:07
MCC不是绝对可靠的。如果你发布你要使用的实际代码,你将获得更好的机会。如果可能的话,将代码减少到可能出现问题的最小可能大小的完整程序。还提到编译器和版本,它有帮助,以及如何知道PiFIt位是按照你说的方式来设置的。

以上来自于百度翻译


      以下为原文

    MCC is not infallible. You will have a much better chance getting asistance if you post the actual code you are trying to use. If possible reduce your code to the smallest possible size complete program that exhibits the issues. Also mention what compiler and version, it helps, and how you know the PERIF bit is set the way you say it is.
举报

胡卫伟

2018-10-19 16:44:36
谢谢你的兴趣。这是我的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;
}
举报

tijing忽忽

2018-10-19 16:57:14
你的U1P1和U1P2等待时间设置为零,这会起作用吗?你实际上是从连接到总线的控制齿轮接收后座吗?它真的被发送了吗?

以上来自于百度翻译


      以下为原文

    You have your U1p1 and U1p2 wait times set to zero, will that work?
Are you actually receiving a backframe from a control gear connected to the bus? IS it actually being sent?
举报

钟晶

2018-10-19 17:10:06
嗨,MCC现在不支持大理、林或DMX。当您选择所提到的任何选项时,请检查通知,也就是说,即使通知也不支持“DALI模式”,它也允许编辑简单的设置并生成令人困惑的代码。

以上来自于百度翻译


      以下为原文

    Hi,
MCC doesn't support DALI, LIN or DMX as of now. When you select any of the options mentioned, check the notification as well which says that "DALI mode is not supported"
Even with notification, it allows to edit easy setup and generate code which is confusing. 
 
 
 
   Attached Image(s)

举报

更多回帖

发帖
×
20
完善资料,
赚取积分