Why don=92t you use a calculated table jump? There's an appnote (I = think, or even in the refman) with code. No more worries where the table is located. -----Original Message----- From: pic microcontroller discussion list [mailto:PICLIST@MITVMA.MIT.EDU] On Behalf Of Mike Blakey Sent: dinsdag 12 februari 2002 13:51 To: PICLIST@MITVMA.MIT.EDU Subject: Re: [PIC]:Program memory tables - Advice please Thanks Tony, What I think I'm after is a hybrid of both !! i.e. store the table in=20 EEDATA, and write it into program memory as the Micro boots up. If I load it into RAM, I don't have enough RAM in one page to hold the full table,=20 so I would not be able to use ADDWF PCL to do a table read. you could look at it as I want to use ADDWF PCL but the table has to be alterable=20 an reconfigured, without reprogramming the Micro. I can't really wait for the 18F252 to hit the streets either!! Thanks. tony.kubek@FLINTAB.COM on 12/02/2002 11:18:27 Please respond to PICLIST@MITVMA.MIT.EDU@INTERNET@wtgw To: PICLIST@MITVMA.MIT.EDU@INTERNET@wtgw cc: =20 Paper Mail:=09 Subject: Re: [PIC]:Program memory tables - Advice please *** WARNING *** This mail has originated outside your organization, either from an external partner or the Global Internet.=20 Keep this in mind if you answer this message.=20 Hi, Mike Blakey wrote: >I am using a 16f876 and have a large lookup table of values, (196=20 >bytes) At present >this table is in EEDATA. the access to the data is not quite fast=20 >enough, I believe >that it is possible to copy this data into program memory, possible=20 >using a routine >at boot-up. I have looked in Microchips archive, and don't fully=20 >understand how to >do this. Has anyone done this sort of thing before, and could point me=20 >in the right >direction, Thanks. From what I understand you are using the eeram to store the table ? In that case I assume something like this is used to access it: ; *********************************************************************** ; EE_WRITE_BYTE - Routine to read a byte from ee ram ; Adress in W, byte will be delivered in W EE_READ_BYTE BANK2 MOVWF EEADR ; put in adress reg. BSF STATUS,RP0 ; bank3 !! BCF EECON1,EEPGD ; set to read data memory BSF EECON1,RD ; set bit to read BCF STATUS,RP0 ; bank2 !! MOVF EEDATA,W ; move data to W BANK0 ; Reset to BANK0 ! RETURN ; and return Something around 12 instructions not counting the call/return, if this is to 'slow' then there always is the program table path which can be accomplished by somthing like: GET_TABLE_BYTE ADDWF PCL MY_TABLE dt 0x01, 0x02, 0x03, 0x04,...... IF ((HIGH (=A4)) !=3D (HIGH (MY_TABLE))) ERROR "TABLE CROSSES PAGE BOUNDARY, RE-ALIGN !" ENDIF Which would generate more or less only 1 instruction for the same task. Which is as fast as you can go I'm afraid. On the 16F876 one can always access the flash mem by similar means as the eeram but it would only be something around 1-2 instructions shorter than the normal eeram read. However it would 'save' program space if it would be sufficient to save only 7 bits/variable. see: http://www.piclist.com/techref/microchip/tables.htm for additional info and pointers. *beware* of program pages ! /Tony -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics ******************************************************************** This email and any attachments are confidential to the intended recipient and may also be privileged. If you are not the intended recipient please delete it from your system and notify the sender. You should not copy it or use it for any purpose nor disclose or distribute its contents to any other person. ******************************************************************** -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics