完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我使用MPLAB X IDE 3.4与代码配置插件(MCC)。我用MCC把EUSAT外设添加到我的项目中。我在异步模式中使用EUSAT。在PIN管理器中,我分配了TX和RX引脚。我有一个主16F1778,发送到从16F1778谁是监听大师TX。的范围,我可以看到有效的TX数据在RX引脚从奴隶16F1778。我的波特率是115200,所以测量的比特率应该是87.US,这正是我在示波器上测量的。我可以开始和停止位以及数据,我只是发送一个字节的数据0x33,我看到的范围。数据看起来是有效的。做一些调试时,我看到EUSAT没有通知它已经接收到数据。它坐在下面的循环中,从不退出:我尝试移除EUSAT外围设备并读取它,但仍然是相同的。我试着把RX管脚换成不同的别针,但仍然不行。我通过论坛和网络搜索过,我的人有过类似的问题,我尝试过为他们工作但不为我工作的修复。下面是引脚设置。这是由MCC产生的。在有人回答端口B(其中TX和RX引脚是)需要设置为零在ANSELB寄存器,我已经尝试做,但它仍然不会收到。奇怪的是,MCC将这些引脚设置为模拟,如果它们应该是数字的。我已经尝试了EUART的中断和没有,并采取相同的方式。通过中断启用,我从未得到ISR的火灾,显示没有有效的数据已被读取。我怀疑RX电路没有被打开。空隙PixMauner-Read(空隙){/**LATX寄存器*/LATA= 0x00;LATC= 0x00;/**TrISX寄存器*/tiSISE=0x08;TrISA=0xAF;TrISB= 0xF0;TrISC= 0x1C;/**ANSELX寄存器*/ANSELC= 0xF0;ANSELB=0x2F;ANSELLA=0x3f;/**= 0x08;WPUA= 0xFF;WPUC=0xFF;/**ODX寄存器*/OdCONa=0x00;OdCONB= 0x00;BOOL状态=GIE;GIE=0;PPSROCK=0x55;PPSROCKIT=0XAA;PPSLIOBITS=PPXCOLD=0x00;//解锁PPSRXPPPSIT.RXPPS= 0x0C;//RB4--Gt;EUARTAR:RX;RC6PPSBITS.RC6。WPUX寄存器*/WPUEPPS= 0x1f;//RC6-和;pWM11:PWM11OUT;RB3PPsBIT.RB3PPS= 0x24;//RB3--Gt;EUSAART:TX;PPSROCK=0x55;PPSROCK=0xAA;PPSROCKBITS。PPsLoCK=0x01;//锁定PPSGEE=状态;}
以上来自于百度翻译 以下为原文 I'm using MPLAB X IDE 3.4 with the code configurator plugin (MCC). I used the MCC to add the EUSART peripheral to my project. I'm using the EUSART in asynchronous mode. In the Pin Manager I assigned TX and RX pins. I have a master 16F1778 that is transmitting to a slave 16F1778 who is listening for the masters TX. With the scope I can see valid TX data at the RX pin of the slave 16F1778. My baud rate is 115200 so the measured bit rate should be 8.7uS, which is exactly what I measure on the oscilloscope. I can the start and stop bit as well as the data, I am just sending one byte with data of 0x33 which I see on the scope. The data looks valid. Doing some debug I see that the EUSART is not signaling that it has received data. It sits in the while loop below, never exiting: while( !PIR1bits.RCIF) { } I've tried removing the EUSART peripheral and readding it but still acts the same. I've tried changing the RX pin to a different pin but it still won't work. I've searched through the forums and the web, I people have had similar issues and I've tried the fixes that worked for them but not working for me. Below is the pin set up. This was generated by the MCC. Before someone replies that port B (where the TX and RX pins are) need to be set to zero in the ANSELB register, I have tried doing that but it still won't receive. It's strange that the MCC sets those pins to analog if they are supposed to be digital. I've tried the EUSART with interrupts and without and acts the same either way. With interrupts enabled I never get the ISR to fire showing no valid data has been read in. I suspect the RX circuit is not getting turned on. void PIN_MANAGER_Initialize(void) { /** LATx registers */ LATA = 0x00; LATB = 0x00; LATC = 0x00; /** TRISx registers */ TRISE = 0x08; TRISA = 0xAF; TRISB = 0xF0; TRISC = 0x1C; /** ANSELx registers */ ANSELC = 0xF0; ANSELB = 0x2F; ANSELA = 0x3F; /** WPUx registers */ WPUE = 0x08; WPUB = 0xFF; WPUA = 0xFF; WPUC = 0xFF; /** ODx registers */ ODCONA = 0x00; ODCONB = 0x00; ODCONC = 0x00; bool state = GIE; GIE = 0; PPSLOCK = 0x55; PPSLOCK = 0xAA; PPSLOCKbits.PPSLOCKED = 0x00; // unlock PPS RXPPSbits.RXPPS = 0x0C; //RB4->EUSART:RX; RC6PPSbits.RC6PPS = 0x1F; //RC6->PWM11:PWM11OUT; RB3PPSbits.RB3PPS = 0x24; //RB3->EUSART:TX; PPSLOCK = 0x55; PPSLOCK = 0xAA; PPSLOCKbits.PPSLOCKED = 0x01; // lock PPS GIE = state; } |
|
相关推荐
4个回答
|
|
在代码中,你会发现这是真的。我建议张贴所有代码,而不是只是你认为“问题”包含的问题/答案。此外,请使用代码标签:[C0De]和[/c0D]在代码之后,用一个小写字符替换0(0字符)。这里使用零来获得标记字符来显示。
以上来自于百度翻译 以下为原文 Well in the code you show that is certainly true. I suggest posting ALL the code rather then just the part you "think" contains the problem/answer. Also please use code tags: [c0de] before and [/c0de] after your code, replace the zero (0 char) with a lower case character o. Zero is used here to get the tag characters to show. |
|
|
|
这里是EasAR.C文件
以上来自于百度翻译 以下为原文 Here is the eusart.c file /** Section: Included Files */ #include "eusart.h" #include "pin_manager.h" /** Section: EUSART APIs */ void EUSART_Initialize(void) { // Set the EUSART module to the options selected in the user interface. // ABDOVF no_overflow; SCKP Non-Inverted; BRG16 16bit_generator; WUE disabled; ABDEN disabled; BAUD1CON = 0x08; // SPEN enabled; RX9 8-bit; CREN enabled; ADDEN disabled; SREN disabled; RC1STA = 0x90; // TX9 8-bit; TX9D 0; SENDB sync_break_complete; TXEN enabled; SYNC asynchronous; BRGH hi_speed; CSRC slave; TX1STA = 0x24; // Baud Rate = 115200; SP1BRGL 68; SP1BRGL = 0x44; // Baud Rate = 115200; SP1BRGH 0; SP1BRGH = 0x00; } uint8_t EUSART_Read(void) { IO_RB2_SetLow(); //Set data direction for RX. while(!PIR1bits.RCIF) { } if(1 == RC1STAbits.OERR) { // EUSART error - restart RC1STAbits.CREN = 0; RC1STAbits.CREN = 1; } return RC1REG; } void EUSART_Write(uint8_t txData) { IO_RB2_SetHigh(); //Set data direction for TX. while(0 == PIR1bits.TXIF) { } TX1REG = txData; // Write the data byte to the USART. } /** End of File */ |
|
|
|
这是我对主循环中的EUSAT函数的调用:
以上来自于百度翻译 以下为原文 This is my calls to the EUSART functions in the main loop: /* Main application */ void main(void) { // initialize the device SYSTEM_Initialize(); // When using interrupts, you need to set the Global and Peripheral Interrupt Enable bits // Use the following macros to: // Enable the Global Interrupts INTERRUPT_GlobalInterruptEnable(); // Enable the Peripheral Interrupts INTERRUPT_PeripheralInterruptEnable(); // Disable the Global Interrupts //INTERRUPT_GlobalInterruptDisable(); // Disable the Peripheral Interrupts //INTERRUPT_PeripheralInterruptDisable(); adc_result_t convertedValue = 0; /* PHASESEL */ //disableInt(); //convertedValue = ADC_GetConversion(channel_AN16); //enableInt(); if( convertedValue >= 0x3F0 && convertedValue <= 0x3FF ) { isMaster = 1; } else if( convertedValue >= 0x1AE && convertedValue <= 0x233 ) { isB = 1; } else isC = 1; /* Main Loop */ while (1) { //IO_RA6_SetHigh(); if(!IO_RC2_GetValue()) IO_RB1_SetHigh(); else IO_RB1_SetLow(); //uint8_t txData = 0xA5; uint8_t rxData = 0x00; //uint8_t rxData1 = 0xFF; /* Discovery */ if(isMaster){ EUSART_Write(discoverPacketAID); //EUSART_Write(discoverPacketData); //} else if(isB || isC){ rxData = EUSART_Read(); //rxData1 = EUSART_Read(); if(rxData == 0x01) discComplete = 1; } if( rxData == 0x33 && (isB || isC) && (!Bphase || !Cphase) ){ Bphase = 1; Cphase = 1; } } |
|
|
|
第一个想法:在所有其他外围配置完成之后,设置SPEN。请注意设备的勘误表1.1。
以上来自于百度翻译 以下为原文 First thought: set SPEN only after all other peripheral configuration is done. Beware Errata 1.1 for your device. |
|
|
|
只有小组成员才能发言,加入小组>>
5171 浏览 9 评论
2001 浏览 8 评论
1931 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3176 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2228 浏览 5 评论
737浏览 1评论
622浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
509浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
635浏览 0评论
533浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-26 07:16 , Processed in 1.312685 second(s), Total 85, Slave 68 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号