Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

How to Create a Table?

Status
Not open for further replies.

Suraj143

Active Member
This is pretty hard but need to find a way to do.

I have 100 eeprom saved data.I need to create a table from this values.

I can read the eeprom values & load into GP registers.But my main program working with these registers.So I cannot use these registers.

So I need a way to create a table using these EEPROM values.
 
This is pretty hard but need to find a way to do.

I have 100 eeprom saved data.I need to create a table from this values.

I can read the eeprom values & load into GP registers.But my main program working with these registers.So I cannot use these registers.

So I need a way to create a table using these EEPROM values.

Check the datasheets and application notes, it's a VERY common requirement - or check my tutorials, many of which use tables themselves.

The required command for the table is RETLW, with a calculated jump using PCL. 100 entries is easy, but you must ensure it doesn't cross a 256 word boundary, or you have to take special precautions (again, my tutorials, LED matrix, gives examples of large tables).
 
Hi Nigel thanks for the info.You didn't get my problem.

I need to create a table using my EEPROM saved values.

From these saved data I need to create a table.
 
Hi Nigel thanks for the info.You didn't get my problem.

I need to create a table using my EEPROM saved values.

From these saved data I need to create a table.

Hi Suraj,
Whats the PIc type.?
If the values exist in EEPROM, why do you need to create a Table in the registers.
 
You are 100% correct.The values are stored in EEPROM.I' using PIC16f628A.

hi,
Whats the purpose of the Table, why cant you use the values in the EEP.?

Why do you have to Tabulate them.
 
You need to explain what you are trying to do. Your EEPROM data is already a table, moving it to SFRs or Rom will make no difference. What do you want to do with the values in EEPROM?

Mike.
 
Hi in my main menu theres such a thing like this.

Code:
Shift	movf	data1,W
	movwf	data2
	movf	data2,W
	movwf	data3
	---
	---

The data registers contains saved data.If I recall EEPROM values & save in this data registers due to shift in the main program the data will get lost.

So again I have to read the EEPROM 100 saved places.

That is why I need to create a table.
 
Why can't you move the values from the EEPROM into the data variables?

Mike.
 
hi Mike,
I will just observe, dont want to confuse Suraj with multiple replies.:)
 
You mean to move them into other banks GP registers?

Yes, although there isn't 100 consecutive location in a 628, you could use locations 0x5c-0x6f (20 bytes) in bank 0 and the 80 bytes in bank 1.

Do you understand how the FSR register works?

With the FSR register you can move the EEPROM values into the SFRs by doing,
Code:
data1		equ	0x5c
data21		equ	0xa0

MoveData
		movlw	data1		;point indirect register
		movwf	FSR		; at data 1
		bcf	STATUS,IRP	;ensure we write to bank 0 and 1
		bsf	STATUS,RP0	;bank 1
		clrf	EEADR		;start at location zero
MoveLoop	bsf	STATUS,RP0	;Bank 1
		bsf	EECON1,RD	;EE Read
		movf	EEDATA,W	;W = EEDATA
		incf	EEADR,F		;point to next location
		bcf	STATUS,RP0	;Bank 0
		movwf	INDF		;write to SFRs
		incf	FSR,F		;move to next location
		movfw	FSR
		xorlw	data1+d'20'	;end of bank 0 data?
		btfss	STATUS,Z	
		goto	NextCheck
		movlw	data21		;yes, so point FSR at next bank
		movwf	FSR
NextCheck	movfw	FSR		
		xorlw	data21+d'80'	;end of all data
		btfss	STATUS,Z
		goto	MoveLoop	;no carry on
		return			;done.

You can use a similar method to access the same area later. I assume you are doing some sort of scrolling display.

The above is untested code and may not work. I state this as I will not be able to correct it if it turns out to be flawed due to the 15 minute edit time.

Mike.
 
Hi Mike Excellent code.That is what I was expecting.

I was looking a method how to place saved data in a one place.The above code of you allow to do that.So no need to create a table.

Thanks for the support.
 
Suraj,

You should study how the code works and particularly how the FSR and INDF registers work. They will probably be useful in your other code.

Mike.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top