On Thu, 4 Sep 2003 19:06:52 EDT, you wrote: >Hi all! > Had a look at the piclist memory method big lookup tables and >AN556 implementing table read now I am confused!! > > > > > I am trying to get data from a large lookup table in Page 1 >of 16f873- (similar table in page0 seems to work fine) This is the first time >I have used anything larger than a 16f628 so I think I may have messed up with >Page selecting and clearing. > > You're on the right track and yes, page select is causing the problems that you're seeing. You need to make this part of your code its own page 0 subroutine and put just the data in the upper bank. You then call this subroutine from your mainline code. I hope the spacing turns out to be readable. ; ; do a table lookup based on 'overflow' and 'fine' values ; ; Note: changes PCLATH - must do a pagesel after calling ; ; GetTable: movlw high(Table1) ; get upper portion of Table1 base address movwf PCLATH movf overflow, w ; get which 256-byte portion of Table1 addwf PCLATH, f ; now pointing to right portion of table movf fine, w ; get offset into 256 byte page movwf PCL ; branch directly into table ; ; NOTE: no return needed, executing the retlw in Table1 returns ; to wherever GetTable was called from ; From your mainline code, this would be used as: ; ; set up your overflow and fine variables ; call GetTable ; convert to table value pagesel $+1 ; restore PCLATH to current page ; ; use the returned value in W as needed ; >;;;;;;;;;;;Table::::::::::::::::::::::: > org 800h ;page1 > >Table1 > movf pcl,f ;using this seems to rollover at every >256th value ^^^^^ Remove the above line to start your data at location 0800h > retlw .1 > retlw .5 > retlw .2 > retlw .12 > retlw .6 Hope this helps. Regards, Bob -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads