Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
LinkBack Thread Tools Display Modes
Old 10th July 2007, 03:36 AM   (permalink)
Arrow Calling a TABLE by using Indirect Addressing

Hi I want to call a TABLE by using indirect addressing. Now I’m doing like this.

Code:
  
	movlw 	01h
	movwf	11h	;GP register
	movlw	02h
	movwf	12h	;GP register
So if there is more registers I want to write more.

I can clear the GP registers using indirect addressing like below.

Code:
	
	movlw	11h
	movwf	FSR
	clrf	INDF
	incf	FSR,f
	btfss	FSR,7
	goto	$-3
	goto	NEXT
But how I call a TABLE to move all literal values to appropriate registers? (My literal values are in the table)

Thanks a lot

Last edited by Suraj143; 10th July 2007 at 03:40 AM.
Suraj143 is offline  
Old 10th July 2007, 04:10 AM   (permalink)
Default

Code:
	movlw	11h
	movwf	FSR
NEXT	call        table
	movwf    INDF
	incf	FSR,f
	btfss	FSR,7
	goto	NEXT
__________________
Superman returns..
bananasiong is offline  
Old 10th July 2007, 04:26 AM   (permalink)
Default

Hi thanks for your reply doesn’t it need a jump value for TABLE?

Another problem if my last GP register is 15h how to detect that.

It means the tables last value must move to this last GP register.
I have only 5 GP registers they are 11h,12h,13h,14h,15h
So after moving last literal value to 15h it must do other work.

How to detect the last 15h register?

Thanks a lot
Suraj143 is offline  
Old 10th July 2007, 05:24 AM   (permalink)
Default

Are you trying to read a table from program memory into RAM?
Code:
 
table addwf PC,f retlw [data] ;is the normal way to read a table on a 14bit PIC core.
you call it with

Code:
    call table ;(where W is the pointer to the table)
__________________
Bill
Smart Kits build Smart People

http://www.blueroomelectronics.com

Last edited by blueroomelectronics; 11th July 2007 at 06:32 AM.
blueroomelectronics is online now  
Old 10th July 2007, 05:37 AM   (permalink)
Default

Ok thanks but how I detect the last value has reached that is 15h?

After moving the last literal value in the table to 15h I want to do other work.

So how can I detect the 15h GP register?
Suraj143 is offline  
Old 10th July 2007, 06:24 AM   (permalink)
Default

increment the pointer value at the end of the loop and do a
btfsc pointer,4
goto exit
__________________
Bill
Smart Kits build Smart People

http://www.blueroomelectronics.com
blueroomelectronics is online now  
Old 10th July 2007, 06:33 AM   (permalink)
Default

Is this Correct

Code:
	movlw	11h
	movwf	FSR
LOOP	call    table
	movwf   INDF
	incf	FSR,f
	btfss	FSR,4
	goto	LOOP
	goto	EXIT
Suraj143 is offline  
Old 10th July 2007, 06:34 AM   (permalink)
Default

Ya, replace
Code:
	btfss	FSR,7
	goto	NEXT
with
Code:
	btfss	FSR,4
	goto	NEXT
	;do other thing here
__________________
Superman returns..
bananasiong is offline  
Old 10th July 2007, 06:35 AM   (permalink)
Default

You posted it first. That's right.
__________________
Superman returns..
bananasiong is offline  
Old 10th July 2007, 06:41 AM   (permalink)
Default

If there is below 8 GP registers its ok. If there is 10 registers how can I detect the last GP register?

Btfss FSR,???
Suraj143 is offline  
Old 10th July 2007, 07:46 AM   (permalink)
Default

No, not only 8 general purpose register. Up to 256 general purpose register maximum.
For example, after incf FSR, f
Code:
movf     FSR, w
xorlw     0x1b       ;if you start with 11h and you have 10 GP register,
                         ;the last one will be 1ah
btfss     STATUS, Z
goto      NEXT
goto      exit
__________________
Superman returns..
bananasiong is offline  
Old 10th July 2007, 07:52 AM   (permalink)
Default

Wow that’s great man that’s the one I need. So I can put your code into my program.

Thanks a lot

You are excellent
Suraj143 is offline  
Old 10th July 2007, 08:07 AM   (permalink)
Default

So here is the final coding moved table values to GP registers from 11h to 15h.

Code:
	movlw	11h
	movwf	FSR
LOOP	call    table
	movwf   INDF
	incf	FSR,f
	movf    FSR, w
	xorlw   16h     ;test if it is 16h GP register?
	btfss   STATUS, Z
	goto    LOOP
	goto    exit
Suraj143 is offline  
Reply

Bookmarks

Thread Tools
Display Modes



Similar Threads
Title Starter Forum Replies Latest
Calling Tables for PIC877A jinchang Micro Controllers 15 10th June 2007 03:08 PM
Indirect addressing issue with 16f84a MWostal Micro Controllers 9 31st December 2006 01:41 PM
PIC: Table lookup across page boundary eblc1388 Micro Controllers 11 16th August 2005 03:43 PM
18F Lookup Table Cose Snippet [ASM] pittuck Micro Controllers 0 14th December 2004 08:40 AM
Lookup table for LCD and 7 segment display patricktran Micro Controllers 3 23rd April 2004 02:43 PM



All times are GMT. The time now is 10:35 PM.


Electronic Circuits  |  Learning Electronics
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

eXTReMe Tracker