完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我问了一个问题,在PIC24线程中使用大量RAM,并通过引导使用EDS内存的响应来达到我的目标的一部分。好像我还没有掌握在我的广告中98个字节的RAM,只有一个小部分可用作真正的RAM。其他(较大)部分必须通过EDS页面切换间接访问。我的问题是,我需要一个缓冲的大集合的A/D样本由一个24位A/D芯片在我的董事会。我需要一个数组中至少有10个Unt32大小的数据样本,所以它在一个数组中计算大约40千字节的RAM。SRAM的基本页太大。如果我进入8KSt样品,如果我可以把所有的EDS页面1都分配给这个数组,我至少会关闭…不幸的是,我没有发现任何例子来说明如何做到这一点。我想使用常规的C30代码,目的是收集一个瞬时值,然后当所有的RAM都保存到SD卡文件时,A/D转换器代码需要访问数组来写入新的数据,而FATFS磁盘代码需要读取数据以将其写入磁盘。可在C代码中显示的机制在哪里?
以上来自于百度翻译 以下为原文 I was asking about a problem with using big amounts of RAM in a PIC24 thread and by the responses I was guided towards using EDS memory to get part of the way to my goal. It seems like I had not grasped that of the advertised 98 KB of RAM in my part only a small section is usable as real RAM and the other (bigger) section must be accessed indirectly by EDS page switching. My problem is that I need a buffer for a large set of A/D samples collected by a 24 bit A/D chip on my board. I need at least 10 kSamples of UINT32 size data in an array, so it calculates to about 40 kBytes of RAM in one array. Too big for the base page of SRAM. If I go down to 8kSamples then if I can allocate all of EDS page #1 to this array I will at least get close... Unfortunately I have not found any example showing how to do this. And the discussions I have searched for are too complex and bring in assembly code. I want to use regular C30 code. The aim is to collect a transient of values and then when all is in RAM save it to an SDcard file, so the A/D converter code needs to access the array for writing the new data and the FatFs disk code needs to read the data to write it to disk. Is there some example available where the mechanism for doing this is shown in C code? |
|
相关推荐
19个回答
|
|
在项目属性中有编译器选项,启用大型数组。使用它和yxEdsx,然后可以创建大小大于8191的uTIN 32×T数组。
以上来自于百度翻译 以下为原文 there is a compiler option, Enable large arrays, in the project properties. Use it with __eds__, then you can create uint32_t array with the size larger than 8191. |
|
|
|
好的,我找到了编译器设置并启用了大型数组。当你说“用它来使用它时,你的意思是这样吗?”这大概是使用了所有的EDS页面1,对吧?一个更大的数组会发生什么?它可以使用空洞或字节指针访问吗?我所追求的是一种以有效的方式填充缓冲区的方法,然后将它作为字节数组写入磁盘。
以上来自于百度翻译 以下为原文 OK, I found the compiler setting and enabled large arrays. Do you mean this when you say "Use it with __eds__": #define SIZEBB 8192 __eds__ uint32_t BigBuffer[SIZEBB] __attribute__((eds)); This presumably uses up all of the EDS page #1, right? What happens with an even bigger array? #define SIZEBB 10000 __eds__ uint32_t BigBuffer[SIZEBB] __attribute__((eds)); And can it be accessed using void or BYTE pointers? BYTE * b; void * p; UINT i = 0; BYTE d=0; b := &BigBuffer; for(i=0; i p = &BigBuffer; for(i=0; i (UINT) *p = i; (UINT)p++; //Does this increment the pointer by 2? } What I am after is a way to fill the buffer with data in an efficient way and then access it for writing to disk as a byte array... |
|
|
|
也就是说,指针。不确定“启用大型数组”自动地将所有指针转换成“EDS能力”…
以上来自于百度翻译 以下为原文 __eds__ pointers, yep. Not sure if the "enable large arrays" automagically converts all pointers to "eds-capable"... |
|
|
|
我尝试了如下代码:它返回了指向第二行的编译错误:这里的交易是什么?
以上来自于百度翻译 以下为原文 I tried the code as follows: #define SIZEBB 8192 __eds__ uint32_t BigBuffer[SIZEBB] __attribute__((eds)); And it returned a compile error pointing to the second line above: ../source/main.c:29: error: syntax error before 'BigBuffer' What is the deal here? |
|
|
|
使用XC16,您可以尝试这样的操作:意图:在EDS中分配8K的UTIT32(带有XC16GCC/内存模型/允许大于32 K的数组)-用指针填充值复制数据的一部分缓冲区。这部分代码在MPLAB-X模拟器中运行。但是,指针的铸造是一个试验。错误处理。它工作,但我不知道为什么。
以上来自于百度翻译 以下为原文 with XC16 you could try something like this: __eds__ unsigned long __attribute__((eds)) myBuffer[8192] ; unsigned char myBytes[4096]; int main(void) { int i=0; unsigned char* pDestination=0; __eds__ unsigned char* pSource=0; for (i=0; i<1024; i++) { myBuffer=2*i+43; } pSource=(__eds__ unsigned char*) &myBuffer[0]; pDestination=&myBytes[0]; for (i=0;i<4096;i++) { *pDestination++=*pSource++; } return 0; } Intention: -allocate 8K of UINT32 in EDS (with XC16-gcc/memory model/allow arrays larger than 32k) -fill a part of the Buffer with values -copy Data using Pointers. This part of code worked within MPLAB-X Simulator. However, casting of the Pointers was a trial and error process. It works but I don't know why. |
|
|
|
如果你想把它放在第1页,你可以使用+ +如果你的数组大小大于8192,它将跨越页面边界,这是可以的。编译器可以处理它。
以上来自于百度翻译 以下为原文 If you want to put it exactly at the page 1, you can use __eds__ uint32_t buffer[8192] __attribute__ ((address(0x8000),space(eds))); ++ If your array size is larger than 8192, it will cross the page boundary and that's OK. The compiler can handle it. |
|
|
|
我尝试了C30:但是这又导致了错误信息:BigBuffer在这条线上的东西是什么????
以上来自于百度翻译 以下为原文 I tried this with C30: #define SIZEBB 8192 __eds__ uint32_t BigBuffer[SIZEBB] __attribute__((address(0x8000),space(eds))); but it resulted in the error message again: ../source/main.c:30: error: syntax error before 'BigBuffer' What is it with the stuff before BigBuffer on this line??? |
|
|
|
UIT32?t(在StInt.h中定义)有什么不对吗?我用C30V3.31编译它,我看不出有什么问题。
以上来自于百度翻译 以下为原文 Could it be something wrong with uint32_t (defined in stdint.h)? I compiled it with C30 v3.31 #include #include __eds__ uint32_t buffer2[8192] __attribute__ ((address(0x8000),space(eds))); I don't see any problem with it. |
|
|
|
谢谢,lt;Stdit.h & gt;不包括在我的页眉中……我改变了冒犯的行如下(也在另一个线程上看这个问题添加段说明符):现在我不再在“BigBuffic”之前得到即时错误,而是有更多的文件被处理,然后就是这个。末端错误(链接?)类似于所有这些引用的Red StudioStudio.G.O...……………………FF.C是FATFS开源模块的一部分,UTIL.C是我编写的各种小功能的单元。刷新所有文件,同样的问题。
以上来自于百度翻译 以下为原文 Thanks, I changed the offending line as follows (also looked in another thread on this matter to add the section specifier): __eds__ UINT32 BigBuffer[SIZEBB] __attribute__((far, address(0x8000), space(eds), section("eds1"))); Now I no longer get the immediate error "before BigBuffer", instead there are more files being processed and then there is this error at the end (linking?): build/default/production/_ext/1803799903/ff.o(.text+0x181e)c:programsmicrochipmplabc30v3.31binbin..bin/pic30-elf-ld.exe: Dwarf Error: found address size '18', this reader can not handle sizes greater than '4'. Following this is a long list of red lines similar to these all referencing : In function `.LM465': : undefined reference to `___udivsi3' build/default/production/_ext/1803799903/ff.o(.text+0x2610): In function `.LM719': : undefined reference to `___udivsi3' ... build/default/production/_ext/812168374/utils.o(.text+0x2)c:programsmicrochipmplabc30v3.31binbin..bin/pic30-elf-ld.exe: Dwarf Error: found address size '150', this reader can not handle sizes greater than '4'. : In function `.LM2': : undefined reference to `_ReadTimer45' build/default/production/_ext/812168374/utils.o(.text+0x4b4): In function `.LM124': : undefined reference to `___umodsi3' Getting closer but not quite there yet... ff.c is part of the FatFs Open Source module and utils.c is a unit for various small functions I have written myself. I even did a Clean and Build in order to refresh all files, same problem. |
|
|
|
如果你把BigBuffer作为函数的指针。对于这些指针,您可能必须使用“y-Edssx”,例如“yay-EdsSuuUnt3*t*缓冲区”。最好这样做,因为你有三页的EDS内存,虽然默认是第1页。
以上来自于百度翻译 以下为原文 If you are passing the BigBuffer as a pointer to some functions. You may have to use __eds__ for those pointers, such as "__eds__ uint32_t *buffer". It's better to do that, because you have three pages of EDS memory, although the default is page 1. |
|
|
|
好的,但是如果操纵这些数组数据的代码位于不同的实用功能(比如FATFS系统和我的数据格式化函数等),那么我必须改变我的整个代码库到这些类型的指针吗?在这种情况下,以后如何使用“正常”非EDS数据来使用这些实用工具?好像我必须保持一组不同的功能,因为输入数据来自EDs,做同样的事情,或者也许这不是必要的?在这种情况下,我把什么放在哪里?例如,我正在做这个“RealEdBigDATATEST”,以便测试当前项目中的大数组,否则它们工作得很好:
以上来自于百度翻译 以下为原文 OK, but if the code manipulating these array data are located in various utility functions (like the FatFs system and my data formatting functions etc), then do I have to change my whole codebase to these types of pointers? And in that case, how do I thereafter use the utilities with "normal" non-EDS data? It seems like I have to keep a different set of functions doing the same thing just because the input data comes from EDS... Or maybe this is not needed? In such a case, where do I put the __eds__ ?? Example, I am doing this "WriteBigDataTest" in order to test the big arrays in a current project that otherwise works fine: #define SIZEBB 8192 __eds__ UINT32 BigBuffer[SIZEBB] __attribute__((far, address(0x8000), space(eds), section("eds1"))); FATFS FatFs; //Global File system work area UINT32 WriteBufToFile(char * fname, char *buf, UINT cnt, BOOL Append) { FIL fil; /* File object */ FRESULT fr; /* FatFs return code */ UINT cres; UINT32 T1, T2; /* Register work area to the default drive */ f_mount(&FatFs, "0:", 0) .... /* Write input data */ fr = f_write(&fil, buf, cnt, &cres);// <== Only use of pointer buf if (fr || cres < cnt) return (int)fr; /* error or disk full */ /* Close the file */ f_close(&fil); T2 = GetTickCount(); T1 = T2 - T1; Nop(); /* Unregister work area prior to discard it */ f_mount(NULL, "0:", 0); return T1; } UINT32 WriteBigDataTest() //My test of the big data array handling { UINT32 i; __eds__ UINT32 * arr; arr = &BigBuffer[0]; for (i = 0; i < SIZEBB; i++) //Fill array { *arr++ = i; } i = WriteBufToFile("BUFTST.BIN", &BigBuffer[0], SIZEBB * 4, FALSE); } |
|
|
|
使用EDS指针将膨胀/慢使用它们的代码。它必须管理和切换页面,这是一个平衡。我想,在做写之前,我会复制到本地缓冲区,以保存所有的“实用程序”函数来使用EDS指针。我不知道(我也仍然使用C30),但我希望XC16将更加成熟地支持EDS等。因此,使用EDS以本地化的最小方式可能是BE。T30接近C30!启用大型数组也可能使其他代码膨胀。
以上来自于百度翻译 以下为原文 Using EDS pointers will bloat/slow the code that uses them. It has to manage and switch pages. Its a balance. I think, I would copy to a local buffer before doing the write to save adjusting all those 'utility' functions to use EDS pointers. I have no idea (I'm also still using C30) but I would expect XC16 will be much more mature in support the EDS etc. So using EDS in a localised minimal way may be the better approach with C30! Enable large arrays might also bloat your other code. |
|
|
|
接下来我做的是注释WordBigDATA()函数中的最后一行,即对WruteBufToFielver()函数的调用。这是一个常用的缓冲文件写入函数,我们使用字符指针作为数据源,从内存写入SD卡。我假设大量的错误来自这个调用,因为该函数本身使用了很多其他函数。通过注释该行,它应该意味着只有WrigeBigDATA()函数需要对大EDS数组做任何事情。在这里,我用指针来定义指针,但是我仍然得到了完全相同的错误负载…所以接下来我注释了函数WrreBigDATATESTER()的完整函数,只在末尾加了一个返回0。猜猜怎么着?所有错误仍然保持干净的建设!同样,如果我拿出定义的Big数组也!编译器设置的“大数组”是否影响整个项目,以便*所有的事物都需要EDS感知?还有什么能让错误继续存在,即使没有使用数组了吗?嗯,我测试过删除那个复选框,现在我终于摆脱了这些错误!但是现在我的代码完全没有任何大数组支持……这里给出了什么?转换为XC16?怎样才能做到呢?
以上来自于百度翻译 以下为原文 What I did next was to comment out the last line in the WriteBigDataTest() function, the call to the WriteBufToFile() function. This is a regular buffer file write function we use to write to SDcard from memory using a char pointer as the source of data. I assumed the large amounts of errors came from this call since that function in itself uses lots of other functions. By commenting out the line it should mean that only the WriteBigDataTest() function will need to do anything to the big EDS array. And here I defined the pointers with the __eds__ attribute. But still I get exactly the same load of errors... So next I commented out the complete body of function WriteBigDataTest() only putting a return 0 at the end. Guess what? All the errors remain even with a Clean Build! Same if I took out the definition of the BigArray too! Is the compiler setting "large arrays" affecting the full project so that *everything* needs to be EDS aware? Or what else could make the errors stay even though nothing is using the array anymore? Well, I tested removing that checkbox as well and now finally I got rid of these errors! But now my code is totally without any large array support etc... What gives here? Converting to XC16? How can one do that? |
|
|
|
是否需要与大型数组一起使用不同的库?
以上来自于百度翻译 以下为原文 Does it required a different library for use with large arrays? |
|
|
|
问:EDS的使用是否需要使用“大数组”选项?或者我可以不离开THTA并分配两个不同的缓冲器,每个缓冲区大小像20字节,在EDS页1中放置一个,另一个放在常规内存中,这样的工作没有大的数组支持吗?当然,我们必须在两个单独的缓冲器中管理样本,但这至少是可行的。
以上来自于百度翻译 以下为原文 Question: Does the use of EDS require the use of option "large arrays" too? Or can I leave thta unchecked and assign two different buffers, each like 20 Kbytes in size and put one in EDS page 1 and the other in regular memory, would that work without large array support? Of course we would have to manage the samples in two separate buffers, but that would be doable at least. |
|
|
|
EDS的使用不需要“大数组”选项。我不确定您的内存分配情况如何。如果您不介意管理用于读取/写入EDS存储器的DSRPAG和DSSWPAG,那么就有一个诀窍。将DSPPAG和DSSWPAG设置为1,或者在使用页面1内存时确保它们设置为1。比如说,创建三个内存块,就像您可以从BuffSer0(0)访问到的那样。BuffSer0(12287)不接触DSRPAG和DSWPAG。如果从BuffSer0(4096)访问ISR中的BuffSer0(12287),则可能必须先推那些页寄存器,然后在访问页1中的BuffR0数据之前将它们更改为1。因为Buffe1和Buffe2在页1中,不使用,你可以在没有EDS.的情况下定义它们。这样的AY-Edss1用于通知编译器自动处理DSRPAG和DSSWPAG。
以上来自于百度翻译 以下为原文 Use of EDS does not require "large arrays" option. I am not sure how your memory allocation looks alike. If you don't mind to manage the DSRPAG and DSWPAG which are used to read/write the EDS memory, there is a trick to do it. The idea is set 1 to DSRPAG and DSWPAG or make sure they are set to 1 when you use the page 1 memory. Say you create three memory blocks like uint32_t buffer0[4096] __attribute__ ((address(0x4000))); __eds__ uint32_t buffer1[4096] __attribute__ ((far,address(0x8000),space(eds))); __eds__ uint32_t buffer2[4096] __attribute__ ((far,address(0xC000),space(eds))); Then you can access from buffer0[0] to buffer0[12287] without touching the DSRPAG and DSWPAG. If you access the data from buffer0[4096] to buffer0[12287] in ISR, you may have to PUSH those PAGE registers first and then change them to 1 before you access the buffer0 data in page 1. Because buffer1 and buffer2 are in page 1, and not used, you can define them without EDS... such as uint32_t buffer0[4096] __attribute__ ((address(0x4000))); uint32_t buffer1[4096] __attribute__ ((address(0x8000))); uint32_t buffer2[4096] __attribute__ ((address(0xC000))); the __eds__ is used to inform the compiler to automatically handle the DSRPAG and DSWPAG for you. |
|
|
|
嗨,BobAGI,用一个小的缓冲区(512字节)怎么样?在普通RAM中,将数据从BigBuffer复制到小缓冲区(逐块),并使用正常的FAT函数保存多个512字节块来存档。从一个以前的帖子中,我知道有一个汇编函数y.MycPyPyEDS(XC16,V1.3.1)(http://www. McCys.com /论坛/ FindPost / 967363)。这个函数处理单词的复制以及字节的复制,源和目的地可以是EDS或普通RAM。但是我没有找到C FU。一个这样的函数的例子可以在MyMeMcPy实现为汇编函数的地方:
以上来自于百度翻译 以下为原文 hi BobAGI, what about using a small buffer (512 bytes?) in normal RAM and copying the data from BigBuffer to the small buffer (block by block) and using your normal FAT functions to save multiple 512 bytes blocks to file. I wonder whether there is a C function to copy between EDS and non-EDS memory without much overhead. Calling convention like: void memcpy_eds(__eds__ void* pDest, __eds__ void* pSource,unsigned int nNumBytes) From a former Post I know there is an Assembly function __memcpy_eds (XC16, V1.3.1) (http://www.microchip.com/forums/FindPost/967363) This function handles copying of words as well as copying of bytes, Source and Destination can be in eds or normal RAM. But I didn't find a C function for this task. An example for such a function could be #include "xc.h" #include "string.h" //only for memcpy // my Assaembly Function to wrap __memcpy_eds extern void myMemCpy(__eds__ void* pSource, __eds__ void* pDest, unsigned int nNumBytes); // some bytes in eds __eds__ unsigned int __attribute((eds)) myBuffer[4096]; // some bytes in normal RAM unsigned char myBytes[1024]; //C function using 32bit Pointers void memcpy_eds(__eds__ void* pDest, __eds__ void* pSource,unsigned int nNumBytes); int main(void) { int i=0; for (i=0;i<32;i++) { myBuffer=i; } memcpy_eds(&myBytes,&myBuffer,20 ); return 0; } void memcpy_eds(__eds__ void* pDest, __eds__ void* pSource,unsigned int nNumBytes) { // call an Assembly function to set up the Registers for __memcpy_eds myMemCpy( pSource, pDest, nNumBytes); // Source and Destination swapped } where myMemCpy is implemented as Assembly Function: .include "xc.inc" .text .global _myMemCpy _myMemCpy: ;; C declaration of this function is: ;; extern void myMemCpy(__eds__ void* pSource, __eds__ void* pDest, unsigned int nNumBytes); ;; XC16 calls this function with: ;; w0: offset of Source ;; w1: page of Source ;; w2: offset of Destination ;; w3: page of Destination ;; w4: Number of bytes ;; Library function: ;; __memcpy_eds ;; Registers used: w0 w1 w2 w3 w4 w5 w6 w7 ;; ;; Inputs: ;; w0,w1 = source address (24 bits) ;; w2,w3 = destination address (24 bits) ;; w4 = number of bytes (even or odd) ;; w5 = align CLR W5 CALL __memcpy_eds RETURN |
|
|
|
这个线程可以提示http://www. McCux.com /论坛/ M88098.ASPX(以及这个评论:http://www. McCHIP.COM/FUMMS/FUNDSPE/81263!!)
以上来自于百度翻译 以下为原文 This thread may give hints http://www.microchip.com/forums/m880978.aspx (and this comment: http://www.microchip.com/forums/FindPost/881263 !! ) |
|
|
|
HI,从EDS复制到正常RAM的另一种方法是使用结构和联盟:MyTimeDATa= MyAdCDATA。块不使用代码中的指针,将512个字节从EDS复制到正常RAM。然后,可以使用一个普通的char *指针来将MyTimeDATA写入到文件中。
以上来自于百度翻译 以下为原文 Hi, another way to copy from eds to normal RAM could be using structs and unions like: #ifndef UINT32 #define UINT32 unsigned long #endif #include "xc.h" #define BLOCK_SIZE 512 #define NUM_BLOCKS 64 typedef struct { char b[512]; }BLOCK; typedef struct __ADCDATA{ union{ UINT32 ADC24[8192]; BLOCK Block[64]; }; }ADCDATA; __eds__ ADCDATA __attribute__((eds)) myADCData ; BLOCK myTempData; int main(void) { int i=0; char* pBytePointer=0; // fill some values for (i=0; i<1024; i++) { myADCData.ADC24=0x00010001*i; } pBytePointer=(char*)&myTempData; // up to 64 blocks from eds to normal RAM for (i=0;i<2; i++) { myTempData=myADCData.Block; //copies 512 bytes // handle this block using pBytePointer ... } return 0; } myTempData=myADCData.Block copies 512 bytes from eds to normal RAM without using Pointers in your code. You can then use a normal char* Pointer to myTempData to write the bytes to file. |
|
|
|
只有小组成员才能发言,加入小组>>
5542 浏览 9 评论
2196 浏览 8 评论
2096 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3373 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2400 浏览 5 评论
1029浏览 1评论
870浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
879浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
907浏览 0评论
我是Microchip 的代理商,有PIC16F1829T-I/SS 威廉希尔官方网站 问题可以咨询我,微信:A-chip-Ti
619浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-6-18 04:50 , Processed in 1.662697 second(s), Total 80, Slave 74 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191