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.

Using data flash on F5438

Hello!

Just an update to say that the code below works. I just forgot to stop interrupts. Sorry.

The code below works. If you send several bytes, just add a wait condition on FCTL3.

Pascal

 

----------------

Hello!

I have to use the data flash on a F5438. I was successfully using it on a F169 and I tried to

write some similar code. For some reason FCTL2 disappeared and there are no FCTL 1, 3, 4.

I choosed info D, therefore 0x1800.

What I wrote is as follws (in fact, I just rewrote in C what is in the user guide in assembler).

The watchdog is already stopped, so I started directly from the next line:

uint8 * flashptr = (uint8 *)0x1800;

FCTL3 = FWKEY; // Clear lock

FCTL1 = FWKEY + WRT; // Enable write

flashptr[0] = 0;

FCTL1 FWKEY; // Disable write

FCTL3 = FWKEY + lock; // Lock

I have set a breakpoint at the first line to follow the whole process.

1. Before entering the above code segment, I have the 3 following flash

registers: 0c9600 in FCTL1, 0x9658 in FCTL2 and ox9600 in FCTL3

Apparently 0x9600 is a FRKEY, so does it mean that it is read by default?

2. When I step the line FCTL3 = FWKEY, instead of having 0xA500 as it should

be, I get 0x9648. Is this normal?

3. When I step FCTL1 = FWKEY + WRT, I get FCTL1 = 0x9640. In this case

I don't get 0xA540 as I logically should do.

4. After assigning the pointer, when I step flashptr[0] = 0, the program goes to

nowhere land.

Can anybody point me to some useful source code or tell me what's wrong?

Thanks,

Pascal

 

 

 

  • Pascal,

    Pascal said:

    1. Before entering the above code segment, I have the 3 following flash

    registers: 0c9600 in FCTL1, 0x9658 in FCTL2 and ox9600 in FCTL3

    Apparently 0x9600 is a FRKEY, so does it mean that it is read by default?

    Yes. FRKEY is read as 0x96 and to Write is 0xA5.

    Pascal said:

    2. When I step the line FCTL3 = FWKEY, instead of having 0xA500 as it should

    be, I get 0x9648. Is this normal?

    Yes. Also to note that if you write a wrong FWKEY to it, the system will cause a PUC to RESET the MSP430.

    Pascal said:

    4. After assigning the pointer, when I step flashptr[0] = 0, the program goes to

    nowhere land

    When writing to flash, you can't single step. The reason is because a single Flash write operation takes a certain amount of clock cycles which can be found in the datasheet. When a single step operation occurs and ended, it halts the clocking of the Flash before Flash write is completed and therefore the Flash write operation never completes thus causing the system to go nowhere land. In all, you will have to let your MSP430 run through the Flash write section to observe its behavior.

    Hope that helps

    William

     

     

  • Hello William!

    Thanks for your reply, it was very helpful. I didn't change anything in my code as it was already

    working, but it's useful because I was worrying about a very odd bug that would popup at random

    times, and now I know what happened.

    Thanks again!

    Pascal

     

**Attention** This is a public forum