Searching \ for '[PIC]: Include files' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/devices.htm?key=pic
Search entire site for: 'Include files'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: Include files'
2002\04\19@112101 by Joris van den Heuvel

flavicon
face
part 1 6456 bytes content-type:multipart/alternative; (decoded quoted-printable)


------ 2002\04\19@122545 by Olin Lathrop
face picon face
> - STATUS,Z becomes Z
> - STATUS,RP0 becomes RP0
> - INTCON,GIE becomes GIE
> - PIR1,CCP1IF becomes CCP1IF

I don't like this because you are redefining standard Microchip names.  This
can really confuse other people looking at your code.  They think they know
what these symbols mean, but they in fact mean something else.  It also
forces you to create your own include files since Microchip has already
defined these symbols in theirs.  I don't mind adding my own definitions in
my own include file to the standard Microchip definitions, but I definitely
want to include their files without modification.

If you are going to do this, I strongly recommend you pick different names
for your bits.  I tend to use xxx_BIT for string substitution macros that
include the register and bit number.  For example Z_BIT could be STATUS,Z.

By the way, if you want to do something similar with flag bits that are
global to a project, check out the /FLAG directive in my MPASM preprocessor
at http://www.embedinc.com/pic.  You put one "/FLAG <name>" directive in the
main project include file for each global bit.  These are allocated from
whole bytes as needed.  Among other things, a string substitution macro
FLAG_<name> is defined that expands to the register and bit within the
register where the flag ended up.


*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2002\04\19@124640 by Thomas McGahee

flavicon
face
To avoid confusion with predefined symbols like Z, I define
my own symbols to have a leading underscore. Thus
   btfss _z        is the same as
   btfss status,z

Fr. Thomas McGahee
 {Original Message removed}

2002\04\19@130353 by Drew Vassallo

picon face
>- STATUS,Z becomes Z
>- STATUS,RP0 becomes RP0
>- INTCON,GIE becomes GIE
>- PIR1,CCP1IF becomes CCP1IF

I agree with Olin here.  Redefining "standard" bit references to something
so similar is just asking for trouble.  Not only do others have a hard time
reading your code, but you may have trouble reading it yourself in another 5
years when you forgot what you did.

I would also recommend using different labels for these, such as "GIE_BIT"
or something similar.

>Furthermore, there's a macro template I always use. Most of the times I end
>up putting extra macros in there, but these are a good start. Included are:
>- incfw    file                ; increment file and load into W
>- decfw    file                ; decrement file and load into W
>- inccprs  file,literal        ; increment file, compare file and literal,
>clear file if equal
>- compare  file,literal,target ; compare file and literal, call target if
>equal

In my opinion, I think it was smart of Microchip not to extend their basic
instruction set beyond the 35 or so instructions that exist now.  (As
opposed to the 80-something for Motorola or Atmel chips).  This allows a
tremendous variety and flexibility in programming.  Since nearly every
program is much different than any other, it's wise to allow the most
flexibility possible.  By adding more instructions through macroed
mnemonics, I'm not all that sure you're saving much by way of readability or
ease of programming.

For example, in two programs that I've worked on this year, each of which
have over 4k worth of instructions, I don't think I would have used the
"compare" or "inccprs" macros that you described above even one time.

That's not to say others will never use them, but having such specialized
functions just don't seem to me to be worth remembering.  Now, Olin likes to
promote his "standard set" of macros, but they are a little different.  Many
of them are time-savers that deal with bank or page switching, long calls,
etc. that incorporate all the instructions necessary to perform one common
operation.  Also, many of them apply to multiple chip series and the same
macro can be used regardless of chip type (16Cxx, 17Cxx, 18Cxx, etc.).

Again, this is all just my opinion.

--Andrew

_________________________________________________________________
Join the world s largest e-mail service with MSN Hotmail.
http://www.hotmail.com

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2002\04\19@162021 by Barry Gershenfeld

picon face
Good discussion, but I didn't see this example:
If you write

  btfss STATUS,Z

Then when it won't compile, and if you're astute enough to
check the listing file, you will discover that your macro
translator has given you:

  btfss STATUS,STATUS,Z

That's when you say, "Oh, yeah, now I get it"

(And you say, "Well, I'd never write that".  True, but then
you copy in someone's code fragment, and...)

Barry

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2002\04\19@163006 by Olin Lathrop

face picon face
> Good discussion, but I didn't see this example:
> If you write
>
>    btfss STATUS,Z
>
> Then when it won't compile, and if you're astute enough to
> check the listing file, you will discover that your macro
> translator has given you:
>
>    btfss STATUS,STATUS,Z
>
> That's when you say, "Oh, yeah, now I get it"
>
> (And you say, "Well, I'd never write that".  True, but then
> you copy in someone's code fragment, and...)

There is also an argument for having the symbols for just the bit numbers
available.  In rare cases the bit number symbols could be used with a shadow
copy or otherwise precomputed copy of a special function register.  This is
unusual, but I'm pretty sure I've done it somewhere.


*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2002\04\21@080829 by Howard Simpson

flavicon
face
> Joris van den Heuvel wrote:
>
> Hey all,
>
> Sometimes I see code posted here and notice how everyone always
> addresses bits by both their register name and their bit names. I'd
> hate to have to remember (at all times) in which register a specific
> bit is, so ever since I started out with PICs I always reworked the
> INC file of the processor type I was working with. For every bit name
> I made a #define statement, so the bit name includes the register name
> etc.

If I may comment here, I myself leave the Microchip include files alone,
for the reasons others have given.
However, that doesn't mean one can't have one's own include files
attached to the current project, as well as the Microchip one.
On a similar note, I am experimenting with breaking up a large program
into three of four or more include files, usually a couple of
sub-routines, and #including them in the main program.

e.g. (not strictly compiler gramatically correct)

;program.asm
#include Microchip files
org     000
goto load_incs  ;(no room to load includes here, hence the jump)
org     004
;==============
load_incs       ;(load the following includes here
               ;I understand they actually load here)
#include        sub_one.inc
#include        sub_two.inc
goto    setup   ;Just to keep setup down the bottom where
               ;it's out of the way
;==============
start
;Main program here,
;e.g
call    one or more subroutines in sub_one
call    one or more subroutines in sub_two
;etc
;==============
setup
#define various in/put port names if required
;setup ports, variable declarations and timers and so on
goto    start
;******************************

My grief was scrolling up and down a couple of thousand lines looking
for a label.  I could use edit-find, but sometimes (well... nearly
always!) forget the exact label name.
However, the include files idea work not too bad, but you have to keep
opening a window of the particular include file, to change the code
there.
I think it might work better if only definitely finished code is saved
in an include file, and hopefully rarely having to go into it.
The other more dramatic problem is naming these things, and avoiding
mixing them up with a heap of other files.  I'm afraid I'm an old DOS
man, and I use directories (sorry - folders) A LOT!  I cannot come to
grips with the idea of everything being in "My Documents"  So, by having
one folder for one project or program it'll work.
Has anyone got any critisisms or comments, I'd be happy to read them.
Regards to all
Howard

--
http://www.piclist.com hint: To leave the PICList
spam_OUTpiclist-unsubscribe-requestTakeThisOuTspammitvma.mit.edu


2002\04\21@095621 by Olin Lathrop

face picon face
{Quote hidden}

Sounds like you are finally ready to see the light and use the linker.  I
always preach to start out using the linker from the beginning, but alas,
they hear me not.  Once you are Saved, perhaps you can help others to stay
on the Right Path and not succumb to the false temptations of the evil
absolute mode.

Now go forth and modularize, but of course thou must first seek the Good
Book (DS33014G) and RTFM.


*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com

--
http://www.piclist.com hint: To leave the PICList
.....piclist-unsubscribe-requestKILLspamspam@spam@mitvma.mit.edu


2002\04\21@140849 by Kevin Olalde

flavicon
face
33014F was the latest I could find.
www.microchip.com/download/tools/uguides/33014f.pdf
Though Microchip's site does win in most of our battles....

The next time you find yourself there could you copy a link?

Thanks,
Kevin

Olin Lathrop wrote:
> Now go forth and modularize, but of course thou must first seek the Good
> Book (DS33014G) and RTFM.

--
http://www.piclist.com hint: To leave the PICList
piclist-unsubscribe-requestspamKILLspammitvma.mit.edu


2002\04\21@141310 by Kevin Olalde

flavicon
face
And then as I was saving the 'F' version, I found I had already downloaded the
'G' version.

Thanks anyway,
Kevin

I wrote:
{Quote hidden}

--
http://www.piclist.com hint: To leave the PICList
.....piclist-unsubscribe-requestKILLspamspam.....mitvma.mit.edu


2002\04\22@055434 by Howard Simpson

flavicon
face
Olin Lathrop wrote:
>
>
> Sounds like you are finally ready to see the light and use the linker.  I
> always preach to start out using the linker from the beginning, but alas,
> they hear me not.  Once you are Saved, perhaps you can help others to stay
> on the Right Path and not succumb to the false temptations of the evil
> absolute mode.
>
> Now go forth and modularize, but of course thou must first seek the Good
> Book (DS33014G) and RTFM.
>

Ah!  The Great One has spoken!
Alas, this humble servant took one look at the linker some time back,
and quite swooned away with chronic bogglement of the mind.
However, one must perservere, and one shall obey, download the
aformentioned missive, attempt to cleanse oneself of doubt and
bewilderment, banish the sad affliction of selective deafness, and go
forth.
My kindest regards,
Howard.

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2002\04\22@080700 by Olin Lathrop

face picon face
> Alas, this humble servant took one look at the linker some time back,
> and quite swooned away with chronic bogglement of the mind.
> However, one must perservere, and one shall obey, download the
> aformentioned missive, attempt to cleanse oneself of doubt and
> bewilderment, banish the sad affliction of selective deafness, and go
> forth.

It's really not that bad.  When I first started with PICs, I read thru the
manuals and decided to use the linker right from the start.  It works pretty
much like you would expect a linker to work, and I don't remember any
problems except that linker control file keywords need to be upper case even
though the manual didn't mention that.

Take a look at http://www.embedinc.com/pic/.  It shows a bunch of standard
modules that most PIC projects will need.  You can also check out the HAL
project as an example of using the linker.  My PIC development tools,
template files, linker control files, and the complete HAL project are
available for download.


*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


More... (looser matching)
- Last day of these posts
- In 2002 , 2003 only
- Today
- New search...