+ Post New Thread
Results 1 to 9 of 9
  1. #1
    Member level 1
    Points: 648, Level: 5

    Join Date
    Nov 2015
    Posts
    34
    Helped
    0 / 0
    Points
    648
    Level
    5

    Flash memory programming for DSPIC33EP256MU806

    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

    •   AltAdvertisment

        
       

  2. #2
    Super Moderator
    Points: 27,297, Level: 40
    andre_teprom's Avatar
    Join Date
    Nov 2006
    Location
    Brazil
    Posts
    8,170
    Helped
    1029 / 1029
    Points
    27,297
    Level
    40
    Blog Entries
    5

    Re: Flash memory programming for DSPIC33EP256MU806

    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.
    --------------------------------------------------------------------------------------------------
    Part of the world that you live in, You are the part that you're giving ( Renaissance )



  3. #3
    Advanced Member level 3
    Points: 6,453, Level: 19

    Join Date
    Jan 2015
    Posts
    939
    Helped
    296 / 296
    Points
    6,453
    Level
    19

    Re: Flash memory programming for DSPIC33EP256MU806

    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



    •   AltAdvertisment

        
       

  4. #4
    Super Moderator
    Points: 27,297, Level: 40
    andre_teprom's Avatar
    Join Date
    Nov 2006
    Location
    Brazil
    Posts
    8,170
    Helped
    1029 / 1029
    Points
    27,297
    Level
    40
    Blog Entries
    5

    Re: Flash memory programming for DSPIC33EP256MU806

    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.
    --------------------------------------------------------------------------------------------------
    Part of the world that you live in, You are the part that you're giving ( Renaissance )



    •   AltAdvertisment

        
       

  5. #5
    Member level 1
    Points: 648, Level: 5

    Join Date
    Nov 2015
    Posts
    34
    Helped
    0 / 0
    Points
    648
    Level
    5

    Re: Flash memory programming for DSPIC33EP256MU806

    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.



  6. #6
    Advanced Member level 3
    Points: 6,453, Level: 19

    Join Date
    Jan 2015
    Posts
    939
    Helped
    296 / 296
    Points
    6,453
    Level
    19

    Re: Flash memory programming for DSPIC33EP256MU806

    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



  7. #7
    Super Moderator
    Points: 61,770, Level: 60
    Achievements:
    7 years registered
    Awards:
    Most Frequent Poster 3rd Helpful Member

    Join Date
    Apr 2014
    Posts
    12,597
    Helped
    2921 / 2921
    Points
    61,770
    Level
    60

    Re: Flash memory programming for DSPIC33EP256MU806

    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
    Please dont contact me via PM, because there is no time to respond to them. No friend requests. Thank you.


    1 members found this post helpful.

    •   AltAdvertisment

        
       

  8. #8
    Member level 1
    Points: 648, Level: 5

    Join Date
    Nov 2015
    Posts
    34
    Helped
    0 / 0
    Points
    648
    Level
    5

    Re: Flash memory programming for DSPIC33EP256MU806

    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.



  9. #9
    Advanced Member level 3
    Points: 6,453, Level: 19

    Join Date
    Jan 2015
    Posts
    939
    Helped
    296 / 296
    Points
    6,453
    Level
    19

    Re: Flash memory programming for DSPIC33EP256MU806

    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



--[[ ]]--