Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
02/24/03 00:14
Read: times


 
#39865 - RE: DS1620. Look-up table?
Responding to: ???'s previous message
Rob:
In the first part the Table you called Hex_Table needs to be in the CODE address space so that the MOVC instruction works to
fetch the data. The code you show works as long as each entry in the table is 1 byte in size and the table is shorter than 256 bytes.

Normally you will place lookup tables in the CODE space and use code like your first part to access them. This is best for tables that contain constant data that does not change during the run of the program.

Sometimes it is necessary to have lookup tables that do not have constant data. Either the data is computed, downloaded from PC or read in from serial EEPROM or whatever else. in these cases the table needs to be located into memory that can act as Read/Write memory. For very small tables these can be put into the internal DATA memory space. If you have this type you typically index them with the....

MOV A,@Ri ;where R0 or R1 is the index.

type of instruction.

If the variable data table is larger then you would place it in the XDATA type space. Under these cases you access the table with code similar to that I showed in my example except that the MOVX instruction opcode is used instead.

In the code I showed for doing the indexing the requirements were a bit more complex. First off the index itself is greater than 8 bits (wont fit in a byte) and secondly the size of each entry in the table two bytes. In these cases the actual index to the entry in the table must be computed. The MOV A,#LOW(C2F_Table) and MOV A,#HIGH(C2F_Table) are used to load the actual high and low bytes of the base of the table into the A register so that it can be added to the index which is in the R6::R7 register pair. Note that code before that had multiplied the initial index value in R6::R7 by two. This multiply by two was done becasue each entry in the table is 2 bytes, whilest memory addresses access bytes. After the index is added to the base address of the table and placed into the DPTR register the DPTR is pointing at the memory address of the indexed entry in the table. It then takes two accesses with the MOVC A,@A+DPTR instriction to read the two bytes of the table enttry. One at DPTR+0 and one at DPTR+1.

Hope this makes sense now.
Michael Karas


List of 19 messages in thread
TopicAuthorDate
DS1620. Look-up table?            01/01/70 00:00      
   RE: DS1620. Look-up table?            01/01/70 00:00      
      RE: DS1620. Look-up table?            01/01/70 00:00      
         Internal External memory            01/01/70 00:00      
            RE: Internal External memory            01/01/70 00:00      
   RE: DS1620. Look-up table?            01/01/70 00:00      
      RE: DS1620. Look-up table?            01/01/70 00:00      
   RE: DS1620. Look-up table?            01/01/70 00:00      
      RE: DS1620. Look-up table?            01/01/70 00:00      
         RE: DS1620. Look-up table?            01/01/70 00:00      
         RE: DS1620. Look-up table?            01/01/70 00:00      
   RE: DS1620. Look-up table? / Erik            01/01/70 00:00      
   Sample LUT            01/01/70 00:00      
      RE: Sample LUT            01/01/70 00:00      
         RE: Sample LUT            01/01/70 00:00      
            RE: Sample LUT            01/01/70 00:00      
   RE: DS1620. Look-up table?            01/01/70 00:00      
      RE: DS1620. Look-up table?            01/01/70 00:00      
         RE: DS1620. Look-up table?            01/01/70 00:00      

Back to Subject List