Pagesel

Thread Starter

poriet

Joined Feb 26, 2010
22
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
 

Markd77

Joined Sep 7, 2009
2,806
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:
Rich (BB code):
org 1FFh
goto start
org 000h
...table
.
.
.
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.
 

Thread Starter

poriet

Joined Feb 26, 2010
22
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!
 

Markd77

Joined Sep 7, 2009
2,806
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.
 

atferrari

Joined Jan 6, 2004
5,011
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:

t06afre

Joined May 11, 2009
5,934
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.
Rich (BB code):
;**********************************************************************
;   This file is a basic code template for assembly code generation   *
;   on the PIC16F54. This file contains the basic code                *
;   building blocks to build upon.                                    *
;                                                                     *
;   Refer to the MPASM User's Guide for additional information on     *
;   features of the assembler (Document DS33014).                     *
;                                                                     *
;   Refer to the respective PIC data sheet for additional             *
;   information on the instruction set.                               *
;                                                                     *
;**********************************************************************
;                                                                     *
;    Filename:     xxx.asm                                           *
;    Date:                                                            *
;    File Version:                                                    *
;                                                                     *
;    Author:                                                          *
;    Company:                                                         *
;                                                                     * 
;                                                                     *
;**********************************************************************
;                                                                     *
;    Files Required: P16F54.INC                                       *
;                                                                     *
;**********************************************************************
;                                                                     *
;    Notes:                                                           *
;                                                                     *
;**********************************************************************
 list      p=16F54             ; list directive to define processor
 #include <p16f5x.inc>         ; processor specific variable definitions
 __CONFIG   _CP_OFF & _WDT_OFF & _RC_OSC
; '__CONFIG' directive is used to embed configuration word within .asm file.
; The lables following the directive are located in the respective .inc file. 
; See respective data sheet for additional information on configuration word.
 
 
;***** VARIABLE DEFINITIONS
temp          EQU     0x07        ;example variable definition
 
 
 
 
;**********************************************************************
  ORG     0x1FF             ; processor reset vector
  goto    start
  ORG     0x000
 
start 
 
; remaining code goes here
 
 
 
  END                       ; directive 'end of program'
 

Thread Starter

poriet

Joined Feb 26, 2010
22
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
 

atferrari

Joined Jan 6, 2004
5,011
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.

Bruce
Will keep the "blame" trick in mind for future use...:D
 
Top