完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛|
我遇到的问题是USAT错误中断不停地发生,不允许程序的其余部分执行。我在PIC32 MZ2048 EFG144上使用和声2.01b。我使用USAT驱动程序、动态实现、中断模式、字节模型支持、1个UART驱动实例和1个USAT驱动客户端。操作模式是DRVIUS UARTARSO操作正常(不是IrDA、寻址或回送)。启动时唤醒,自动波特,在空闲中停止都关闭。线路控制是8N1,握手是没有的,电源是SysSimeMeLePixyRunyFul.我的代码非常简单。我使用DrviUsARTAROPEN获得了一个UART句柄,用DRVIIOION ItEntTyRead Wr.DVVIOION ITENtiN非阻塞。之后,我执行每个程序循环一次:如果(DrviUsReaveBuffelISHOLL(MyUartHandle)=false){RXCHAR=DrviUsARTHAREADEQUEL字节(MyUartHandle);}(DRVIUSAARTION SuffFuffSeriSULL(MyUartHandle)= FALSE){DrvU.AtARTHARCHEEDYBEL字节(MYUARTHANDELE,RxChar);}(启动时,RxChar初始化为A)n个ASCII字符,以便它在接收任何东西之前都是有效的。因此,基本上,这应该是一遍遍地发送字符,并且每次接收字符时,都会变成新的字符。RAM只是“锁定”通过反复进入错误中断。在ISR中调用DrviUsARTHARTASKSERROR(SysObj.DrvasART0)行时,在SturixCult.c中放置了断点。执行在该断点处停止,每当我按下继续时,执行就会再次停止。我知道经常需要在代码中清除一个中断标志,但由于我使用的是和声,所以我认为和声应该实现并清除错误标志。在USART Driver帮助中需要注意的是:“当驱动器配置为在裸金属(非RTOS)应用程序中进行轮询操作(DRV_USART_INTERRUPT_MODE为false)时,不要在阻塞模式下打开驱动程序。当调用DRV_USART_Read或DRV_USART_Write函数时,这将导致系统进入无限循环条件。”但是,由于我在中断模式下使用驱动程序,并且使用DRV_IO_INTENT_NONBLOCKING,因此不应该应用此条件。
以上来自于百度翻译 以下为原文 I'm having a problem that appears to be the USART error interrupt happening non-stop, not allowing the rest of the program to execute. I'm using HARMony 2.01b on PIC32MZ2048EFG144. I'm using USART driver, DYNAMIC implementation, interrupt mode, byte model support, with 1 USART driver instance and 1 USART driver client. The operation mode is DRV_USART_OPERATION_MODE_NORMAL (not IrDA, addressed, or loopback). Wake On Start, Auto Baud, and Stop In Idle are all turned OFF. Line control is 8N1, handshake is none, power is SYS_MODULE_POWER_RUN_FULL. My code is very simple. I obtain a UART handle using DRV_USART_OPEN with DRV_IO_INTENT_READWRITE | DRV_IO_INTENT_NONBLOCKING. Afterwards, I do the following once per program loop: if (DRV_USART_ReceiverBufferIsEmpty(MyUartHandle) == false) { RxChar = DRV_USART_ReadByte(MyUartHandle); } if (DRV_USART_TransmitBufferIsFull(MyUartHandle) == false) { DRV_USART_WriteByte(MyUartHandle, RxChar); } (On startup, RxChar is initialized to an ASCII character so that it will be valid before anything is received.) So basically this is supposed to transmit a character over and over, and each time a character is received, that becomes the new character that gets transmitted. It seems to me that whether something is received or not, the program just "locks up" by going into the error interrupt over and over. I placed a breakpoint in system_interrupt.c at the call to DRV_USART_TasksError(sysObj.drvUsart0) line in the ISR. Execution halts at that breakpoint, and each time I press continue, execution halts there again. I know that it is often necessary to clear an interrupt flag in code, but since I am using Harmony, I think Harmony is supposed to implement that and clear the error flag. Edit: I also know about the following note in the USART Driver help: "Do not open the driver in Blocking mode when the driver is configured for polling operation (DRV_USART_INTERRUPT_MODE is false) in a bare-metal (non-RTOS) application. This will cause the system to enter an infinite loop condition when the DRV_USART_Read or DRV_USART_Write function is called." But since I am using the driver in interrupt mode and with DRV_IO_INTENT_NONBLOCKING, this should not apply. |
|
相关推荐
2个回答
|
|
|
对不起忘了附加开始代码
以上来自于百度翻译 以下为原文 Sorry forgot to attach the start code void SendMessage(int length){ SYS_PORTS_PinSet(PORTS_ID_0, PORT_CHANNEL_D, PORTS_BIT_POS_6); //change RS485 to transmitt mode remainingdatalength = length; //set message length for isr PLIB_INT_VectorPrioritySet(INT_ID_0, INT_VECTOR_UART2_TX, INT_PRIORITY_LEVEL3); //enables interrupts, triggers interrupt } |
|
|
|
|
|
是的,我也看到了。每当出现框架错误时,我使用Orthier-ISRS(动态USAT模型)进行相同的锁定。现在我使用静态实现,因为在协调中没有9位的支持(见注释):看来,直到接收寄存器(ReaRead)(Read Read)之前,错误也不会被清除。在中断处理程序之外,这意味着你会被锁定在错误ISR中——一旦退出,它就重新进入。为了处理这个问题,接收ISR还需要清除任何错误:使用这个,我可以说它现在处理用于锁定它的框架错误。
以上来自于百度翻译 以下为原文 Yes, I have seen this too. I experienced the same lock-up using Harmony ISRs (dynamic USART model) whenever a framing error occurred. I now use a static implementation because there was no 9-bit support in Harmony (see comment for experience): /* Called from an Err ISR */ /* WARNING! Despite the documentation, reading a parity or framing error does * NOT clear the interrupt and we get stuck in the FAULT int if enabled. * If you enable the interrupt, stress-test at a low baud rate. */ void SerialErrISR(SERIAL_PORT *this) { /* Speed check for no errors - normal state */ if (USART_ERROR_NONE == PLIB_USART_ErrorsGet(this->PhysicalUsartID)) return; /* Handle errors */ /* Although this is meant to cause an interrupt, it appears not to... ??> */ if (PLIB_USART_ReceiverOverrunHasOccurred(this->PhysicalUsartID)) { PLIB_USART_ReceiverOverrunErrorClear(this->PhysicalUsartID); this->SerErrors |= SER_RX_OVERRUN; } /* Although reading this is meant to clear the interrupt, it appears not * to... ??> */ if (PLIB_USART_ReceiverFramingErrorHasOccurred(this->PhysicalUsartID)) { this->SerErrors |= SER_RX_FRAMING; } /* Although reading this is meant to clear the interrupt, it appears not * to... ??> */ if (PLIB_USART_ReceiverParityErrorHasOccurred(this->PhysicalUsartID)) { this->SerErrors |= SER_RX_PARITY; } } It appears that the error won't get cleared until the receive register is (also) read. Outside an interrupt handler, this means you get locked up in the Error ISR - as soon as it exits it re-enters. To deal with this, the Receive ISR needs to clear any errors as well: /* Called from an Rx ISR */ void SerialRxISR(SERIAL_PORT *this) { /* Check and clear any faults. Note that enabling the FAULT interrupt is * fatal for framing errors since reading the fault does not clear it, despite * the documentation. Also, for the overrun error, no interrupt occurs. */ this->SerialErrISR(); /* Only attempt to receive if we've got data */ if (PLIB_USART_ReceiverDataIsAvailable(this->PhysicalUsartID)) { /* If there is a callback for start of Rx, call it now */ if (this->RxStarts) this->RxStarts(); if (this->DataBits == EIGHT_DATA_BITS) /* 8-bit data */ { BYTE Data = PLIB_USART_ReceiverByteReceive(this->PhysicalUsartID); if (!AddToCircBuf(this->serRxBuffer, SERIAL_RX_BUFFER_SIZE, &Data, 1, &this->serRxWrPtr, &this->serRxRdPtr)) this->SerErrors |= SER_RX_OVERRUN; } else /* 9-bit data */ { WORD Data = PLIB_USART_Receiver9BitsReceive(this->PhysicalUsartID); if (!AddToCircBuf(this->serRxBuffer, SERIAL_RX_BUFFER_SIZE, (BYTE*)&Data, 2, &this->serRxWrPtr, &this->serRxRdPtr)) this->SerErrors |= SER_RX_OVERRUN; } } else { this->SerErrors |= SER_RX_UNDERRUN; } /* If there is no data pending despite the interrupt, signal an RxEnd */ if (this->IsSerialRxBufferEmpty()) ; } Using this I can say that it now handles framing errors that used to lock it up. |
|
|
|
|
只有小组成员才能发言,加入小组>>
MPLAB X IDE V6.25版本怎么对bootloader和应用程序进行烧录
473 浏览 0 评论
5793 浏览 9 评论
2334 浏览 8 评论
2224 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3530 浏览 3 评论
1123浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
1095浏览 1评论
我是Microchip 的代理商,有PIC16F1829T-I/SS 技术问题可以咨询我,微信:A-chip-Ti
873浏览 1评论
MPLAB X IDE V6.25版本怎么对bootloader和应用程序进行烧录
475浏览 0评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-2 01:23 , Processed in 0.556372 second(s), Total 76, Slave 59 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
2216