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.

cc2541 flash

Other Parts Discussed in Thread: CC2541

Hi

1. I develop BLE application on CC2541 MCU and I base my application on SimpleBLEPeripheral

2. I want to use DMA flash writing for some of my data as demonstrated in flash_c254x example from CC2541_43_44_45_Peripherals_Software_Examples

3. The flash example alone works perfect.

4. However when I have implemented that code in SimpleBLEPeripheral, the data that is written to the flash seems corrupted (it is read and displayed after writing) and it is possible to write the data only once. When trying to write second time the code is stuck at  while (!(DMAIRQ & DMAIRQ_DMAIF0));

5. I thought the problem is in the link file, so I have used lnk51ew_CC2541F256_banked.xcl that is used in flash_c254x  example , but when I link I get the following error

Fatal Error[e72]: Segment BANKED_CODE must be defined in a segment definition option (-Z, -b or -P)

6. Appreciate any help

  • Are you erasing the flash page before each write? Flash bits can only be written from 1 to 0, not the otherway round.

  • There are very specific rules for writing flash multiple times

    See section 6.2.2 page 77 of the CC253X/4X user guide;

        /*
         * The following rules apply when writing multiple times to a 32-bit word between erase:
         *     • Writing 0 to a bit within a 32-bit flash word, which has been set to 1 by the last erase operation,
         *       changes the state of the bit to 0, subject to the last bullet below.
         *     • It is possible to write 0 to a bit within a 32-bit word repeatedly (subject to the last bullet below) once the
         *       bit has been written with 0. This does not change the state of the bit.
         *     • Writing 1 to a bit does not change the state of the bit, subject to the last bullet below.
         *     • The following limitations apply to writes subsequent to the last page erase:
         *         – A 0 must not be written more than two times to a single bit.
         *         – A 32-bit word shall not be written more than 8 times.
         *         – A page must not be written more than 1024 times.
         * The state of any bit of a 32-bit flash word is nondeterministic if these limitations are violated.
         *
         * This makes it possible to write up to 4 new bits to a 32-bit word up to 8 times.
         */

    HOWEVER

    I followed these rules and after filling up ~6k of a flash buffer about 40 bytes at a time, the DMA just stops functioning.

    Anyone got a fix??

  • @Eng351

    Your comment is only partially true - you can write one 32 bit word up to 8 times setting any 1->0

    However, you can't re-write a 0 more than twice - makes multiple writes tricky!