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.

Number of byte of the flash

Other Parts Discussed in Thread: MSP430F248

 

I want to calculate number of bytes which was programmed between 2 memory addrasses. writing the function can I do it? please help me.

have any sample code send me. (MSP430F248)

 

Thanks.

  • result = higherAddress-lowerAddress; // higherAddress/lowerAddress being an INT or a char* or a void*

    Based on your question, it's that simple. If it isn't, then you should add more information about what you exactly want to do..

  • Thanks for the answer.

    exactly I want to integrity check of the flash programe. so i want assign array for all byte of the programe. So I want to know number of write byte(not FFFF ones) . how do this?

    pleas help me.

  • Chinthaka Dinesh said:
    So I want to know number of write byte(not FFFF ones) . how do this?

    Frankly, I don't know. The position of the data in flash is fixed by the linker, and based on the specific algorithm of exactly this linker and version and the linker command files of this linker and version for the selected processor, the code may end up anywhere. Grouped together at start of flash, before or after the variable init values and/or constants etc. It even depends on the order you added your source files to the project.

    The only location where the info is found is the map file that you can analyze to see where in the flash the code is located. And maybe the binary file. There's no way for the code to know or determine it.

    However, to check the integrity, you need to include this integrity information (probably a checksum) to the binary. Also, you only know the correct checksum after the program has been compiled and linked. So you already need to add this info directly to the binary after compiling and lining - or you add it to info memory in a second programming run. Either way, you can add the info where the code is (based on analysis of the map file, which you already need to do to originally build the checksum) to the checksum data and pass both together to the MSP.
    The MSP code then only needs to take the start address and cast it to a unsigned char * and you can access the whole code area like an array.
    Keep in mind that arrays usually (depends on the compiler) have a maximum of 32767 elements, so if your code is larger than 32k, you'll need to increment the pointer to the array itself instead of using an index.

    *(ptr+index) rather than ptr[index].

**Attention** This is a public forum