完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
你好,我一直在用浮点来处理数学表达式的问题。我的意思是,MikroC编译代码没有错误,但是在proteus模拟器上出现错误“堆栈下溢执行RETLW指令”。即使代码有大约3500个程序字,在ROM和RAM中也有足够的空间。该项目由PIC16F648A和16x2液晶显示器组成。它的功能之一是一个电动生态车原型的速度计。所以我必须处理一些“long int变量”和“float变量”。我一直使用MikroC的库函数将float变量转换为string(称为FloatToStr),以便在LCD显示器上显示它。即使浮标变量被给定为常数(如2.5),Proteus模拟器也产生相同的误差。另一方面,如果我创建一个程序,只使用浮点变量来计算一个长的数学表达式,并使用相同的函数来转换它,Proteus模拟器上没有错误。我的问题。所以,如果有人能帮助我,我很感激。我没有发布代码的任何部分,因为它太大了,即使使用常数也不能工作。所以,我认为问题不在代码上,但可能存在一些与程序大小有关的问题。毕竟,如果在完全专用于此的程序中使用相同的计算和转换函数,则没有错误。
以上来自于百度翻译 以下为原文 Hello, I've been having problems to work with math expression using 'float'. I mean, the MikroC compiles the code without errors, but on the Proteus simulator occurs an error "Stack underflow executing RETLW instruction". Even the code has around 3500 program words, there are enough space in ROM and RAM. The project consists of PIC16F648A and an 16x2 LCD display. One of its functions is be a speedometer for a prototype of an electrical ecologic car. So I have to work with some 'long int variables' and 'float variables'. I've been using an library function of MikroC to convert a float variable to string (called FloatToStr) in order to show it in LCD display. Even though the float variable is given as a constant (like 2.5), the Proteus simulator generates the same error. On the other hand, if I create a program only to calculate a long math expression using float variables and use this same function to convert it, there is NO error on Proteus simulator. I had looked for solutions on the internet and books for a long time before I created this post, but I hadn't solved my problem. So, I appreciate if someone can help me PS.: I didn't post any part of the code because it's so big and it isn't working even using a constant. So, I believe that the problem isn't on the code, but maybe there is some issue related with the size of the program. After all, if I use the same calculation and convert function in a program totally dedicated for this, there is no error. Simas, |
|
相关推荐
2个回答
|
|
注意,MikroC和Protus都是第三方产品,不是由Microchip生产的。MikroC支持在:http://..mikroe.com/Proteus支持在:http://..labcenter.co.uk/for./
以上来自于百度翻译 以下为原文 Note, MikroC and Proteus are both third-party products, not produced by Microchip. MikroC support is at: http://forum.mikroe.com/ Proteus support is at: http://support.labcenter.co.uk/forums/ |
|
|
|
野生猜测-该设备具有8级硬件堆栈。不知道处理浮点数需要多少级别的函数调用,但我猜是1(至少)太多,并且内部堆栈深度计数器正在环绕。减少并触发您所看到的陷阱。我强烈建议您取消浮点值,改为使用不动点整数。它将节省您的ROM空间,更快,您将在控制功能调用的深度。苏珊
以上来自于百度翻译 以下为原文 Wild guess - that device has an 8 level hardware stack. No idea how many levels of function calls are required to handle floating point numbers but I'm guessing that it is 1 (at least) too many and the internal stack depth counter is wrapping around . When you come to one of the function returns, the hardware is detecting a '0' which is then supposed to be decremented and triggers the trap you are seeing. I would STRONGLY recommend that you scrap the floating point values and use fixed point integers instead. It will save you ROM space, be faster and you will be in control of the depth of function calls. Susan |
|
|
|
只有小组成员才能发言,加入小组>>
5203 浏览 9 评论
2016 浏览 8 评论
1942 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3188 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2243 浏览 5 评论
753浏览 1评论
640浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
545浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
652浏览 0评论
552浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-4 18:29 , Processed in 1.379462 second(s), Total 47, Slave 41 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号