Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Programmable Space on PICs

Status
Not open for further replies.

bsodmike

New Member
Okay. This has me baffled!

Take the PIC 12C672 for example - data sheet states memory = 2048 x 14...

What size can the HEX be? Is it wrong to say that 1 word = 2bytes for pics?

Regards,

Mike
 
bsodmike said:
Okay. This has me baffled!

Take the PIC 12C672 for example - data sheet states memory = 2048 x 14...

What size can the HEX be? Is it wrong to say that 1 word = 2bytes for pics?

14 bit core PIC's obviously use 14 bit memory (hence the name), 12 bit core PIC's (like the 12C508) use 12 bit memory.

It's totally irrelevent what you call it, a word is fine (and can apply to either 12 or 14 bit) - but as it's only program memory which is 14 bit you can't access it anyway - the data registers are only 8 bit.

On most processors instructions are different lengths, for example:

LDA $23

Would load the accumulator with the hex value 23 on a 6502 (as far as I can remember, it's been a long time!), it would take two bytes - one for LDA and one for $23. On the 6502 instructions can be various lengths, in this case 2 bytes, but they can be 1 or 3 bytes as well.

On the PIC a similar command would be:

MOVLW 0x23

This loads hex 23 in to the W register, it only takes one word, and the data (0x23) is actually part of the instruction. On the PIC, all instructions are one word long - which makes things much simpler. One reason for this is the RISC instruction set - a complex instrcution set can't do this because of the sheer number of instructions.
 
Well....what I'm trying to figure out *really* is how much 'space' the PIC has for my HEX. So I code, compile and I should know when my code is 'too large' for the PIC?

Right now the code for the 12C672 is about 2055 bytes (or a little more)....

thanks...!
 
bsodmike said:
Well....what I'm trying to figure out *really* is how much 'space' the PIC has for my HEX. So I code, compile and I should know when my code is 'too large' for the PIC?

Right now the code for the 12C672 is about 2055 bytes (or a little more)....

It's got space for 2048 instructions, when you say your code is 2055 bytes, what code do you mean?. If it's the HEX code produced by the assembler that will be a great deal larger than the actual machine code, full details of the format are in the MPASM help file appendix.

If your program is too large the assembler should give an error during assembly, personally I've never seen it happen - but 2K of PIC machine code is really quite a lot!.
 
Ohhhh...... okay now I got it. No wonder 1.87KB of hex only used up 30% of the memory on the PIC (someone elsed flashed an OTP with some some software that showed how much space was used)

okay thanks, this makes a lot more sense now.
 
If you view the Program Memory while in MPLAB you will be able to see each instructions location in memory and from that you can tell how much memory your code takes up.

-Bill
 
Oooh thanks!

Using 355 lines of code so far.... awesome :D I see what you guys mean!
 
:wink:
If you scroll down the "absoulte listing" (or *.lst file) of your project, right at the bottom there is some stats about your file, how much space used and how much is free :wink:
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top