Electrical – How to store 8 bit character in 32 bit Data Flash memory

ccortex-m0flash-memoriesmicrocontroller

Is it possible to store 8 bit character to 32 bit Internal Data Flash in the Microcontroller by just using only 8 bit of space for each bytes?,by using a combination of 4 bytes which can be also recovered as individual bytes later.
I'm using Nuc240 (ARM-M0) Microcontoller with 32 bit Data Flash and 512 bytes erase limit,read write limit is 32 bit.
Please explain a code template if possible.

Best Answer

Yes, by either array or structure.

char memory [4] = { 'a', 'b', 'c', 'd' };  // Uses 4-bytes (32-bits)

// memory [0] = 'a';
// memory [1] = 'b';
// memory [2] = 'c';
// memory [3] = 'd';

// ... store 'memory' in internal flash memory ...

Or

typedef struct
{
    char byte_0;
    char byte_1;
    char byte_2;
    char byte_3;
} memory_t;

memory_t memory; // Uses 4-bytes (32-bits );

memory.byte_0 = 'a';
memory.byte_1 = 'b';
memory.byte_2 = 'c';
memory.byte_3 = 'd';

// ... store 'memory' in internal flash memory ...