1. poriet

    Thread Starter New Member

    Feb 26, 2010
    22
    2
    Hi,
    I would appreciate some guidance on the use, in baseline PIC architecture, of the pagesel Directive:

    There is a tutorial on the Gooligum site using a 16F505 with a 7-seg display. The lookup tables have to be in the first 256 instructions of a Page ( because of the PCL bit<8> reset ). The 16F505 has 2 pages of Flash and so Mr. Gooligum is able to place the lookup tables at the start of a page by selecting the second page with the pagesel Directive. However, I'm using a 16F54 which has only one page. If I locate the lookup tables at the top of the page, using the CODE directive, the 'start' of the program will be somewhere in the middle of the page. Is this likely to be a recognised problem?

    Bruce
     
  2. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    These are abit different to the PICs I normally use. From the datasheet you can only put lookup tables in the first 256 bytes of program. The reset vector is at 1FFh so if you put:
    Code ( (Unknown Language)):
    1. org 1FFh
    2. goto start
    3. org 000h
    4. ...table
    5. .
    6. .
    7. .
    8. start
    I think that might work.
    I got a bit confused about what happens if you call the lookup table from the second 256 bytes of program.
     
  3. retched

    AAC Fanatic!

    Dec 5, 2009
    5,201
    312
    Is the command even available on pics that only have 1 page?
     
  4. poriet

    Thread Starter New Member

    Feb 26, 2010
    22
    2
    Hello Mark
    Thanks, but what is 'org'? not come across that one in my travels.

    I think you might be right about Pagesel not being useable if theres only one page.

    I have the F57 as well; perhaps I should try that as it has IIRC more than one page.

    If you dont know, nobody does!
     
  5. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    From looking at the help file ORG seems to do much the same job as CODE in that it specifies where in program memory the next sequence of instructions is located.
     
  6. atferrari

    AAC Fanatic!

    Jan 6, 2004
    2,650
    765
    I have never used that micro. It seems that going to "Start" you force the micro to run the "code" there (which in fact is a "table"). Not good.

    You should locate your "Start" at some other address in memory using the appropiate "ORG" value; to say something, immediately after the table.
     
    Last edited: Apr 21, 2010
  7. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    in the folder ...Microchip\MPASM Suite\Template\Code you will find a template different MCUs. Can save you some work ;) This is the template for your chip.
    Code ( (Unknown Language)):
    1.  
    2. ;**********************************************************************
    3. ;   This file is a basic code template for assembly code generation   *
    4. ;   on the PIC16F54. This file contains the basic code                *
    5. ;   building blocks to build upon.                                    *
    6. ;                                                                     *
    7. ;   Refer to the MPASM User's Guide for additional information on     *
    8. ;   features of the assembler (Document DS33014).                     *
    9. ;                                                                     *
    10. ;   Refer to the respective PIC data sheet for additional             *
    11. ;   information on the instruction set.                               *
    12. ;                                                                     *
    13. ;**********************************************************************
    14. ;                                                                     *
    15. ;    Filename:     xxx.asm                                           *
    16. ;    Date:                                                            *
    17. ;    File Version:                                                    *
    18. ;                                                                     *
    19. ;    Author:                                                          *
    20. ;    Company:                                                         *
    21. ;                                                                     *
    22. ;                                                                     *
    23. ;**********************************************************************
    24. ;                                                                     *
    25. ;    Files Required: P16F54.INC                                       *
    26. ;                                                                     *
    27. ;**********************************************************************
    28. ;                                                                     *
    29. ;    Notes:                                                           *
    30. ;                                                                     *
    31. ;**********************************************************************
    32.  list      p=16F54             ; list directive to define processor
    33.  #include <p16f5x.inc>         ; processor specific variable definitions
    34.  __CONFIG   _CP_OFF & _WDT_OFF & _RC_OSC
    35. ; '__CONFIG' directive is used to embed configuration word within .asm file.
    36. ; The lables following the directive are located in the respective .inc file.
    37. ; See respective data sheet for additional information on configuration word.
    38.  
    39.  
    40. ;***** VARIABLE DEFINITIONS
    41. temp          EQU     0x07        ;example variable definition
    42.  
    43.  
    44.  
    45.  
    46. ;**********************************************************************
    47.   ORG     0x1FF             ; processor reset vector
    48.   goto    start
    49.   ORG     0x000
    50.  
    51. start
    52.  
    53. ; remaining code goes here
    54.  
    55.  
    56.  
    57.   END                       ; directive 'end of program'
    58.  
    59.  
     
  8. poriet

    Thread Starter New Member

    Feb 26, 2010
    22
    2
    Hello guys,
    I thought this thread was dead, but I see it is not.
    ( You just cant keep a good man down. And I'm not even a good man )
    Mark, if you locate the lookup beyond the first 256 instructions, it crashes ( or blows up, I cant remember ). The RETLW instruction resets whatever does the 9th digit, so the next instruction must be within the first 256. Not a problem if you have 2 pages, but I dont. I'll try the ORG directive. I looked at your code and it looks OK to me. The best bit is, if it fails, I have somebody else to blame, which, in programming, is the most important consideration.
    Augustin ( Hi, you do get around! ) I'm bruce on the EPE CZ. I think you and Mark are on the right track.
    Hello t06afre, yes, I have the header, but I'm not clear how it helps.
    I learned about this shortcoming of baseline PICs from the 'Gooligum' tutorials. They are very good, but he doesnt seem to answer emails.

    Bruce
     
    Mrdouble likes this.
  9. atferrari

    AAC Fanatic!

    Jan 6, 2004
    2,650
    765
    Will keep the "blame" trick in mind for future use...:D