发 帖  
原厂入驻New
申请华秋企业认证 多层板首单免费打样!
30s提交资料,10分钟通过审核(免费赔付+顺丰包邮)>>立即报名
[问答] 请问9.5 kb不足以处理上述数据吗?
139 LED RAM
分享
我使用的是dsPIC33fJ256GP710A。我有以下代码:现在,我在我的主函数中调用这个函数,并打开和关闭一个LED,以了解这个块是否正在执行?我在PIC24FJ256GB206(RAM=96 KB)中实现了相同的代码,LED在一段时间后闪烁。然而,对于dspic33fj256gp710a(ram=30KB)的情况则不同。根据我的计算,上述块所需的ram是:a)10KB用于Xb)10KB用于Yc)400B(50*4)用于xd)100B(50*2)用于he)10B用于yn,k,i,N和f)处理数据需要一些ram。GHY 20.5 KB,所以问题是,9.5 kb不足以处理上述数据吗?我错过什么了吗?我也想附加构建输出(作为一个图像),如果有人想要指向除了Access Denied之外的任何有趣的地方。

以上来自于百度翻译


      以下为原文

    I am using dsPIC33FJ256GP710A. I have the following code:
void fiRFilter(long int *X, const int *h,int N)          //N=50
{
   long int Y[2500];
   long int x[50];
   long int yn=0;
   int i=0;
   for (i = 0; i < N; i++)
        {
            x = 0;
        }
     for( i=0; i<2500; i++)
    {
        for(int k=0; k < N-1; k++)
        {
          x[N-k-1] = x[N-k-2]; //shIFt the data
        }

              
        x[0] = X; // move input sample to buffer
        yn = 0; // clear output sample

        for(int k=0; k < N; k++)
        {
            yn += h[k]*x[k]; // multiply data on coefficients with accumulation
        }

        Y = yn;
      }



   



     for (i = 0; i < 2500; i++)
    {
        *X = Y;
        X++;
    }
}

Now, I am calling this function in my main function and turning on and off an LED to know whether this block is executing or not?  I have implemented the same code in pic24fj256gb206 (ram=96 KB) and the led blinked after some time. However, same doesn't happen with the case of dspic33fj256gp710a (ram=30 KB).

As per my calculations required ram for above block is:
a) 10 KB for X
b) 10 KB for Y
c) 400 B(50*4) for x
d) 100 B(50*2) for h
e) 10 B for yn,k,i,N  and
f) some amount of ram is required for processing data
Adding a) to e) is roughly 20.5 KB, so the question is, isn't 9.5 KB sufficient enough for processing the above data? Am I missing something?

I though of attaching build output (as an image) too, if one wants to point to anything interesting there but Access Denied.


Note to dsPIC fans: I will modify the code for efficient usage of dsPIC instructions :)
0
2019-7-30 11:22:11   评论 分享淘帖 邀请回答

相关问题

19个回答
你会错过正确配置时钟系统吗?原则上,如果得到一个十六进制文件,生成输出时没有发出(显著的)警告,并且代码已经在另一个设备上运行,那么它应该在新的C上也能够执行。执行死刑。

以上来自于百度翻译


      以下为原文

    Could it be you missed to properly configure the clock system ?
In principle, if you get a hex file, no (significant) warnings from building the output, and the code already ran on another device, it should execute as well on the new µC.
Depending on µC clock, it could take considerably longer :)
 
If you have some debugger (PICkit, ICD), you should be able to check the execution.
2019-7-30 11:30:15 评论

举报

为了避免时钟问题,当我使用一个新的UC时,我做的第一件事是在1秒内用定时器中断闪烁一个LED。如果我对上述firFilter()的调用进行注释,那么LED在1秒内闪烁,如果我没有注释,忘记我正在开启和关闭的LED,在调用firFilter()之前和之后,闪烁的LED停止闪烁,这表示即使定时器中断也不工作。这两种情况都没有任何警告。

以上来自于百度翻译


      以下为原文

   
To avoid the clock problem, the first thing I do when I am using a new uC is to blink an LED using the timer interrupt at 1 sec. If I comment the calling of the above firFilter(), LED blinks at 1 sec and If I don't comment, forget about the LED which I am turning on and off, before and after calling of the firFilter(), the blinking LED stops blinking which suggests even the timer interrupt isn't working.
 
Build is successful in both the cases without any warnings.
2019-7-30 11:38:36 评论

举报

当中断不再工作时,这有点可疑……您可以尝试在任何函数之外找到以下变量——只是为了确保没有堆栈/堆问题:BTW:调试器怎么样?

以上来自于百度翻译


      以下为原文

    When the interrupt is no longer working, this is slightly dubious...
 
You could try to locate the following variables outside any function - just to make sure there is no stack/heap problem:
long int Y[2500];
long int x[50];
 
BTW: what about a debugger ?
2019-7-30 11:49:34 评论

举报

通过定位,我推测可能在FiFrter()之外的数组重复。如果是这样的话,不存在数组的重复。我知道有人在谈论堆栈/堆或相关术语,所以我想上传构建输出为映像,但拒绝访问。我已经在代码块内添加了图像链接:目前,我没有调试器,我明天将使用它。礼貌的询问:我过去20分钟试图发布上述内容,论坛行为怪异,我出错,页面没有加载等等。有人面临这个问题吗?论坛是马车吗?

以上来自于百度翻译


      以下为原文

   
By locate I am presuming possible duplication of the arrays outside the firFilter(). If that's the case, no, there is no duplication of the arrays. I know someone would be talking about stack/heap or related terms, so I thought of uploading the build output as an image but Access Denied.
 
Here's the workaround. I have added the image link inside the code block:

http://imgur.com/MEwBqH3

 

Currently, I don't have the debugger with me, I will use it tomorrow.
 
Polite enquiries: I was trying to post above content for the past 20 min, forum behaves in a weird way, I am getting error, pages doesn't load etc. Is anyone facing this issue? Is the forum buggy?
2019-7-30 12:03:41 评论

举报

关于“怪异行为”:这些都是日常问题。开始约14小时CEST(欧洲中部夏季时间),并沉降至20小时(CEST)。似乎是一些过载情况。不是均匀地分布在所有线程上,而是在某种程度上是随机的……我所看到的:堆栈实际上占据了可用的整个RAM。我不确定编译器是否能够在这些条件下执行有用的检查。很可能是堆栈空间[8]和NO:MOVE(至少对于大数组)有一些意外的“重用”,将变量声明(包括main())从函数内部(包括main())复制到全局名称空间。只是为了确保不会发生重用/重写条件。如果你还有其他的大变量…

以上来自于百度翻译


      以下为原文

    Regarding 'weird behavior': these are the daily issues. Starting around 14.00 h CEST (Central European Summer Time) and subsiding until 20.00 h (CEST). Seems to be some overload condition. Not equally spread over all threads but to some extend random...
 
What I've seen: the stack in effect occupies the whole RAM available.
I'm not sure whether the compiler is still capable to perform useful checks under these conditions. Could well be that there is some unintended "re-use" of stack space [8)]
 
AND NO:
MOVE (not copy) the variable declarations (at least for the big arrays) from within your function(s) (incl. main()) to the global namespace.
Just to make sure that no re-use/overwrite conditions can happen. If you've got some other big variables ...
2019-7-30 12:22:08 评论

举报

感谢你的分析,我会尽量避免在论坛上面提到的时间:)我实际上没有理解上面的引用。对不起,忘记在原始帖子的底部拷贝几行代码。原始帖子被编辑了。

以上来自于百度翻译


      以下为原文

   
Thanks for the analysis, I will try to avoid the forum as much as I can during the mentioned period :)
 

I actually didn't understand the above quote.

I am sorry, forgot to copy couple of lines of code at the bottom of the original post.Original post edited.

for (i = 0; i < 2500; i++)
    {
        *X = Y;
        X++;
    }
2019-7-30 12:28:55 评论

举报

你想做什么?对于您的代码来说,完全不需要“Y”变量,并且“x”变量(在初始化之前使用BTW)也可以通过很少的重新安排来消除。所以,如果你删除它们,你的记忆状况会变得更好。

以上来自于百度翻译


      以下为原文

    What are you trying to do?
 
For your code to do what it does, the "Y" variable is not needed at all, and the "x" variable (which is BTW used before it is initialized) can be eliminated too with little re-arrangements. So, if you just remove them, your memory situation will become much better.
2019-7-30 12:39:44 评论

举报

上面的代码是第一个FiFLASH版本。我已经修改了关于x变量初始化的原始帖子(对不正确的粘贴表示歉意,这是由于分别粘贴每个块造成的)。我发布第一个版本的代码的原因是,我觉得有点奇怪,代码在一个uC中运行,而不是在dsPIC中运行,即使为执行该功能而计算的RAM需求在dsPIC的限制之内,至少根据我。

以上来自于百度翻译


      以下为原文

   
The above code is the first version of firFilter I started with. I have modified the original post regarding the initialization of x variable (My apologies regarding the improper pasting, it's due to pasting each block separately)
 
Coming to Y variable, I have modified it in the second version with exactly what you said above. The reason I have posted the first version of code is because I felt it a bit strange that code is running in one uC and not running in the dsPIC even though the calculated RAM requirements for execution of that function is well within limits of the dsPIC, at least according to me.
2019-7-30 12:46:59 评论

举报

为了记忆,你需要看地图。局部变量将流向堆栈。你需要看看地图上的堆栈大小。我想我看过修改后的版本。我认为不需要任何“Y”变量。它保存数据,然后复制到“X”。你可以把它们直接复制到“X”,这样就不需要“Y”了。“x”也是如此:可以直接从“X”获得数据,绕过“x”(尽管它主要影响性能,而不是内存)。

以上来自于百度翻译


      以下为原文

    For memory, you need to look at the map. Local variables will go to the stack. You need to look at the stack size on the map.
 
I think I looked at the modified version. I don't think there's any need for "Y" variable. It holds data which are then copied to "X". You can copy them directly to "X" thus eliminating the need for "Y". Same holds for "x": you can get data directly from "X", bypassing "x" (although it has mostly performance impact, rather than memory impact).
2019-7-30 12:52:10 评论

举报

这就是我在上面附加构建输出的原因,其中可以看到我确保所有堆栈都可用于执行函数,在本例中是firFilter()。我试图附加地图文件,但论坛的行为在其最奇怪的方式可能。它不允许我将文件附加为文本文件。猜猜看,附件按钮本身不工作。感谢您指出这些修改,但我不知道您引用的是哪个版本,并且所有提到的优化已经在我当前版本的代码中得到处理。我没有使用firFilter()是因为我很好奇,当9.5KB可用于数据处理时,为什么没有执行firFilter()呢?

以上来自于百度翻译


      以下为原文

   
That is the reason I have attached build output above, where one can see I have made sure all the stack is available to execute a function, in my case, firFilter(). I am trying to attach map file but forum is behaving in its weirdest way possible. It is not allowing me to attach the file as a text file. Guess what, the attachment button itself isn't functioning.
 

Thank you for pointing those modifications but I don't know which version you are referring to and all the mentioned optimizations have already been taken care in my current version of the code.


You might ask, why did I post above code when I am not working with it, it is because I felt curious to know what is the reason behind not execution of the firFilter() when 9.5 KB is available for data processing?
2019-7-30 13:05:53 评论

举报

我猜这是另一回事,与记忆无关,但它的信息太少,不能得出任何结论。

以上来自于百度翻译


      以下为原文

   


My guess is this is something else, not related to memory, but it's too little information to draw any conclusions.
2019-7-30 13:14:09 评论

举报

WDT开启?

以上来自于百度翻译


      以下为原文

    WDT turned on ?
2019-7-30 13:30:51 评论

举报

也许你需要一个大的内存模型来存储数据?Ruben

以上来自于百度翻译


      以下为原文

    Perhaps you need a large memory model for data memory?
 
/Ruben
2019-7-30 13:46:33 评论

举报

这是我的主要代码:我希望这些信息是足够的。

以上来自于百度翻译


      以下为原文

   


Here's my main code:
 #include "System.h"
#include "Timer.h"
#include "Algorithm.h"

//_FOSCSEL(FNOSC_PRIPLL & IESO_OFF)
#pragma config FNOSC=PRIPLL
#pragma config IESO=OFF

//_FOSC(POSCMD_XT & FCKSM_CSDCMD)
#pragma config POSCMD=XT
#pragma config FCKSM=CSDCMD

//_FWDT(FWDTEN_OFF)
#pragma config FWDTEN=OFF

//_FICD(ICS_PGD1 & JTAGEN_OFF)
#pragma config ICS=PGD1
#pragma config JTAGEN=OFF

unsigned char flag=0;
volatile unsigned char timer1Count=0;

int main(void)
{
    CLKDIV=0x0000;
    PLLFBD=0x0026;
 
  startTimer1(3,0,15625);     //prescalar value=3;gate value=0;PR1=15625; timer1 is on with IE bit set
    
  long int signal[] = { };         //2500 int values have been pasted here
   _TRISA0=0;
   _TRISA1=0;
   _LATA1=1;
  firFilter(signal, bpfCoeffs,50); //this is the firFilter() I have posted in my original post
   _LATA1=0;                                                  //bpfCoeffs are declared as const int in "Algorithm.h"
  
    while(1)
    {
    }
    return 0;
}

void __attribute__((__interrupt__, auto_psv)) _T1Interrupt(void)
{
    IFS0bits.T1IF=0;
    timer1Count=timer1Count+1;
    if(timer1Count>=10)
    {
        timer1Count=0;
        _LATA0=~_LATA0;
    }
}
I hope this information is sufficient.
2019-7-30 13:56:59 评论

举报

哈哈,这是显而易见的,因为它与具有RAM 96 KB的uC一起工作,但如果有人回答我的问题,那么将来粗略地预测执行特定功能需要多少RAM将是有帮助的。

以上来自于百度翻译


      以下为原文

   
Haha, that is evident since it is working with a uC having RAM 96 KB but if one answers my question it would be helpful in future to roughly predict how much RAM is required to execute a particular function.
2019-7-30 14:13:23 评论

举报

看地图,堆栈的地址和大小是多少?当你运行它时会发生什么?

以上来自于百度翻译


      以下为原文

    Looking at the map, what is the address and size of the stack?
 
What happens when you run it?
2019-7-30 14:19:18 评论

举报

动态存储器使用地址最大长度(dec)-----------------------------------------------------堆0(0)堆0x8020x77fe(30718)最大动态存储器(字节):上面代码中的0x77fe(30718)A0和A1连接到LED(活动高电平)。当我注释调用firFilter()时,A0在1秒内闪烁,而当我取消注释时,A1保持高电平,A0保持低电平,并且不闪烁。

以上来自于百度翻译


      以下为原文

   

Dynamic Memory Usage

region                     address                      maximum length  (dec)
------                     -------                      ---------------------
heap                             0                                   0  (0)
stack                        0x802                              0x77fe  (30718)

                 Maximum dynamic memory (bytes):         0x77fe  (30718)
 

A0 and A1 in above code are connected to LED's (active HIGH). When I comment calling of the firFilter(), A0 is blinking at 1 sec,and when I uncomment, A1 stays HIGH and A0 stays LOW and doesn't blink.
2019-7-30 14:26:43 评论

举报

该死的,甚至是另一个版本的代码,其中y根本没有被使用在FiFrter()中,没有运行。在新版本中,可用RAM是(9.5+10)kb。为什么它不运行??

以上来自于百度翻译


      以下为原文

    Damn, even the other version of the code where Y isn't utilized at all in the firFilter() isn't running. With the new version the available RAM is (9.5+10) KB. Why isn't it running??
2019-7-30 14:41:12 评论

举报

目前,我没有调试器,我将在明天使用它,使用它!

以上来自于百度翻译


      以下为原文

   
Currently, I don't have the debugger with me, I will use it tomorrow.
</blockquote>
Use it!
2019-7-30 14:47:13 评论

举报

只有小组成员才能发言,加入小组>>

57个成员聚集在这个小组

加入小组

创建小组步骤

关闭

站长推荐 上一条 /10 下一条

快速回复 返回顶部 返回列表