完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我在本论坛的其他地方看到,在PIC32上,不应该使用SFR上的双字段结构,而应该使用SET、CLR、INV寄存器。RMW正在发生。由于MIPS核心没有位集和CLR操作码,如何设置,CLR,IV实现?编译器是否在PIC32上实现BITFEAR结构为SET、CLR、IV?把这些东西放到门上是不对的吗?
以上来自于百度翻译 以下为原文 I read else where in this forum that on the PIC32 you shouldn't be using the bifield structs on the SFR's and we should be using the SET, CLR, INV registers instead. The reason given was that using bitfields results in RMW operations and could cause issues if an interrupt hits in between while that RMW is taking place. Since the MIPS core does not have Bit set and clr opcodes how are SET, CLR, INV implemented? Does the compiler implement bitfield structs as SET, CLR, INV on the PIC32? Is it wrong to do LATBbits.LATB0 = 0; or something on these lines. |
|
相关推荐
14个回答
|
|
为了在外设上提供单周期位操作,外围设备中的寄存器可以根据外围地址以三种不同的方式访问。每个寄存器有四个不同的地址。虽然四个不同的地址出现为不同的寄存器,但它们实际上是四种不同的方法来处理相同的物理寄存器。基寄存器地址提供正常的读/写访问,而其他的三提供特殊的只读函数。原子RMW访问:清除位原子RMW访问。颠倒位原子RMW访问参考手册。见2.8设置/清除/反相
以上来自于百度翻译 以下为原文 To provide single-cycle bit operations on peripherals, the registers in the peripheral units can be accessed in three different ways depending on peripheral addresses. Each register has four different addresses. Although the four different addresses appear as different registers, they are really just four different methods to address the same physical register. The base register address provides normal Read/Write access, while the other three provide special write-only functions. • Normal access • Set bit atomic RMW access • Clear bit atomic RMW access • Invert bit atomic RMW access Reference Manual. See 2.8 SET/CLEAR/INVERT |
|
|
|
因此,当我们使用位场结构时,它将具有普通RMW访问,而SET、CLR、INV将具有原子RMW访问?因此,如果SFR在主和中断都使用,那么我们应该使用SET、CLR、INV等原子访问命令,这是否正确?但如果只写访问,那么为什么称之为“原子RMW访问”呢?
以上来自于百度翻译 以下为原文 So when we use the Bitfield structs it would have Normal RMW access whereas the SET, CLR, INV will have atomic RMW access? So is it correct that if the SFR's are being used both in main as well as in interrupts then we should use the atomic access commands like SET, CLR, INV. But if the access is write only then why is it called "atomic RMW access"? |
|
|
|
|
|
|
|
很高兴听到…有一些宏,比如mPortBClearBits()、mPortBDirection()等等。也许我应该开始使用这些宏……对不起,我没有得到那个->read.write,那么它怎么不读回呢?
以上来自于百度翻译 以下为原文 Good to hear that ... there are some macros like mPortBClearBits(), mPortBDirection() etc. maybe I should start using those ... I'm sorry I didn't get that -> read modify write then how does it not read back? |
|
|
|
一个很大的问题,因为MIPS核心使用LL(Load Link Word)和SC(存储条件字)。SC总是由LL进行。使用反汇编窗口查看LL和SC MIPS核心是如何被调用的。从外科手术中摆脱出来,希望这是有意义的。
以上来自于百度翻译 以下为原文 Great question, as MIPS Core uses LL (Load Linked Word) and SC (Store condition Word). SC is always proceeded by LL. Use the disassembly window to look to see how LL and SC MIPS core are being called. TIP: From MLAB-XC32-Uusers-Guide.pdf 3.4.4.2 HOW CAN I ACCESS INDIVIDUAL BITS OF A VARIABLE Still a little out of it from surgery, hope this makes sense. |
|
|
|
我的意思是,使用SET/CLR/IV,你不会回信。使用正常指令和SFR访问,您必须。
以上来自于百度翻译 以下为原文 I mean, using SET/CLR/INV you're not reading back. Using normal instruction and SFR access, you have to. |
|
|
|
我不会谈论周期。外围访问比CPU慢一些,所以无论如何要经历很多周期。如果您使用位字段,那么将会有一个读取寄存器的命令,至少一个要修改的命令,以及一个要写入的命令(因此最小为3)。
以上来自于百度翻译 以下为原文 I wouldn't speak about cycles. Periphery access is somehow slower than CPU, so it'll be many cycles anyway. If you use a bit-field, there will be a command to read the register, at least one command to modify, then a command to write (so minimum 3). This compares to 1 command with SET/CLR/INV. |
|
|
|
我不知道。可能是在某种程度上的优化。
以上来自于百度翻译 以下为原文 I don't know. May be it does at some level of optimization. |
|
|
|
我在一年前提出问题后发现编译器没有,部分和睦没有使用非RMW操作码。也许我应该投一张支持票。
以上来自于百度翻译 以下为原文 I asked that question over a year ago after finding out the compiler did not, and Parts of Harmony did not use the non rmw opcodes. Maybe I should put in a support ticket. |
|
|
|
为什么?这些都是等价物。”任何事物,不仅可以是常量,也可以是任意的表达。
以上来自于百度翻译 以下为原文 Why? These are equivalents. "anything" can not only be a constant, but also can be an arbitrary expression. SFR |= anything; SFRSET = anything; SFR &= ~anything; SFRCLR = anything; SFR ^= anything; SFRINV = anything; |
|
|
|
为什么?这些都是等价物。”任何事物“不仅可以是常量,也可以是任意表达式。然而,编译器不知道SFR是SFR。它所看到的是一个指针,在设备头文件中定义为Extn,其地址可能因设备而异。与SFRSET等相同,MIPS没有对内存进行操作,因此,虽然您的示例在语义上是等价的,但在操作中它们不是。SFRSET=任何东西都是一个简单的存储。SFR=任何东西都是一个加载OP存储序列。对于BITFELD操作,编译器将使用插入/提取操作码。
以上来自于百度翻译 以下为原文 Why? These are equivalents. "anything" can not only be a constant, but also can be an arbitrary expression. SFR |= anything; SFRSET = anything; SFR &= ~anything; SFRCLR = anything; SFR ^= anything; SFRINV = anything; However, the compiler doesn't know that SFR is an SFR. All it sees is a pointer, defined as extern in the device header file, whose address may vary from device to device. Same with SFRSET etc. MIPS doesn't do operations on memory, so while your examples are semantically equivalent, in operation they are not. SFRSET=anything is a simple store. SFR|=anything is a load-op-store sequence. For bitfield operations the compiler will use the INSert/EXTract op-codes. |
|
|
|
编译器是软件,所以是可能的。另一个故事有多困难。但是你的观点被采纳了。编译器并不天生知道那些位字段是特殊的。
以上来自于百度翻译 以下为原文 The compiler is software, so it is possible. How difficult is another story. But your point is taken. The compiler does not innately know that those bit fields are special. |
|
|
|
字段=变量;这是一个集合,清除,还是反转?
以上来自于百度翻译 以下为原文 SFR.field = variable; Is this a set, clear, or invert? |
|
|
|
|
|
|
|
只有小组成员才能发言,加入小组>>
4814 浏览 9 评论
1823 浏览 8 评论
1743 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
2949 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2055 浏览 5 评论
452浏览 1评论
1107浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
355浏览 0评论
260浏览 0评论
LAN9252使用SQI通信,进行数字复位后读BYTE_TEST异常
1777浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-4-18 09:04 , Processed in 1.219929 second(s), Total 85, Slave 72 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号