完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
大家好,这是一个PIC16F690。我使用的是一个较老的B类版本(V1.02),它正在测试一个函数的地址。这两个函数被声明为:每个SSLyTestFrime1和2的地址以这种方式检查:问题是Twitter=1安德鲁地址=0x501,因此测试失败。在调试模式下,我得到了“地址=0x500”,我把鼠标光标OffsLyStestFrime1(在行中:TuntAd= =(未签名int)和;SSLyTestMult1)。我认为插入“(无符号INT*)”就像在“未签名INTSLSYTestMultudi1(空)”中那样做是愚蠢的。这就好像是用同样的方式做两次……是否有另一种方法来读取SSLYTestTyf1的正确地址值?更多的细节如下:
以上来自于百度翻译 以下为原文 Hi all, This is for a PIC16F690. I'm using an older class b version (v1.02) and It is failing a test where it is checking the addresses of a couple of function. These two functions are declared as: unsigned int SSL_TestFunction1(void) @ 0x500; unsigned int SSL_TestFunction2(void) @ 0x400; The address of the each SSL_TestFunction1 and 2 is checked this way: tempAddress= (unsigned int)&SSL_TestFunction1; //store Address of SSL_TestFunction1 returnAddress=SSL_TestFunction1(); // Branch to SSL_TestFunction1 if( tempAddress != returnAddress) // Test if the addresses match return PROGRAM_COUNTER_TEST_FAIL; The problem is tempAddress=1 and returnAddress=0x501 so the test fails. I get "address=0x500' when in debug mode I put the mouse cursor over SSL_TestFunction1 (in the line:tempAddress= (unsigned int)&SSL_TestFunction1). I thought it would be silly to just insert "(unsigned int *)" like they do it in "unsigned int SSL_TestFunction1(void)". That would be like doing it twice the same way... Is there another way to read the correct address value for SSL_TestFunction1? Thanks More details below: unsigned int returnAddress,tempAddress; unsigned int SSL_TestFunction1(void) { return ((unsigned int)(unsigned int *) &SSL_TestFunction1); } |
|
相关推荐
2个回答
|
|
HI,第一步是将两个变量的类型保存到函数指针,并改变函数返回值的类型。下一步将是阅读用户指南,并意识到函数地址并不总是函数驻留的实际地址。如果使用查找表来调用函数,函数地址将反映调用的方式。函数地址与选定的设备发生变化。您可能只是错误地解释这些值,没有错误。
以上来自于百度翻译 以下为原文 Hi, The first step would be to change the type of the two variables holding the address to function pointers, and change the type of the return value of the function. The next step would be to read the User's Guide and appreciate that a function address is not always the actual address at which a function resides. If a lookup table is used to call the function, the function address will reflect that way of calling. Function addresses change with the selected device. You might be simply interpreting the values incorrectly and there is no fault. Jeff. |
|
|
|
在C中,函数的地址只是它的名字。不需要!
以上来自于百度翻译 以下为原文 In C the address of a function is just its name. No & is required! |
|
|
|
只有小组成员才能发言,加入小组>>
5166 浏览 9 评论
2000 浏览 8 评论
1929 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3175 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2227 浏览 5 评论
736浏览 1评论
619浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
507浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
633浏览 0评论
530浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-25 03:03 , Processed in 1.546443 second(s), Total 80, Slave 64 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号