+ Post New Thread
Results 1 to 4 of 4
  1. #1
    Full Member level 4
    Points: 3,480, Level: 13

    Join Date
    Nov 2003
    Location
    Lahore Pakistan
    Posts
    210
    Helped
    3 / 3
    Points
    3,480
    Level
    13

    data pointing in ROM in pic16f887 problem.

    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?

    •   Alt1st March 2016, 07:05

      advertising

        
       

  2. #2
    Super Moderator
    Points: 68,518, Level: 63
    Achievements:
    7 years registered
    Awards:
    2nd Helpful Member
    betwixt's Avatar
    Join Date
    Jul 2009
    Location
    Aberdyfi, West Wales, UK
    Posts
    11,197
    Helped
    3702 / 3702
    Points
    68,518
    Level
    63

    Re: data pointing in ROM in pic16f887 problem.

    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.
    PLEASE - no friends requests or private emails, I simply don't have time to reply to them all.
    It's better to share your questions and answers on Edaboard so we can all benefit from each others experiences.



    •   Alt1st March 2016, 09:21

      advertising

        
       

  3. #3
    Full Member level 4
    Points: 3,480, Level: 13

    Join Date
    Nov 2003
    Location
    Lahore Pakistan
    Posts
    210
    Helped
    3 / 3
    Points
    3,480
    Level
    13

    Re: data pointing in ROM in pic16f887 problem.

    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



    •   Alt1st March 2016, 13:32

      advertising

        
       

  4. #4
    Super Moderator
    Points: 68,518, Level: 63
    Achievements:
    7 years registered
    Awards:
    2nd Helpful Member
    betwixt's Avatar
    Join Date
    Jul 2009
    Location
    Aberdyfi, West Wales, UK
    Posts
    11,197
    Helped
    3702 / 3702
    Points
    68,518
    Level
    63

    Re: data pointing in ROM in pic16f887 problem.

    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.
    PLEASE - no friends requests or private emails, I simply don't have time to reply to them all.
    It's better to share your questions and answers on Edaboard so we can all benefit from each others experiences.



--[[ ]]--