完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛扫一扫,分享给好友
|
只是想知道如果内存明智的是有可能创建一个堆栈上的PIC16LF18325现实。我的起始地址是0x00,结束地址是0x69F,还没有创建堆栈函数。我不是内存空间的专家,我很好奇它是否合理,是否能够在堆栈中存储大约400-600字节的信息。
以上来自于百度翻译 以下为原文 Just wondering if memory wise is it possible to create a stack on a PIC16LF18325 realistically. My start address is 0x00 and my ending address is 0x69F already without creating the stack function. I am not an expert on memory space, I was curious if it is reasonable to do and to be able to store somewhere near 400-600 bytes of information within the stack. Thank you |
|
相关推荐
19个回答
|
|
|
你到底是什么意思?C意义上的堆栈还是…?
以上来自于百度翻译 以下为原文 What do you mean exactly? a Stack in C sense or...? |
|
|
|
|
|
嗯,我需要一些方法来存储信息随着时间的推移。每隔一分钟(也许最终每30分钟)左右,我需要获取11个字节的传感器数据并再次存储。我认为最好的方法是创建一个C堆栈的11个实例,每分钟在每个堆栈中存储一个字节。这个代码是否已经存在,我能够仅仅包括我的程序还是需要创建我自己的程序?我只使用我现在的代码的大约20%的内存空间,我怀疑这是否足够。当然,除非有更好的方法来存储这些数据。
以上来自于百度翻译 以下为原文 Well I need some way of storing information over-time. Every minute (maybe every 30 minutes eventually) or so I need to take 11 bytes of sensor data and store it for another time. I figured the best way to do that is to make 11 instances of a C stack and each minute, store one byte in each stack. Does this code already exist that I can just #include into my program or do I need to create my own? I am only using about 20% of my memory space for the code I have now, I wonder if it that is enough. Unless of course there is a better way to store this data. |
|
|
|
|
|
我不认为堆栈是你要找的词。如果没有,那就错了。数组可能吗?结构数组?一个2维数组?30×11=330字节。注意RAM空间和ROM(FLASH)(代码)空间是不同的。除非您想在闪存中存储数据。
以上来自于百度翻译 以下为原文 I do not think Stack is the word you are looking for. If it is no that would be wrong. Array maybe? An array of structs? A 2 dimensional array? 30* 11 = 330 bytes. Note RAM space and ROM (flash)(code) spaces are different. Unless you want to store data in the flash. |
|
|
|
|
|
|
|
|
|
|
|
双方都同意。它可能是某种程度上的,但现在我明白了,或多或少。
以上来自于百度翻译 以下为原文 Agreed with both. It may be finetuned somehow but now I get it - more or less. |
|
|
|
|
|
|
|
|
|
|
|
有两种常用的访问缓冲区的方法:先进先出。这通常是作为堆栈实现的。C堆栈是一个例子。先进先出。这通常被实现为循环缓冲区。例如,UART的中间缓冲区。从C观点来看,两者都是数组。您需要哪一个?或者你需要更复杂的东西吗?
以上来自于百度翻译 以下为原文 There are two common ways of accessing buffers: LIFO - last in first out. This is often implemented as a stack. C stack is an example. FIFO - first in first out. This is often implemented as a circular buffer. For example, intermediary buffer for UART. From the C viewpoints both are arrays. Which one would you need? Or do you need something more complex? |
|
|
|
|
|
我想一次一次地存储11字节的信息。我不知道要记录11个字节需要多少时间,所以我认为堆栈会很完美,因为我可以把数据放在最上面(LIFO),然后附加数据。如果有其他存储信息的方法,比如环形缓冲区,我可以实现。这个代码容易访问吗?我只是不想给它一个确定的大小,我不知道我需要保存多少信息。对NorthGuy来说,不管是FIFO还是LIFO,只要在我的微控制器中实现一种数据结构来临时存储数据就行了。然后偶尔地,可能每天,我会把所有的信息提取到我的笔记本电脑上,然后重新开始整件事。一旦数据在笔记本电脑上,就可以从其在MCU上的存储中删除。
以上来自于百度翻译 以下为原文 I want to store 11 bytes of information at a time periodically. I do not know how many time I need to record the 11 bytes so that is why I thought a stack would be perfect because I can just push the data on top (LIFO) and it would append the data. If there is another way of storing information, like the ring buffer, I can implement that. Is this code accessible easily? I just don't want to give it a determined size, I do not know how much information I will need to keep. to NorthGuy, It does not matter if it is FIFO or LIFO, just some way of implementing into my microcontroller a data structure to store data temporarily. Then every once in a while, possibly daily, I will extract all the information on to my laptop and then start the whole thing over. Once the data is on the laptop, it can be deleted from its storage on the MCU |
|
|
|
|
|
然后使用一个循环缓冲区,当它满时,新的数据将覆盖旧的数据,因为您不知道所需的大小。将剩下的所有内存分配给这个缓冲区。
以上来自于百度翻译 以下为原文 Then use a circular buffer where when it is full the new data will overwrite the old data, since you do not know the size needed. Allocate all the remaining memory you have left to this buffer. |
|
|
|
|
|
我能使用现有代码还是需要自己编写代码?
以上来自于百度翻译 以下为原文 Is there existing code I can utilize or do I need to write my own? |
|
|
|
|
|
堆栈是LIFO构造函数。堆栈是CPU用来传递函数调用之类的东西的硬件方法。没有内置到C中的堆栈构造供您使用。您需要编写它,而且它根本不会帮助您,它可能使工作更加困难。K用于帮助解决问题的糟糕解决方案。一个你没有明确描述的问题。你的11个字节是什么?11字节大小的变量?5个字节和一个字节?什么。环形缓冲区对于持续异步到达的数据非常有用。编写(对于初学者)并不简单。我怀疑它会有所帮助。一种基本方法(缺少更多细节)是无符号char anArray[30][11];//创建3011char数组,Google2维数组用于Cif you数据,但并非全部都是这样同样,你会做一个石板,然后宣布和排列这些。
以上来自于百度翻译 以下为原文 A Stack is a LIFO constrack. The Stack is a hardware method the CPU uses to hand things like function calls. There is no Stack construct built in to C for you to use. You would need to write it, and it would not help you at all, it might make the job more difficult. AS is common on the Forum you are ask for help in implementing a poor solution for your problem. A problem you did not clearly describe. Your 11 bytes are what? 11 bytes size variables? 5 ints and a byte? What. A ring Buffer is great for data that is continually arriving asynchronously. It is not simple to write (for a Beginner) An I doubt it will help. A basic way (lacking more details) unsigned char anArray[30][11]; // create 30 11 char arrays Google 2 dimensional arrays for C if you data in not all the same you would make a stuct, then declare and array of those. |
|
|
|
|
|
看起来,你所寻找的是“数组”,首先定义类型来覆盖11字节:然后创建一个由这种类型的变量组成的数组。这里的大小是50(550字节)。必须指定大小。反正你也得不到无穷大。因此,需要确定需要多少,然后根据需要访问变量:
以上来自于百度翻译 以下为原文 Looks like the thing you're looking for is "array" You first define the type to cover your 11 bytes: typedef struct xTag{ // here you define your 11-byte worth of variables int a; int b; } xType; Then you create an array consisting of variables of this type. xType xArray[50]; Here the size is 50 (550 bytes). You have to specify the size. You won't get infinity anyway. So, you need to figure out how many you need. Then you access the variables as needed: xArray[12].a = 2; q = 17; z = xArray[q].b; |
|
|
|
|
|
这11个字节只是11组8位数据,1位和0位,都表示无符号整数。至于NorthGuy,谢谢。我没有意识到数组是我最好的选择,但是根据每个人的建议,这似乎是我们的出路。我会实现你的代码并尝试它。可能是星期一tho= z。
以上来自于百度翻译 以下为原文 The 11 bytes are just 11 sets of 8-bits of data, 1's and 0's, all representing unsigned integers. As for NorthGuy, thank you. I didn't realize arrays were my best option, but with everyone's advice, it would appear that is the way to go. I will implement your code and try it out. It may be for Monday tho =z |
|
|
|
|
|
无符号整数占用两个字节的存储空间。我正在思考无符号int——我可能错了。L///G>循环缓冲器是一种环绕的数组形式。
以上来自于百度翻译 以下为原文 An unsigned integer takes two bytes of storage space. |
|
|
|
|
|
11字节只是11组8位数据,1位和0位,都表示无符号整数。真的吗???????你说的是1和0!8位非整数整数?这将是ANUNCHANCE CHARR,而不是英特尔16位UNSIGNEN签名整数,这是标准大小,但如何得到11?32或64位也是其他CPU的可能大小。
以上来自于百度翻译 以下为原文 The 11 bytes are just 11 sets of 8-bits of data, 1's and 0's, all representing unsigned integers. Really?????? 1's and 0's you say! 8 bit unsigned integers? This would be an unsigned char, not int. 16 bit unsigned unsigned integers, this is the standard size, but how do you get 11? 32 or 64 bits are also possible sizes for other CPUs |
|
|
|
|
|
如果知道需要保存的最大数据量,则顺序访问的数组是一个好方法,但是如果填充了数组并仍然有更多的数据,则会出现问题,您该怎么做?这就是为什么循环访问方案有时值得实现的原因,至少您可以存储传入的新数据(但是它丢失了最旧的数据)。循环访问对于输入指针和输出指针来说稍微复杂一些,但是应该有很多可用的好例子,这是一种老技术。如果在将数据写入缓冲区的同时不输出数据(读取缓冲区),则会变得更容易,因为您不必担心输出指针在改变时超出输入指针。稍微多做一点工作,然后顺序填充数组并从开始读到输入指针,但是如果RAM很短并且数据量可能超出数组(并且您希望保留最近的数据),则可能需要这些工作。微笑:
以上来自于百度翻译 以下为原文 An array that is sequentially accessed is a good approach if you know the maximum amount of data that you need to hold however it can present issues if you fill up the array and still have more data, what do you do? this is why a circular access scheme can sometimes be worth implementing, at least you can store the new data coming in (however it is at the loss of the oldest data). The circular access is a little more complicated with an input pointer and an output pointer but there should be many good examples of this available, it is an old technique. And if you are not outputting the data (reading the buffer) at the same time you are writing the data to the buffer then it gets easier because you won't need to worry about the output pointer overrunning the input pointer while it is changing. A little more work then just sequentially filling the array and reading it from the start to the input pointer but may be needed if RAM is short and the amount of data may overrun the array (and you wish to preserve the most recent data). IMHO.Smile: |
|
|
|
|
|
@ OP:当数组/缓冲区被填充,还有更多的数据进来时,你想做什么?这将决定您需要什么样的数据结构。搁置你帖子中的所有混淆,你想每次存储11个无符号字符类型变量,对吗?
以上来自于百度翻译 以下为原文 @OP: What do you want to do when the array/buffer is filled and there's more data coming in? That will determine what kind of data structure you need. Set aside all the confusions in your posts, you wanted to store 11 unsigned char type variables each time, correct? |
|
|
|
|
|
不要担心数组溢出时该怎么办,想想如何确保它永远不会溢出。通常情况下,它是可能的,以确保它永远不会发生。如果没有,可以减轻这种情况,让接收器知道发生了一些坏事-你可以使用诸如帧编号等东西。
以上来自于百度翻译 以下为原文 Instead of worrying what to do if the array overflows, think about the ways to make sure it never overflows. Often it is possible to make sure it never happens. If not, it could be possible to alleviate the situation and let the receiver know something bad has happened - you can use things such as frame numbering etc. |
|
|
|
|
|
在我看来,他每分钟接收一次数据。而是他一分钟取样一次。这意味着环缓冲器可能没有任何用途,除非他正在做一些类似于运行平均值的事情。
以上来自于百度翻译 以下为原文 It does appear to me he is receiving data once a minute. But that he is sampling once a minute. This means a ring buffer may not be of any use unless he is doing something like a running average. |
|
|
|
|
只有小组成员才能发言,加入小组>>
MPLAB X IDE V6.25版本怎么对bootloader和应用程序进行烧录
473 浏览 0 评论
5793 浏览 9 评论
2334 浏览 8 评论
2224 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3530 浏览 3 评论
1124浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
1097浏览 1评论
我是Microchip 的代理商,有PIC16F1829T-I/SS 技术问题可以咨询我,微信:A-chip-Ti
873浏览 1评论
MPLAB X IDE V6.25版本怎么对bootloader和应用程序进行烧录
475浏览 0评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-2 07:06 , Processed in 1.074688 second(s), Total 108, Slave 91 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
2707