完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
我试图获得UART1,这有TX引脚在RC6和RX引脚上的RC7,在工作中。我的初始化例程几乎与我经常使用的一样,但我不能接收和/或发送数据。在UART初始化后,TX引脚保持低而不是高。PIC18F67 K40具有PPS寄存器重新映射引脚,但我使用的RX/TX引脚默认为…所以我不认为我必须做点什么…还是我错了?我的传输数据的测试代码如下:RC1STA= 0B100000;//启用串行端口PoS1BRGH=SPBRGVALY/256;SP1BRGL=SPBRG值% 256;BUD1CONC=0B000 1001000;//BRG16= 1TX1STA= 0B00 100100;//TX使能,高SeaDrc1Stist.CREN=1;/ /可接收(1){CrRWdTh();Trim0=1;Tx1Stest.TrMT){};Tx1Reg=“a”;Trim0=0;希望有人能帮助,克里斯
以上来自于百度翻译 以下为原文 I am trying to get UART1, that has the TX pin on RC6 and RX pin on RC7, at work. My initialisation routines are almost the same as i have used often but i cannot receive and/or sent data. After UART initialisation the TX pin stays low instead of high. The PIC18F67K40 has PPS registers to remap pins, but i use the rx/tx pins that are stated as default... so i don't think i have to do something with it... or am i wrong ? My test code for transmitting data is as follows: RC1STA = 0b10000000 ; // enable serial port SP1BRGH = spbrgvalue/256 ; SP1BRGL = spbrgvalue%256 ; BAUD1CON = 0b00001000 ; // BRG16=1 TX1STA = 0b00100100 ; // tx enable, high speed RC1STAbits.CREN = 1 ; // receive enable while(1){ CLRWDT(); trig0=1; while(!TX1STAbits.TRMT){}; TX1REG='A'; trig0=0; } Hope someone can help, Chris |
|
相关推荐
6个回答
|
|
[开始免责声明]我没有PIC18F67 K40来测试,但我已经用PIC18F27 K40实现了几个小项目。她是我的拿手。[最终免责声明]首先……没有TX1输出的“默认”值。你需要把任务分配给RC6PPS:我需要像下面这样的东西:没有这个声明,我的RC6引脚仍然没有被驱动。(浮动)在“范围”上看起来有点噪音低,请注意,您的芯片的许多PPS功能与我的不同,使用数据表中的寄存器17-2表的值!其次,请注意,对于接收,RX1有一个默认的赋值,但是您仍然必须清除正确的安塞尔位以使其有效。对于我的项目,我总是做出明确的赋值(浪费一个指令来确定),并且在我决定将它改为UART2的情况下充当占位符。这无济于事,我建议你发布一个完整的(小)程序。也许有人能帮你弄清事情的真相。问候,戴夫
以上来自于百度翻译 以下为原文 [Begin Disclaimer] I don't have a PIC18F67K40 to test, but I have implemented a couple of small projects with a PIC18F27K40. Her's my take on it. [End Disclaimer] First of all... There is no "default" value for TX1 output. You need to make the assignment to RC6PPS: I need something like the following: // Assign TX1 to RC6 RC6PPS = 0b01001; // This is for a PIC18F27K40 Without that statement, my RC6 pin remains undriven. (Floats and looks like a somewhat noisy low value on the 'scope.) Note that many of the PPS functions for your chip are different from mine; Use values from the Register 17-2 table in your data sheet! Secondly... Note that for receiving, there is a default assignment for RX1, but you still must clear the correct ANSEL bit to make it work. For my project, I always make the explicit assignment (Waste an instruction to "make sure" and to act as a placeholder in case I decide to change it to UART2): // Default assignment for RX1 is RC7, so this is optional RX1PPS = 0b10111; // This is for a PIC18F27K40 // This is not optional! It is not taken care of by the PPS assignment // or by enabling the USART ANSELCbits.ANSELC7 = 0; If this doesn't help, I suggest you post a complete (small) program. Maybe someone can help you get to the bottom of things. Regards, Dave |
|
|
|
跳过这个帖子,我误解了数据表…我同意,根据UART1的数据表,PPS默认值是“上电复位后RC6上的TX引脚和RC7上的RX引脚”。表17.1 PPS输入寄存器DigiLeSuSART1接收,RX1PPS,RC7EUSAT1传输,TX1PPS,RC6,但是我到了我的极限,为什么他们在“P”下列出TX1PPS。PS输入寄存器细节“,所以更好地遵循以前的建议。你确保你的PIC是在运行,也就是说你的TIG0切换创建一个开关信号吗?如何测量TX PIN?
以上来自于百度翻译 以下为原文 edit < skip this post, I misinterpreted the data sheet ... > I would have agreed that according to the datasheet for UART1 the PPS defaults are "TX pin on RC6 and RX pin on RC7" after Power On Reset. Table 17.1 PPS INPUT REGISTER DETAILS EUSART1 Receive, RX1PPS, RC7 EUSART1 Transmit, TX1PPS, RC6 However I come to my limits, - why do they list TX1PPS under "PPS Input Register Details". So better follow previous advice. Did you ensure your PIC is running at all, i.e. does your trig0 toggling create a switching signal ? How do you measure TX pin ? |
|
|
|
不,PPS输出寄存器的默认设置在开机时未定义。“7K40”数据表的表17-1是用于输入分配,而不是输出。也许表17-1有点误导,但是寄存器17-2:RXYPPS:PIN RXY输出源选择寄存器设置“清楚”显示输出寄存器值在电源复位时都为零。(在布朗退出复位的情况下未定义)我的测试是在实际的硬件项目板上(以及电路板和好奇心HPC等)。我陈述了我用PIC18F27 K40和我的测试观察所做的事情,并且我的经验告诉我明确设置PPS输出寄存器值的必要性。时期,问候,戴夫
以上来自于百度翻译 以下为原文 No. Default settings for PPS Output registers are undefined at power-on. Table 17-1 of the '67K40 data sheet is for input assignments, not outputs. Maybe the Table 17-1 is a little misleading, but REGISTER 17-2: RxyPPS: PIN Rxy OUTPUT SOURCE SELECTION REGISTER settings "clearly" shows output register values are all zero upon Power On Reset. (And undefined in case of Brown Out Reset.) My testing is on actual hardware project boards (and breadboards and Curiosity HPC, etc). I stated what I had to do with the PIC18F27K40 and my test observations, and my experience shows me the necessity of explicitly setting PPS output register values. Period. Regards, Dave |
|
|
|
是的,最好不要理会我对数据表的误解。
以上来自于百度翻译 以下为原文 Yep, better ignore my misinterpretation of the data sheet. |
|
|
|
你好,戴夫,谢谢,现在开始工作了!我没有读数据表,但通过你的答案,我能弄清楚我做错了什么。对于RX,默认设置为TX输出,但不用于TX输出。我忽略了这一点。在我的应用中,我遇到了同样的问题,在我的应用程序中,我现在有2个工作的UART通道和一个工作的CCP通道,具有以下任务:Re5PPS= 0x05;/CCP1 RC6PPS= 0x0C;//TX1 OPRC6RG1PPS= 0x0e;//TX2 OP RG1RODIMS:我有一个关于TX输出的范围的探索。控制器的。我也有一个关于RB6的探针,我用它作为触发输出(TIG0)。所以我可以看到程序正在运行…但现在我的另一个问题是我的Prttf语句不起作用(见另一个帖子),克里斯
以上来自于百度翻译 以下为原文 Hello Dave, Thanks, It works now ! I didn't read the datasheet not well, but with your answers i was able to figure out what i did wrong. For rx the default is set, but not for tx output. I overlooked that. I got the same problem with a 'not working' CCP1 channel. In my application i have now 2 working Uart channels and a working CCP channel with the following assignments: RE5PPS=0x05; // CCP1 RC6PPS=0x0C; // TX1 op RC6 RG1PPS=0x0E; // TX2 op RG1 For Rodims: I have a probe of my scope on the tx output of the controller. I also have a probe on RB6 which i use as a trigger output (trig0). So i can see that the program is running. ... but now i have another problem with my printf statement that doesn't work (see another posting) regards, Chris |
|
|
|
论坛上有大约一百万篇关于K40设备和Prtff()和其他故障的帖子。(参见脚注)。例如:http://www. McCys.com /论坛/ M9875 71.ASPX第9875 93页,DaveFootnote:从我爸爸那里说:“如果我告诉过你一次,我已经告诉过你一百万次:不要夸张!”
以上来自于百度翻译 以下为原文 There are about a million posts about 'K40 devices and printf() and other malfunctions on this forum. (See Footnote). For example: http://www.microchip.com/forums/m987571.aspx#987593 Regards, Dave Footnote: From my dad: "If I've told you once, I've told you a million times: Don't exaggerate!" |
|
|
|
只有小组成员才能发言,加入小组>>
5244 浏览 9 评论
2035 浏览 8 评论
1955 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3214 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2261 浏览 5 评论
779浏览 1评论
672浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
598浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
682浏览 0评论
579浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-25 16:28 , Processed in 1.346226 second(s), Total 87, Slave 70 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号