完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我想知道数组的大小与RAM的可用性有关。如果我在主.c文件的任何函数之外分配一个数组,那么看起来我不能像我喜欢的那样大,所以我必须在512 UIT32上停止,否则我会在内存中产生内存不足的错误。但是如果我把数组移到函数中实际使用它的离子,我可以把它做成1024个没有问题。那么我怎么才能知道我能在多大程度上做到这一点呢?我的设备是PIC24FJ256GB206,具有96 KB的RAM,这意味着完整的第一页0x000—0x7FFF可用(除了第一个2K寄存器重叠的地方)。
以上来自于百度翻译 以下为原文 I am wondering about the size of arrays concerning RAM availability. If I assign an array outside any function in the main.c file then it seems like I cannot make it as big as I like, I had to stop at 512 UINT32 otherwise I got a memory shortage error on build. But if I move that array into the function that actually uses it, then I could make it 1024 without problems. So how can I find out how big I can make it at the most? My device is PIC24FJ256GB206 with 96 kB of RAM, which means the the full first page 0x000-0x7FFF is available (except the first 2K where registers overlap. How much of this is available for local function variables? |
|
相关推荐
3个回答
|
|
它都是可用的。如果你做了一个全局变量,那么它占用了所有时间的内存。如果你只在函数中定义它,那么它只在函数运行时存在。这样,从不运行的函数可以使用相同的RAM块。编译器会为你处理所有这些。
以上来自于百度翻译 以下为原文 It's all available. If you make a variable global, then it occupies that memory for all time. If you only define it in a function, then it only exists while that function is running. In this way, functions that are never running at the same time can use the same blocks of RAM. The compiler takes care of all this for you. |
|
|
|
嗯,似乎不是这样……当我试图在主外部任何函数中定义一个1024项UIT32数组时,编译器给出了一个内存不足的错误。减少到512个项目使它通过。但是后来我尝试用它把缓冲区放入函数中,然后我可以把它定义为1024个项目,没有错误。所以它似乎取决于编译器把变量放在哪里可以用多长时间。
以上来自于百度翻译 以下为原文 Well it does not seem like that... When I tried to define a 1024 item UINT32 array in main outside any function, the compiler gave an out of memory error. Decreasing to 512 items made it pass. But later I tried to put the buffer into the function using it, and then I could define it as 1024 items without error. So it seems to depend on where the compiler places the variable how long it can be... |
|
|
|
C30对于如何管理PIC24、PIC30、PIC33类型的控制器上的内存引用是古怪的。本质上有两类,(类?)在内存空间中,编译器以一种几乎正常的方式处理。RAM直接存取或在与页选择寄存器相关的工作寄存器中具有16位偏移量。例如,使用PIC24F256GB206:“不使用页选择寄存器的”公共XRAM范围为0x000到0x7FFF。这代表了公共RAM的特殊功能寄存器和30K。第一个2K(0x000到0x07FF)是SFRS。下一个6K(0x0800到0x1FFF)在数据附近。下一个30K(0x2000到0x7FFF)是公用数据。SFRS和近数据可以使用指令OPACK中包含的直接地址访问。其他的内存区域必须通过使用工作寄存器作为地址指针来访问。然后有“EDS内存窗口”从0x8000到0xFFFF。访问该区域使用页面选择寄存器(DSRPAG,DSWPAG)来选择指令读取或写入的物理内存。EDS页0x00访问一个32 K区域的片上分支页面0x02访问一个32 K区域的片上分支页面0x00 3访问一个2K区域的片上分支页面0x00到0x1ff访问扩展的并行主端口存储器空间。EDS页面0x200到0x2FF访问程序存储器空间中的24位字的低16位。S页0x300到0x3FF访问程序存储器空间中的24位字的高16位。注意,高8位读取为零。C30编译器和链接器不知道如何分配一个需要更多32766字节空间的单个内存对象。在内存大小计算中,这是一个一次性的错误,使得语句“Oy-EdsSysUnSchultAxAtAdviType((FAR,EDS1),Stand(EDS)))BytARRay[[ 32768 ] ]:“无法建立。您确定要知道这么多吗?”
以上来自于百度翻译 以下为原文 C30 is quirky about how it manages memory references on the PIC24, PIC30, PIC33 types of controllers. There are in essence two kinds, (classes?) of memory spaces the compiler deals with in an almost sane way. The RAM is accessed directly or with 16-bit offsets in working register associated with page select registers. For example using the PIC24F256GB206: There is the "common" RAM range of 0x0000 to 0x7FFF that does not use page select registers. This represents the Special Function Register and 30K of common RAM. The first 2K (0x0000 to 0x07FF) are SFRs. The next 6K (0x0800 to 0x1FFF) is near DATA The next 30K (0x2000 to 0x7FFF) is common DATA The SFRs and near DATA can be accessed using a direct address contained in an instruction opcode. All other memory regions must be accessed by using a working register as an address pointer. Then there is the "EDS memory window" from 0x8000 to 0xFFFF. Access to this region use the page select registers (DSRPAG, DSWPAG) to choose the physical memory the instruction will read or write.
Are you sure you want to know this much? |
|
|
|
只有小组成员才能发言,加入小组>>
5181 浏览 9 评论
2004 浏览 8 评论
1931 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3177 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2228 浏览 5 评论
739浏览 1评论
624浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
510浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
637浏览 0评论
535浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-27 11:58 , Processed in 1.288043 second(s), Total 80, Slave 63 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号