This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

cc2531 - storing data to flash, bank 2.

Other Parts Discussed in Thread: CC2531, REMOTI, CC2533

hi all, 

i need a help here.

i'm using cc2531 and i need to store some data to flash so that i will not be erased when the power is off.

i'm using library in RemoTI software to use the flash controller, which are hal_flash.c & hal_flash.h ( i used it as it is)

i specified my storage address at 0xf000.

and I got my data is stored in memory address 0x1f000 (i guess this is bank 1 although i didn't select which bank i want to use).

so, my question is,

how can i specify the bank  number ? i want to access (read, write, & eras) flash in memory address 0x2f000.

thanks.  

 

  • Hi Iman,

    The address to use in HalFlashWrite is the word address, i.e. actual address / 4. So, if you want to write to address 0x2F000:

    0x2F000 is a logical address which corresponds to physical address 0x17000 (1 bank is 0x8000 in size)

    4-byte aligned address is then 0x5C00 (23552)

  • Hi Torbjorn, 

    Thank for your reply, i will try on that tomorrow (coz it's midnight here.. lol)

    but, could you explain a bit more how to convert logical address to physical address?
    this my first time dealing with memory stuff, and i feel it's quite tricky. 

    today, what i did is to make a function like below (just a pseudo-code):

    #pragma location = "BANK7"

    void saveData (uint8 *buffer) {

    HalFlashErase(0xf000);

    HalFlashWrite( (0xf000/4) , buffer, 13);

    }

    i put the function on Bank7 and what i got from above is data stored at 0x7f000.

    what do you think about this method ? I think this is not correct, but, it works. 


    thanks for your time. 

    cheers,

    Iman. 

  • Hi Iman,

    The problem with your attempt is that you're lucky, more than correct ;) The argument to the erase function is the page number. Although the flash page size of CC2533 is only 1KB we use 2KB even for that device. You're working with CC2531, so nothing weird there.

    Logical Address Physical Address 4-byte Aligned Page (2KB Flash Page Size)
    0x00000 0x00000 0x0000 0
    0x01000 0x01000 0x0400 2
    0x07000 0x07000 0x1C00 14
    0x07FF0 0x07FF0 0x1FFC 15
    0x18000 0x08000 0x2000 16
    0x1FFFC 0x0FFFC 0x3FFF 31
    0x28000 0x10000 0x4000 32
    0x2FFFC 0x17FFC 0x5FFF 47
    0x38000 0x18000 0x6000 48

    First 32 KB address range is the same for logical and physical, above that each 32 KB range is from 0x8000-0xFFFF and the MSB (3rd byte) signifies the bank.

  • Hi Torbjorn, 

    haha.. yeah, i was lucky. 

    anyway, thanks for your explanation. so much clear now.

    i'll try your method and get back with the result. 

    have a nice day there.

    cheers, 

    Iman. 

     

  • Hi Torbjorn, 

    Just want to say that your answer is confirmed. 

    I've tried it and it works. 

    Hope this thread useful for others. 

    thanks a lot. 

    Iman.