pic adress range.

Status
Not open for further replies.

tracidfish

New Member
My code is getting rather long

So far i have about 1K bytes of look up tables!
I know I have enough programme memory to deal with the rest of the code.

Do i need to worry about the limit of the pic's address range?

If so how would I find out what the address range is, I cannot find anything on the data sheet.

i am using a pic16f628.

Thanks
 
Are you saying your code written to the flash is running out of space? Or are you saying your out of EEPROM space? If you run out of EEPROM space, you can interface with an external EEPROM chip for much more space.

Now that PIC has 1KB, or 1024 bytes of EEPROM. So if you say you have about 1K, your getting close. If you run out of space, you should get an error. Then you'll know your out of space
 
No I have not yet used the EEPROM

i would like to save this space for future development.

I am concerned about the address range in the flash programme memory.
 
Each byte of your lookup table is stored in one instruction word. The program counter for mid-range PICs such as the 16F628A can address up to 8K instructions. Only 2K instruction locations are implemented in the 16F628A. The 16F648A has 4K locations implemented. This information is found in the data sheet in the section on memory organization.
 
For midrange PICs the instruction word is 14 bits. A lookup table is built using the RETLW instruction. Six bits are used for op code and 8 bits for the data. See the description of memory organization and the instruction set. Its all spelled out clearly in the data sheet.
 
If you run out of space which is unlikely as you are currently only using half of it then I suggest switching to the more modern 16F88. Not only has it got 4k x 14 flash locations the program can read/write to the flash at runtime. Therefore, if your data is ascii strings, each location can hold two characters hence doubling your storage ability. I have used this method many times and have various utilities to construct the data.

Mike.
 
If large tables are your thing then I would take a look at the 18F series PICs. Much more efficient table and memory use over the 16F parts.
 
It might be worth checking out the new "enhanced" mid-range devices too (in 18, 28, and 40-pin DIP packages so far with 8 and 14-pin devices coming soon).

With the ability to read and write the stack pointer on the "enhanced" devices you can reduce code "overhead" to 1 word per string, plus the storage required for each in-line string table, just by using a simple method like this;

Code:
        call    putstrg         ;
        dt      "hello world/n/r/0"

        call    putstrg         ;
        dt      "16F1936 Serial I/O Demo/n/r/0"
Code:
putstrg
        banksel TOSL            ; bank 31                         |B31
        movf    TOSL,W          ; top-of-stack lo                 |B31
        movwf   FSR1L           ;                                 |B31
        movf    TOSH,W          ; top-of-stack hi                 |B31
        iorlw   128             ; set FSR1.15 for rom access      |B31
        movwf   FSR1H           ;                                 |B31
getchar movlb   0               ; bank 0                          |B0
        moviw   INDF1++         ; null terminator?                |B0
        bz      putexit         ; yes, exit, else                 |B0
        call    Put232          ; print string character          |B?
        bra     getchar         ; loop                            |B?
putexit movlb   31              ; bank 31                         |B31
        movf    FSR1L,W         ; adjust return address           |B31
        movwf   TOSL            ;                                 |B31
        movf    FSR1H,W         ;                                 |B31
        movwf   TOSH            ;                                 |B31
        movlb   0               ; bank 0                          |B0
        return                  ;                                 |B0
 
Last edited:

Hi pommie.

Would you be able to show me how your tables are constructe useing this method?

Thanks
charlie
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…