完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我使用PIC32MX110F016B-I/SP时遇到了麻烦。我试过几种不同版本的代码,结果各不相同。有时输出是胡言乱语,有时输出非常接近输入,这让我相信这个问题可能与BAUD速率和/或振荡器配置有关。以太或不是芯片实际上是运行程序。这也让我觉得我可能也不正确地做PPS。我已经成功地用PIC18F4550芯片连接到UART端点并与之通信,因此我不认为端点有问题。我有三个独立的PIC32MX110F016B芯片,当运行下面的代码时,它们都未能进行通信,所以我不认为问题也在芯片中。我在这里已经有一段时间了,我有点失落。如有任何帮助,我们将不胜感激。下面是我的代码的当前状态:
以上来自于百度翻译 以下为原文 I've been having trouble getting UART to work with my PIC32MX110F016B-I/SP. I've tried several different variations of the code with various results. Sometimes the output is gibberish, sometimes the output is very close to the input, which leads me to believe that the issue may be related to the BAUD rate and/or the oscillator configurations. For certain pins selected with PPS, the chip outputs a never ending stream of gibberish, regardless of whether or not the chip is actually running the program. This makes me also think that I might be doing the PPS incorrectly as well. I've been successful connecting and communicating to the UART endpoint with a PIC18F4550 chip so I don't believe there is an issue with the endpoint. I have three separate PIC32MX110F016B chips and they all have failed communicating when running with the code listed below, so I don't believe the issue is in the chips either. I've been at this for awhile and I'm at a bit of a loss. Any help would be appreciated. Here is the current state of my code: #include #include #include #include #pragma config FPLLODIV = DIV_2 #pragma config FPLLMUL = MUL_20 #pragma config FPLLIDIV = DIV_1 #pragma config FPBDIV = DIV_1 #pragma config FWDTEN = OFF #pragma config WDTPS = PS1 #pragma config FCKSM = CSECME #pragma config OSCIOFNC = OFF #pragma config POSCMOD = HS #pragma config IESO = ON #pragma config FSOSCEN = OFF #pragma config FNOSC = FRCPLL #pragma config CP = OFF #pragma config BWP = OFF #pragma config PWP = OFF #pragma config ICESEL = ICS_PGx1 // NB: set to correct channel #pragma config DEBUG = OFF #pragma config IOL1WAY = OFF #pragma config JTAGEN = OFF #define GetSystemClock() (80000000ul) #define GetPeripheralClock() (GetSystemClock()/(1 << OSCCONbits.PBDIV)) #define GetInstructionClock() (GetSystemClock()) void SendDataBuffer(const char *buffer) { UINT32 size = strlen(buffer); while(size) { while(!UARTTransmitterIsReady(UART2)); UARTSendDataByte(UART2, *buffer); buffer++; size--; } while(!UARTTransmissionHasCompleted(UART2)); } void main(void) { TRISA = 0xFF; // Set A register as output ANSELA = 0; TRISB = 0x00; // Set B register as output ANSELB = 0; // Set input/output for pins U2RXR = 0x0000; // configure the input U2RX to pin RPA1 RPB14R = 0x0002; // configure the output U2TX to pin RB14 UARTConfigure(UART2, UART_ENABLE_PINS_TX_RX_ONLY); UARTSetFifoMode(UART2, UART_INTERRUPT_ON_TX_NOT_FULL | UART_INTERRUPT_ON_RX_NOT_EMPTY); UARTSetLineControl(UART2, UART_DATA_SIZE_8_BITS | UART_PARITY_NONE | UART_STOP_BITS_1); UARTSetDataRate(UART2, GetPeripheralClock(), 9600); UARTEnable(UART2, UART_ENABLE_FLAGS(UART_PERIPHERAL | UART_RX | UART_TX)); SendDataBuffer("hellon"); WriteUART2(0x48); while(1) {} return; } |
|
相关推荐
4个回答
|
|
首先,该设备额定为最大50MHz操作,因此您的时钟配置完全错误。
以上来自于百度翻译 以下为原文 To start with, that device is rated for max 50MHz operation, so your clock configuration is completely wrong. |
|
|
|
啊,有趣。谢谢你指出来。我试过使用从8MHz到80MHz的各种不同的时钟速度,但是每次都失败了。还会有别的事情发生吗?
以上来自于百度翻译 以下为原文 Ah, interesting. Thanks for pointing that out. I've tried using various different clock speeds ranging from 8MHz to 80MHz but it still fails every time. Could there be something else going on? |
|
|
|
我终于明白出了什么问题。因为我的两个PIC之间的引脚布置方式不同,所以使用PICKit3为pic32供电总是比较方便(对于我的pic8芯片,我是从不同的电源供电)。从PICKit3为芯片供电的选择电压是3.25。我不确定选择的电压是否太低,或者来自PICKit3的电压是否只是不稳定的,或者我是否需要添加额外的电容器来稳定东西。无论如何,从稳定的3.3电压供电PIC32对我来说是个问题。
以上来自于百度翻译 以下为原文 At long last I figured out what was wrong. Because of the way the pins were laid out differently between my two PICs, it was always more convenient for me to power my pic32 with using the PICKit3 (for my pic8 chip, I was powering it from a different source). The chosen voltage from the PICKit3 to power the chip was 3.25. I'm unsure if the chosen voltage was just too low, or if the voltage coming from the PICKit3 was just unstable, or if maybe I needed to add additional capacitors to stabilize things. At any rate, powering the pic32 from a stable 3.3 voltage fixed the problem for me. |
|
|
|
嗨,我永远不会用镐子给PIC32供电,因为我知道镐子是30到50mA的。你应该用电源给PIC32供电,以避免电源摆动。当PIC32运行时,根据内部模块的不同,功耗也不同。这在编程时尤其如此。…问候
以上来自于百度翻译 以下为原文 Hi, I would never power PIC32 with a pickit3...knowing that it is speced to deliver 30 to 50mA. You should really use a power supply for your PIC32 to avoid power supply swings... While PIC32 runs, depending upon internal modules the power consumptions varies. This is especially true during programming... Regards |
|
|
|
只有小组成员才能发言,加入小组>>
5158 浏览 9 评论
1997 浏览 8 评论
1926 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3169 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2222 浏览 5 评论
723浏览 1评论
606浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
494浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
620浏览 0评论
519浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-19 13:23 , Processed in 1.381277 second(s), Total 85, Slave 68 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号