Searching \ for '16C57 PC crazy?' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: techref.massmind.org/techref/microchip/devices.htm?key=16C
Search entire site for: '16C57 PC crazy?'.

Truncated match.
PICList Thread
'16C57 PC crazy?'
1999\03\04@142422 by PJH

flavicon
face
Hi,

I've got this programme written for
ye olde PIC16C57 and decided to
update its format so as to
programme it using PICSTART+. Fine,
compiled OK, simulated OK, no
probs. Then I thought, "Why not put
in a jump table to minimize the
code a bit?"

Now the PC goes crazy when I feed
it small jumps like 00h, 07h, 0ah
etc. Finishes up back near the
start address, in 1st half of page
0.

When I come to the start table,
W=0, PCL=0D18 for movf readata,w.
Then PCL=0E1C for  addwf PCL and we
finish up back at 0F18. See below.
(PCL is defined as 02h in the
include file.)


So, what's going on? I'm doing
small jumps within the page, so the
PC should just increment to the
proper part of the table? (As long
as the jumps are in the proper
range, of course, which they are
in this case.)

I've always avoided jump tables as
bad news but now I've got MPLAB &
Myke Predko's  great book, I
figured I'd have to give it a try.

Hey, I bet I'm missing something
REALLY obvious here. Any advice
much appreciated.


Regards - PJH.


PS: The order of the jump table
looks a little odd because of the
way the PCB is wired. Have to do
swapf's on upper & lower nibbles
etc and it's easier to have the
table this way rather than fool
around even more with the i/p byte.

********************************************************************************
***

Here is the relevant code :-

list    p=16c57,F=inhx8m,R=hex
      errorlevel 0,-305
       include "A:\p16c5x.inc"
__CONFIG _CP_OFF & _WDT_OFF &
_XT_OSC

;******************************************************************

;VECTOR ASSIGNMENTS
;******************************************************************

_16C57 equ 0x07FF

.... SNIP OTHER REGISTER
ASSIGNMENTS ETC ....

;***************************************************************

;PAGE #0
;PROCEDURES are all in the lower
half of page 0. Main programme
;is in the top half, starting at
0x0100, of page 0.
;***************************************************************

       org      0x00
start   nop
       bsf      FSR,4     ;Can
only select another page if b4=1
       bsf      FSR,5
       bsf      FSR,6
       bsf      STATUS,4
       bsf      STATUS,5
       bsf      STATUS,6
       goto     reset


;****************************************************************

;The MAIN programme is in the upper
half of the page
;****************************************************************

          org      0x100
main    call     init
;Initialise the ports.
          IFNDEF DEBUG
            call     wait_1
;Pause to settle.
          ENDIF

.... SNIP PREPARATORY STEPS ....

chkmode  movlw    i_addr3
;Check the battery first

        .... SNIP INTERMEDIATE
STEPS ....
        ..... OK, HERE'S WHERE THE
PROBLEM IS ...

         call     Get_Data
;Comes back with 00, 07, 0A etc in
"readata"
table   movf     readata,w
;SET W=0  PCL=0D18 TO TEST
         addwf    PCL
;         PCL=0E1C

;NEXT STEP, PCL=0E1C, somewhere in
ist half of page 0.
       goto     shutdown
;No input so switch off

nop
;unassigned jumps
       nop
       goto     chkmode
;Catches out of range inputs
       goto
hunt                   ;Look for
targets
       goto
user                   ;Power up
for manual control
       goto
standbye            ;Power on &
standbye
       goto     chkmode
;just keep cycling.

.....SNIP REST OF PROGRAMME ....

;****************************************************************

;PAGE #3
;****************************************************************

           org      0x0700
bootup  bsf      FSR,4         ;Can
only select another page if b4=1
            bcf      FSR,5
            bcf      FSR,6
            bsf      STATUS,4
            bcf      STATUS,5
;Clear bits 5, 6 and go to
            bcf      STATUS,6
;page_0.
            goto     main
;The main programme.

         org      _16C57
;Address= 0x07FF
reset   goto     bootup
         end

1999\03\04@205821 by Mike Keitz

picon face
On Fri, 5 Mar 1999 06:19:51 +1100 PJH <spam_OUTelekTakeThisOuTspamNETSTRA.COM.AU> writes:

>Now the PC goes crazy when I feed
>it small jumps like 00h, 07h, 0ah
>etc. Finishes up back near the
>start address, in 1st half of page
>0.

That's how the '57 and all 12 bit
PIC's work.  You must put the table
in the first half (256 bytes) of a
page.

Also the page select bits (in the
status register) must be set to match
the page where the table is.


___________________________________________________________________
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com/getjuno.html
or call Juno at (800) 654-JUNO [654-5866]


'16C57 PC crazy?'
1999\04\02@111635 by Larry G. Nelson Sr.
flavicon
face
You need to put the jump table in the first 255 locations on the page. The
W register which you are using to do the math is 8 bits and the PC is 12
with the upper bits being lost in the bit bucket. This is the limitation
with anything doing math on the PC.



At 06:19 AM 3/5/99 +1100, you wrote:
{Quote hidden}

SNIP
Larry G. Nelson Sr.
.....L.NelsonKILLspamspam@spam@ieee.org
http://www.ultranet.com/~nr

1999\04\02@160417 by PJH

flavicon
face
Larry G. Nelson Sr. wrote:

> You need to put the jump table in the first 255 locations on the page. The
> W register which you are using to do the math is 8 bits and the PC is 12
> with the upper bits being lost in the bit bucket. This is the limitation
> with anything doing math on the PC.
>

Thanks - figured that out. It'd been a while since I programmed one of these
things. Putting the subroutines & jump tables in the lower half page is a real
pain in the ****.

PJH

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