完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛|
问候语!我正在使用多UART OPIC32 MK1024GPD064。问题是1 RX引脚上的收入数据导致数据被从多个引脚接受——它触发多个中断,并且许多UART接收相同的数据。这是我的密码:知道我做错了什么吗?谢谢!
以上来自于百度翻译 以下为原文 Greetings! I`m using multiple UARTs on PIC32MK1024GPD064. The problem is income data on 1 RX pin cause the data to be accepted from multiple pins - it triggers multiple interrupts and many UARTs receive the same data. Here is my code: #pragma config DEBUG = OFF #pragma config JTAGEN = OFF #pragma config ICESEL = ICS_PGx1 #pragma config TRCEN = OFF #pragma config BOOTISA = MIPS32 #pragma config FSLEEP = OFF #pragma config DBGPER = PG_ALL #pragma config SMCLR = MCLR_NORM #pragma config SOSCGAIN = GAIN_2X #pragma config SOSCBOOST = ON #pragma config POSCGAIN = GAIN_LEVEL_3 #pragma config POSCBOOST = ON #pragma config EJTAGBEN = NORMAL #pragma config CP = OFF /*** DEVCFG1 ***/ #pragma config FNOSC = SPLL #pragma config DMTINTV = WIN_127_128 #pragma config FSOSCEN = OFF #pragma config IESO = ON #pragma config POSCMOD = HS #pragma config OSCIOFNC = OFF #pragma config FCKSM = CSECME #pragma config WDTPS = PS1048576 #pragma config WDTSPGM = STOP #pragma config FWDTEN = OFF #pragma config WINDIS = NORMAL #pragma config FWDTWINSZ = WINSZ_25 #pragma config DMTCNT = DMT31 #pragma config FDMTEN = OFF /*** DEVCFG2 ***/ #pragma config FPLLIDIV = DIV_1 #pragma config FPLLRNG = RANGE_5_10_MHZ #pragma config FPLLICLK = PLL_POSC #pragma config FPLLMULT = MUL_48 #pragma config FPLLODIV = DIV_4 #pragma config VBATBOREN = ON #pragma config DSBOREN = ON #pragma config DSWDTPS = DSPS32 #pragma config DSWDTOSC = LPRC #pragma config DSWDTEN = OFF #pragma config FDSEN = ON #pragma config BORSEL = HIGH #pragma config UPLLEN = OFF /*** DEVCFG3 ***/ #pragma config USERID = 0xffff #pragma config FUSBIDIO2 = ON #pragma config FVBUSIO2 = ON #pragma config PGL1WAY = ON #pragma config PMDL1WAY = ON #pragma config IOL1WAY = ON #pragma config FUSBIDIO1 = ON #pragma config FVBUSIO1 = ON /*** BF1SEQ0 ***/ #pragma config TSEQ = 0x0000 #pragma config CSEQ = 0xffff static inline __attribute__((always_inline)) void HardwareUseMultiVectoredInterrupts( void ) { __builtin_disable_interrupts(); /* Enable multi-vector interrupts. */ _CP0_BIS_CAUSE( 0x00800000U ); INTCONSET = _INTCON_MVEC_MASK; __builtin_enable_interrupts(); } #define PPSUnLock() {SYSKEY=0x0;SYSKEY=0xAA996655;SYSKEY=0x556699AA;CFGCONbits.IOLOCK=0;} #define PPSLock() {CFGCONbits.IOLOCK=1;SYSKEY=0x0;} #define RX5_TRIS TRISAbits.TRISA7 #define TX5_TRIS TRISBbits.TRISB14 #define RX5_PINREG U5RXR #define TX5_PINREG RPB14R #define RX5_Init() {RX5_TRIS=1;} #define TX5_Init() {TX5_TRIS=0;} #define RX4_TRIS TRISDbits.TRISD5 #define RX4_ANSEL ANSELDbits.ANSD5 #define TX4_TRIS TRISCbits.TRISC6 #define RX4_PINREG U6RXR #define TX4_PINREG RPC6R #define RX4_Init() {RX4_TRIS=1;RX4_ANSEL=0;} #define TX4_Init() {TX4_TRIS=0;} void __ISR(_UART6_RX_VECTOR, IPL3AUTO) UART6Interrupt(void) { static unsigned char value; while(U6STA & _U6STA_URXDA_MASK) { value=U6RXREG; buffer[pointer++]=value; } IFS5CLR = _IFS5_U6RXIF_MASK; } void __ISR(_UART5_RX_VECTOR, IPL3AUTO) UART5Interrupt(void) { static unsigned char value; while(U5STA & _U5STA_URXDA_MASK) { value=U5RXREG; buffer5[pointer5++]=value; } IFS2CLR = _IFS2_U5RXIF_MASK; } int main ( void ) { /* Initialize all MPLAB HARMony modules, including application(s). */ SYS_Initialize ( NULL ); //Harmony generated WDTCONSET=_WDTCON_ON_MASK; WDTCONbits.WDTCLRKEY=0x5743; RX6_Init(); TX6_Init(); RX5_Init(); TX5_Init(); PPSUnLock(); RX6_PINREG=9; TX6_PINREG=11; RX5_PINREG=7; TX5_PINREG=11; PPSLock(); while(1) { //main } } Any idea what I`m doing wrong?! Thanks! |
|
相关推荐
12个回答
|
|
|
但不是全部。缓冲区[指针++] =值;Buffer-5[PoTeN5++]=值;那么,是什么使你保持在每个缓冲区内?
以上来自于百度翻译 以下为原文 but not all. buffer[pointer++]=value; buffer5[pointer5++]=value; so what keeps you inside each buffer? |
|
|
|
|
|
什么也不能阻止我!这是原始代码:我在其他PIC32中使用它没有任何问题。问题不是我呆在里面,而是在不同的UXRX上触发多个中断。我想问题是在初始化过程中。我将尝试使用和声PIN设置重复这个…
以上来自于百度翻译 以下为原文 Nothing keeps me inside! This is the original code: void __ISR(_UART5_RX_VECTOR, IPL3AUTO) UART5Interrupt(void) { static unsigned char value; while(U5STA & _U5STA_URXDA_MASK) { value=U5RXREG; RS485_Port5_IncomeBuffer[RS485_Port5_IncomeBuffer_Pointer]=value; RS485_Port5_IncomeBuffer_Pointer++; RS485Port5_Properties.UpdateTicks=0; if(RS485_Port5_IncomeBuffer_Pointer>=RS485_PORT5_INCOMEBUFFER_SIZE) { RS485_Port5_IncomeBuffer_Pointer=0; RS485_Port5_Reloaded=1; } } IFS2CLR = _IFS2_U5RXIF_MASK; } I`ve used this with other PIC32 without any problems. And the problem is not I`m staying inside, but triggering multiple interrupts on different UxRX. I suppose the problem is in the initialization. I`ll try to repeat this using Harmony pin setup... |
|
|
|
|
|
当代码不完整和混合时,它很难帮助——你使用RX6,但是定义了你从来没有提到过RX6等等。你当然需要留在那些缓冲区内,不管你做了什么,这都是个问题。根据您如何诊断您的问题,您可能会看到RX缓冲区数据从一个引脚到另一个RX缓冲区的数据,因为指针递增到另一个,这就是缓冲区溢出的无害版本。
以上来自于百度翻译 以下为原文 Its difficult to help when the code is incomplete and mixed up- you use RX6, but the defines you have never refer to RX6, etc. You certainly need to stay inside those buffers, and it is a problem no matter what else you have going on. Depending on how you are diagnosing your problem, you may see rx buffer data from one pin go into rx buffer data of another due to the pointer incrementing into the other- and that's the harmless version of the buffer overrun. |
|
|
|
|
|
嗨,又来了!现在一切都很好。只有我的错误处理功能不好。这里是我的代码:问题是当我激活这个中断(IEC1SET=IIEC1U2EIAY掩码)时,它会被FER错误不断触发。没有它,一切都在运转,但是当我打开它的时候,我永远无法摆脱那个中断。它在我初始化UART后不久发生。在线路上没有传输-没有输入或输出数据……我做错了什么?!
以上来自于百度翻译 以下为原文 Hi, again! Everything is just fine now. Only my error handle function is not OK. Here is my code: calculatedValue=(_XTAL_FREQ/(4*baudrate))-1; U2BRG=calculatedValue; U2MODEbits.CLKSEL=1; U2MODECLR=_U2MODE_RTSMD_MASK; U2MODECLR=_U2MODE_UEN0_MASK; U2MODESET=_U2MODE_BRGH_MASK; U2MODECLR=_U2MODE_LPBACK_MASK; U2MODECLR=_U2MODE_PDSEL0_MASK; U2MODECLR=_U2MODE_STSEL_MASK; U2MODECLR=_U2MODE_ABAUD_MASK; U2STASET=_U2STA_URXEN_MASK; U2STASET=_U2STA_UTXEN_MASK; U2STACLR=_U2STA_URXISEL0_MASK; U2STACLR=_U2STA_ADDEN_MASK; IEC1SET=_IEC1_U2EIE_MASK;//error int enable IPC14bits.U2EIP=7; //error priority IPC14bits.U2EIS=7; IEC1bits.U2EIE=1; IEC1SET=_IEC1_U2RXIE_MASK; IPC14bits.U2RXIP=6; IPC14bits.U2RXIS=6; U2MODESET=_U2MODE_ON_MASK; //Error int void __ISR(_UART2_FAULT_VECTOR, IPL7AUTO) UART2Error() { static int c; while (U2STA & _U2STA_URXDA_MASK) c = U2RXREG; U2STACLR = _U2STA_OERR_MASK; } The problem is when I activate this interrupt(IEC1SET=_IEC1_U2EIE_MASK) it triggers constantly by FERR error. Without it everything is working, but when I turn it on I never get out of that interrupt. It happens soon after I initialize the UART. There is no transmition on the line - no in or out data... What am I doing wrong?! |
|
|
|
|
|
|
|
|
|
|
|
这是我的PIN初始化功能:我有一个双向电平移位器连接到引脚-TXS0108EPWR。这一次我在线路上没有任何上拉电阻。如果你认为这是问题,我必须补充吗?!
以上来自于百度翻译 以下为原文 Here are my pin init functions: #define GSM_RX_TRIS TRISBbits.TRISB1 #define GSM_RX_ANSEL ANSELBbits.ANSB1 #define GSM_TX_TRIS TRISBbits.TRISB0 #define GSM_TX_ANSEL ANSELBbits.ANSB0 #define GSM_RX_PINREG U2RXR #define GSM_TX_PINREG RPB0R #define GSM_RX_Init() {GSM_RX_TRIS=1;GSM_RX_ANSEL=0;} #define GSM_TX_Init() {GSM_TX_TRIS=0;GSM_TX_ANSEL=0;} GSM_RX_Init(); GSM_TX_Init(); PPSUnLock(); GSM_RX_PINREG=2; GSM_TX_PINREG=2; PPSLock(); I have a bidirectional level shifter connected to the pins - TXS0108EPWR. This time I don`t have any pull up or down resistors on the lines. Do I have to add if you think this is the problem?! |
|
|
|
|
|
UART通常不需要上拉,因为销总是被驱动。但是在USAT上有一个可能的反转设置呢?(检查寄存器)
以上来自于百度翻译 以下为原文 No pullups are usually needed on a UART, since pins are always driven. But how about a possiblt invert-setting on the USART? (check registers) |
|
|
|
|
|
|
|
|
|
|
|
就我个人而言,我认为TX5PiReg和Tx6PiReg都设置为11有点冒险吗?试图把两个UART的TX绑在一个输出引脚上?
以上来自于百度翻译 以下为原文 Personally I thought that setting both TX5_PINREG and TX6_PINREG to 11 a bit dodgy? Trying to tie two uarts' TX on one output pin? |
|
|
|
|
|
我不会把2 UART绑在一个输出上!你在哪里看到的?关于错误处理有什么想法吗?你能给我举个例子吗?谢谢!
以上来自于百度翻译 以下为原文 I do not tie 2 UARTs on one output! Where did you see that?! Any ideas about the error handling?! Can you give me an example how do you do it?! Thanks! |
|
|
|
|
|
对不起的。事实上,你把其他两个引脚绑在同一个UART上:
以上来自于百度翻译 以下为原文 Sorry. It is indeed the other way around you tie two pins to the same uart: PPSUnLock(); RX6_PINREG=9; TX6_PINREG=11; // <- THIS RX5_PINREG=7; TX5_PINREG=11; // <- AND THIS PPSLock(); |
|
|
|
|
|
不!这是不正确的!TX6PiReg和TX5PiReg指向不同的寄存器!每一个寄存器11指向不同的引脚!好啊!我做到了!我只是添加了一个叫做函数的时间来检查ORR并清除它。不要中断!很好,谢谢大家!
以上来自于百度翻译 以下为原文 No! This is incorrect! TX6_PINREG and TX5_PINREG point to different registers! And every register 11 points to different pin! OK! I`ve done it! I just added a time called function which checks OERR and cleans it. No interrupt! And it works fine. if(timeout>TIMEOUT_VALUE) { if(U2STAbits.OERR==1) { U2STACLR = _U2STA_OERR_MASK; } timeout=0; } Thanks to everyone! |
|
|
|
|
只有小组成员才能发言,加入小组>>
MPLAB X IDE V6.25版本怎么对bootloader和应用程序进行烧录
475 浏览 0 评论
5795 浏览 9 评论
2334 浏览 8 评论
2224 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3530 浏览 3 评论
1125浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
1098浏览 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-3 04:14 , Processed in 3.789224 second(s), Total 94, Slave 77 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
2144