Friday, August 18, 2017

Program memory size on MCUs

Funny thing: In most MCU datasheets, the program memory size is listed in KB. The PIC16F18325 for example is said to have 14KB of program memory.

Don't let this fool you! It does not mean that you can store 14KB of data/constants.

The problem is, each word (instruction) on the PIC16 is 14bits long. Storing an 8bit constant in program memory (flash/ROM) takes up 14bits of space.

So how big is the memory really? That's easy: 14KB = 14 * 1024 * 8 = 114688bits, divided by 14bits per word = 8192. Thus, the "real" memory size is 8KB - you can store 8K instructions or constants.

No comments:

Post a Comment