View Single Post
  #34   Report Post  
Posted to alt.binaries.schematics.electronic
ian field ian field is offline
external usenet poster
 
Posts: 396
Default MPLAB programmer interface.


"john jardine" wrote in message
...

"ian field" wrote in message
...
[...]
One thing I don't get, in a programming example they show multiple
iterations of the ORG instruction, that doesn't match the explanation of

ORG
I got elsewhere.


Well at this early stage 2nd instalment, they damned well shouldn't be.
The "ORG (origin) xxxx" fixes the location where your following
instructions
are poked into the PIC memory. You can use it hundreds of times if you
wish,
though god knows why anyone would want to.
The ones liable to turn up are listed below and are shown in that stupid
f****** hexadecimal the priesthood insist on using. (from recall of 16F
series PICs I use)
#ORG 0#
Progs start at "ORG 0", i.e. the first memory location the PIC will read
after power up.
#ORG 4#
If you're thinking of using 'interrupts' then you'll need an "ORG 4".
This
is the fixed memory location that the PIC is forced to jump back to when a
(previously set-up) 'interrupt' happens. If no ints are set-up then the
prog
starts at 0 and just runs upwards.
If EPE have used an 'ORG 4' then the previous instruction (location
3 )will
be a 'jump over the complete interrupt routine'. eg ...
ORG 0
...
GOTO Fred ;the jump over
----------------------------------
ORG 4 ;forced start of EPE's int routine
...
RETFIE ;end of EPE's int routine
----------------------------------
Fred: ;jumps to here and is usually the real program 'Start'
...

#ORG 2007#
DW 0x0D41 ;Where the 'config' bit settings hang out.(crystal type etc)
;(example number is from a 16F873A I did last week)

#ORG 2100# ;(where you can 'prefill' the the EEPROM memory with cal'
data
etc
DW 1
DW 2
DW 3
...

On much bigger progs an 'ORG xxxx' can be used to load a complete routine
into a higher bank of memory and saves a lot of buggering about with
continual 'bank switching'.
If at all possible though, try and avoid using the higher memory banks.
This
essentially limits the useable PIC memory to 1/4 or 1/2 of that advertised
(and paid for!) but can save a LOT of grief and tears.
There again though, if you get to that stage then you'll have already got
the T shirt


Thanks - why the hell couldn't any of the tutorials have told me that?!

Most of it probably isn't needed until the student reaches a more advanced
level, but when the tutorial introduces necessary instructions without any
explanations of their purpose, saying "just work around it for now" isn't
good enough, to my mind just entering code parrot fashion isn't learning.