Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Flash memory programming for DSPIC33EP256MU806

Status
Not open for further replies.

kiransbaddi

Member level 2
Joined
Nov 30, 2015
Messages
51
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Activity points
427
I want to store a 2D array of abc[400][256] in Flash program memory to store random values for noise generation. My device has a capacity of 87296 Words.

Problem
I m able to use only 34% of memory. I m getting a error message of array size is too large.

what could be the problem
 

The fact that program memory size is given in Words (16 bits for dsPic) does not mean that values declared with a presumable lower magnitude (8 bits, byte) would necessarily be stored without wasting memory space. Try to set different compiler optimization options, which are usually opposed: space x speed.
 

According to my old fashioned maths, 400 * 256 = 102,400. You have not said what sized values you are wanting to store.
The data sheet shows that MCU having space for 87552 instructions (excluding the auxiliary memory). Now each instructor is 24 bits wide (the addressing scheme will always return a top byte of all 0's for add addressed words - see Figure 4-2). Therefore you can use 34,134 instruction locations to store your array if the values are bytes, but unless you want to employ some very fancy decoding, you will be out of luck for 16-bit or longer values.
Basically, the rule is that trying to store large arrays in a microcontroller means you have selected an inappropriate design. At worst you could put the array into an external EEPROM.
Without knowing what sort of values are being stored, it is hard to offer alternative strategies - is the array sparse; can the values be calculated; is it something like a trig lookup table in which case it can be cut in 1/4 the size etc.
Susan
 

Some compilers have the capability of (via pre-processor directive), when creating a structure composed of variables of specific size in a core of a larger word lenght, it can be aligned in such a way not to waste memory space, as for example the __attribute__((aligned(SIZE))) available on GCC.
 

Thank you for your kind reply. I m storing random no. to generate white noise, the random nos have range between 0-255 or 8 bit value only. So i m using 8 bit data to store in program memory.
 

I would have thought it would be much easier to generate pseudo-random numbers as you need them rather than store them.
Unless you needed a completely repeatable sequence (in which case it is moot whether it is really 'white noise' which is truly random). Also if you start a pseudo-random number generator off with the same seed then you will get the same sequence anyway.
Susan
 

Hi,

Yes, I also vote for a pseudo random generator.
Only a little code, but much better performance.
0...255 is 8 bits only.
400x256 bytes gives good low frequency performance....
but with 8 bits resolution I expect some artefacts..


Klaus
 
you mean to say we can generate random nos. without storing it using random no. generator. Sure I will try this. thanks for your great help.
 

Yes but remember that they are pseudo-random numbers. Also, depending on the context, you may need to use a different seed every time the code is restarted so that you don't generate the same sequence as after the last restart.
If you are writing in C then you will probably already have access to a 'rand()' function.
Susan
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top