完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
嗨,我有这个函数:但是地址位于cpu寄存器r04,变量操作(地址|=0b10000000)是不可能的。我试图定义这个函数,如(void)lcd_set_cursor_at_address(易失性无符号字符地址),但是地址总是位于r04 cpu寄存器mplabXC32com中。皮勒用户指南81.2表示:…Valayle Qualisher并不保证任何访问都是原子的,但是编译器会尝试实现这一点。……我该如何解决这个问题?pic是pic32mx440f256hxc32 v1.42,在windows 10(在项目属性中)优化级别是0pre-optimization指令调度=default for optimization levelpost-optimization指令调度=default for optimization级别
以上来自于百度翻译 以下为原文 Hi, I have this function : (void) lcd_set_cursor_at_address (unsigned char address) { address |= 0b10000000; //most significant bit must be 1 for lcd command lcd_command(address); } but address is located at cpu register r04 and variable manipulation (address |= 0b10000000) is not possible. I tried to define this function like (void) lcd_set_cursor_at_address ( volatile unsigned char address) but address is always located in r04 cpu register mplab XC32 compiler user guide 8.10.2 says: ..... The VOLATYLE qualyfier does not guarantee tha any access will be atomic, but the compiler will try to implement this. ..... How do i solve this issue? pic is pic32mx440f256h xc32 v1.42 on windows 10 (in project properties) optimization-level is 0 pre-optimization instruction scheduling = default for optimization level post-optimization instruction scheduling = default for optimization level |
|
相关推荐
10个回答
|
|
|
|
|
|
指令地址=0B100000;没有影响:最高有效位保持为0。
以上来自于百度翻译 以下为原文 the instruction address |= 0b10000000; has no effect: most significant bit remain to 0 |
|
|
|
你怎么知道高比特没有改变?什么版本MPLABX?XC32的版本是什么?
以上来自于百度翻译 以下为原文 How do you know the high bit is not changed? What version mplabx ? What version of XC32? |
|
|
|
根据配置和声明,函数参数无符号字符地址既可以在堆栈上传递,也可以在寄存器中传递。在函数中修改自己的函数参数不是好的做法。这可能是高度编译器依赖的。为此目的使用局部变量。
以上来自于百度翻译 以下为原文 Your function parameter unsigned char address may be passed either on stack or in a register, depending on your configurations and declarations. It's not good practice to modify your own function parameters within the function. This may be highly compiler dependant. Use a local variable for this purpose. |
|
|
|
谁告诉你这个不真实的事实?这是一种有效的做法。如果它每次都不工作,编译器就会有错误。
以上来自于百度翻译 以下为原文 Who told you this very untrue fact? It is a valid practice. If it does not work every time then the compiler has a bugs. |
|
|
|
在执行代码期间,我总是在Variables View:.->Debug.->Variables中观察变量。现在,我正在逐步执行代码(使用pickit3),并且lcd正确响应。在函数
以上来自于百度翻译 以下为原文 mplab x v3.40 xc32 v1.42 During execution of my code I always watch my variables in Variables View: Window->Debugging->Variables At now I'm executing code step by step (with pickit3) and the lcd respond correctly. In the function So I think Variable View window doesn't refresh immediately the r04(CPU) register and this made me very confusedLoL: |
|
|
|
|
|
|
|
|
|
|
|
前四个参数总是(*)在寄存器中传递。这就是调用约定的定义。(*)有一些特殊情况,比如vararg,并且当传递参数太大而不能放入CPU寄存器时,比如structs或64位值。
以上来自于百度翻译 以下为原文 The first four parameters are always(*) passed in registers. That's just how the calling convention is defined. (*) There are special cases, such as varargs, and when passing arguments too large to fit in the CPU registers, eg. structs or 64-bit values. |
|
|
|
在执行代码期间,我总是在Variables View:.->Debuging->Variables中观察变量。现在,我正在逐步执行代码(使用pickit3),并且液晶显示正确响应。cd_command>“address”是0b1xxxxxxxxx(所需值)。所以我认为Variable View窗口不会立即刷新r04(CPU)寄存器,这让我非常困惑LoL:我认为MPlabX比PIC硬件和编译器更可靠吗?不,把一个不稳定的全局测试变量复制到那个变量。或者点亮LED,得到你所期望的价值。
以上来自于百度翻译 以下为原文 During execution of my code I always watch my variables in Variables View: Window->Debugging->Variables At now I'm executing code step by step (with pickit3) and the lcd respond correctly. In the function So I think Variable View window doesn't refresh immediately the r04(CPU) register and this made me very confusedLoL: Do I think MPlabX is more reliable than the PIC hardware and the Compiler? NO. Make a volatile global test variable and copy it to that. Or light an LED in you get the value you expect. |
|
|
|
只有小组成员才能发言,加入小组>>
4849 浏览 9 评论
1847 浏览 8 评论
1773 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
2975 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2076 浏览 5 评论
474浏览 1评论
320浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
379浏览 0评论
271浏览 0评论
LAN9252使用SQI通信,进行数字复位后读BYTE_TEST异常
1828浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-5-21 14:54 , Processed in 1.303673 second(s), Total 96, Slave 80 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号