Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

data pointing in ROM in pic16f887 problem.

Status
Not open for further replies.

Noman Yousaf

Full Member level 4
Joined
Nov 19, 2003
Messages
208
Helped
3
Reputation
6
Reaction score
2
Trophy points
1,298
Location
Lahore Pakistan
Activity points
1,763
hi all,

i work in assembly language with pic16f887

i want to use ROM as readable memory.
like i have used with DPTR in 8051.

what are DB and DT in PIC16?

how can i use ROM with DB or DT direactive for making long lookup table?
 

DB = "Define Byte"
DW = "Define Word"
DT = "Define Table"
DE = "Define EEPROM"

They are all instructions to allow you to directly store data in memory. See the document "MPASM_MPLINK_User_Guide.pdf" for more information, it should be in your compiler folder. The example it gives is:
Code:
#include p16f877a.inc     ;Include standard header file for the selected device.

org 0x2100     ;The absolue address 2100h is mapped to the 0000 location of EE data memory.
;You can create a data or character table starting from any address in EE data memory.

ch_tbl2 de "PICmicro"    ;8 EE data memory locations (starting from 0) will be filled with 8 ASCII characters.
end
but check the address 0x2100 because it is different from one processor to another. It isn't a real address, the programmer sees it as a special location and puts it in EEPROM instead of normal program memory. The example is for the 16F877A.

Brian.
 

I just want to use ROM as constant data as it is done in 8051 with DPTR.

i will define word or data and i will read it.

the question is, how i can read that data or word?

as i define like this


org 100h

db "hello"

it is written in memory but please tell the routine in which i will read it and may be display it. I just want this data in W reg one by one.

I can do it with

addwf pcl,f

retlw 'h'

retlw 'h'

retlw 'e'

retlw 'l'

retlw 'l'

retlw 'o'
retlw 'w'

retlw 0x00

but it is lengthy and time consuming
 

The easiest method is to write it as:

DT "hello"

Then access it using the "addwf pcl,f" method but you do not have to put all the individual retlw instructions in place. Like this:
Code:
addwf pcl,f
DT "hellow",0

You can also access it using the FSR register as a pointer to the table. I'm rusty at 8051 code but I think FSR is similar to DPTR in PIC language.

PIC18 devices and some enhanced PIC16 devices have dedicated table writing and reading instructions but they are not present in the 16F887A

Brian.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top