Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > sci.electronics.design > #381281

Re: OT: Reformatted update on table call problem

From Robert Baer <robertbaer@localnet.com>
Newsgroups sci.electronics.design
Subject Re: OT: Reformatted update on table call problem
References <egISx.89569$s%4.86979@fx20.iad> <mvfs0s$ekf$1@speranza.aioe.org>
Message-ID <he_Sx.10$bT2.2@fx19.iad> (permalink)
Date 2015-10-12 19:44 -0700

Show all headers | View raw


Martin Brown wrote:
> On 12/10/2015 07:17, Robert Baer wrote:
>>
>> LIST p=P16F648A
>> #include P16F648A.inc
>> ; Was P16F628A
>> __CONFIG _CP_OFF & _WDT_OFF & _PWRTE_OFF & _HS_OSC &
>> _LVP_OFF & _MCLRE_OFF & _BOREN_OFF
>> __IDLOCS 0x0001
>>
>> ; VARIABLES
>> ptrlo EQU 0x20 ; table pointer
>> ptrhi EQU 0x21
>> COUNT1 EQU 0x22 ; delay counter
>> COUNT2 EQU 0x23
>> COUNT3 EQU 0x24
>> sSTATUS EQU 0x25
>> sW EQU 0x26
>> ;
>> ORG 0x0000
>> GOTO start
>> GOTO start
>> GOTO start
>> GOTO start
>> ORG 0x0010
>> start: ;** setup I/O
>> ; All pins have 10K in series with an LED to GND except OSC pins (and
>> GND)
>>
>> CLRF PORTB ; Set all Port B pins to logic 0
>> BSF RB3,RB5 ; Bank 1 command comes next STATUS RP0 set
>> CLRF PORTB ; sel all Port B pins as outputs
>> BCF RB3,RB5 ; Bank 0 command comes next STATUS RP0 clear
>>
>> CLRF ptrlo ; start offset pointers at zero
>> CLRF ptrhi
>>
>> CLRW
>> MOVWF PORTB ; Port B to zero
>> CALL DELAY ; "freeze" LEDs
>>
>> MOVLW 0xFF
>> MOVWF PORTB ; Port B ones
>> CALL DELAY ; "freeze" LEDs
>>
>> repeat:
>> INCF ptrlo ; next loc
>> MOVF ptrlo,W
>> CALL tab1 ;;*REMoving this, one sees 0x00 0xFF (counting)
>> ; otherwise,one sees only repeating 0x00 0xFF
>> MOVWF PORTB ; Port B from W
>> CALL DELAY ; "freeze" LEDs
>> GOTO repeat
>> ; ----------------------------------------------
>> DELAY MOVWF sW
>> ; MOVF STATUS,W
>> ; MOVWF sSTATUS
>> CLRF COUNT1
>> CLRF COUNT2
>> MOVLW d'45' ; fudge for about 4 Sec delay
>> MOVWF COUNT3
>> LUPINR DECFSZ COUNT1
>> GOTO LUPINR
>> DECFSZ COUNT2
>> GOTO LUPINR
>> DECFSZ COUNT3
>> GOTO LUPINR
>> DEXIT: ; MOVF sSTATUS,W
>> ; MOVWF STATUS
>> MOVF sW,W
>> RETURN
>> ; ---------------------------------------------- sine
>> ORG 0x0100
>> tab1:
>> ;; RETLW 0x01 ; [0] t=0.7500 r=0.0000
>> ADDWF PCL,F
>> RETLW 0x15 ; [1] t=0.7539 r=0.0240
>> RETLW 0x14 ; [2] t=0.7578 r=0.0964
>> RETLW 0x13 ; [3] t=0.7617 r=0.2173
>> RETLW 0x12 ; [4] t=0.7656 r=0.3865
>>
>> Note the CALL tab1 does not work.
>> Why?
>
> PCLATH is still zero! Single step it in the emulator!!!
>
> Try this for a concrete example of what you seem to be trying to do:
>
> http://www.piclist.com/techref/microchip/bigtable.htm
>
>
   If that is true,no wonder it acts like a system reset every time thru 
the loop!
   SO that means the CALL instruction is lame as all hell, and the 
"working" examples are useless.

   "Documentation" on the CALL shows that an eleven-bit address is used 
for the jump; the doc for the PIC shows:
(PC)+1-->TOS
k-->PC<10:0)>,
(PCLATH<4:3>)-->PC<12:11>
   So...you are right, PCLATH remains zero, as that was the page the 
program was on at the CALL.

   So the CALL allows one to jump to ANY 4K address within a 2K block as 
set by PCLATH.
   But after that, ignoring a return, one is stuck with addressing 
within a 256 location range at best.
   And if that puts one on a different page (16 of them in each aligned 
block), then tough tissue paper as they say in Southern Russia.

   Gee..i can, with seven-league boots, walk around 1/2 of the world, 
but then must mince on tippie-toes afterwords.
   Not exactly conducive to sanity.

   Thanks!
   PS: I bet that NONE of the samples in that reference actually work.

Back to sci.electronics.design | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

OT: Reformatted update on table call problem Robert Baer <robertbaer@localnet.com> - 2015-10-11 23:17 -0700
  Re: OT: Reformatted update on table call problem piglet <erichpwagner@hotmail.com> - 2015-10-12 09:17 +0100
    Re: OT: Reformatted update on table call problem Robert Baer <robertbaer@localnet.com> - 2015-10-12 19:11 -0700
      Re: OT: Reformatted update on table call problem Martin Brown <|||newspam|||@nezumi.demon.co.uk> - 2015-10-13 08:17 +0100
        Re: OT: Reformatted update on table call problem Robert Baer <robertbaer@localnet.com> - 2015-10-13 22:26 -0700
          Re: OT: Reformatted update on table call problem piglet <erichpwagner@hotmail.com> - 2015-10-14 07:50 +0100
            Re: OT: Reformatted update on table call problem Robert Baer <robertbaer@localnet.com> - 2015-10-14 16:35 -0700
              Re: OT: Reformatted update on table call problem Martin Brown <|||newspam|||@nezumi.demon.co.uk> - 2015-10-15 12:01 +0100
                Re: OT: Reformatted update on table call problem Robert Baer <robertbaer@localnet.com> - 2015-10-15 22:41 -0700
                Re: OT: Reformatted update on table call problem piglet <erichpwagner@hotmail.com> - 2015-10-16 07:09 +0100
                Re: OT: Reformatted update on table call problem Martin Brown <|||newspam|||@nezumi.demon.co.uk> - 2015-10-16 08:50 +0100
                Re: OT: Reformatted update on table call problem piglet <erichpwagner@hotmail.com> - 2015-10-16 09:31 +0100
                Re: OT: Reformatted update on table call problem Robert Baer <robertbaer@localnet.com> - 2015-10-17 21:34 -0700
                Re: OT: Reformatted update on table call problem piglet <erichpwagner@hotmail.com> - 2015-10-18 09:42 +0100
                Re: OT: Reformatted update on table call problem Martin Brown <|||newspam|||@nezumi.demon.co.uk> - 2015-10-19 09:12 +0100
                Re: OT: Reformatted update on table call problem Robert Baer <robertbaer@localnet.com> - 2015-10-19 23:04 -0700
                Re: OT: Reformatted update on table call problem Robert Baer <robertbaer@localnet.com> - 2015-10-17 21:08 -0700
                Re: OT: Reformatted update on table call problem piglet <erichpwagner@hotmail.com> - 2015-10-18 09:45 +0100
                Re: OT: Reformatted update on table call problem Robert Baer <robertbaer@localnet.com> - 2015-10-19 23:08 -0700
                Re: OT: Reformatted update on table call problem Robert Baer <robertbaer@localnet.com> - 2015-10-17 21:19 -0700
                Re: OT: Reformatted update on table call problem piglet <erichpwagner@hotmail.com> - 2015-10-18 09:50 +0100
                Re: OT: Reformatted update on table call problem Robert Baer <robertbaer@localnet.com> - 2015-10-19 23:14 -0700
                Re: OT: Reformatted update on table call problem Robert Baer <robertbaer@localnet.com> - 2015-10-17 21:03 -0700
                Re: OT: Reformatted update on table call problem piglet <erichpwagner@hotmail.com> - 2015-10-18 10:14 +0100
                Re: OT: Reformatted update on table call problem Robert Baer <robertbaer@localnet.com> - 2015-10-19 23:31 -0700
                Re: Reformatted update on table call problem "P E Schoen" <paul@pstech-inc.com> - 2015-10-20 20:30 -0400
                Re: Reformatted update on table call problem Robert Baer <robertbaer@localnet.com> - 2015-10-20 22:42 -0700
                Re: Reformatted update on table call problem "P E Schoen" <paul@pstech-inc.com> - 2015-10-21 14:06 -0400
                Re: Reformatted update on table call problem Robert Baer <robertbaer@localnet.com> - 2015-10-23 21:01 -0700
                Re: Reformatted update on table call problem "P E Schoen" <paul@pstech-inc.com> - 2015-10-24 01:08 -0400
                Re: Reformatted update on table call problem krw <krw@nowhere.com> - 2015-10-24 09:05 -0400
  Re: OT: Reformatted update on table call problem Martin Brown <|||newspam|||@nezumi.demon.co.uk> - 2015-10-12 09:46 +0100
    Re: OT: Reformatted update on table call problem piglet <erichpwagner@hotmail.com> - 2015-10-12 10:39 +0100
      Re: OT: Reformatted update on table call problem Martin Riddle <martin_ridd@verizon.net> - 2015-10-12 08:24 -0400
        Re: OT: Reformatted update on table call problem Robert Baer <robertbaer@localnet.com> - 2015-10-12 19:54 -0700
        Re: OT: Reformatted update on table call problem Robert Baer <robertbaer@localnet.com> - 2015-10-12 19:55 -0700
      Re: OT: Reformatted update on table call problem Robert Baer <robertbaer@localnet.com> - 2015-10-12 19:49 -0700
    Re: OT: Reformatted update on table call problem Robert Baer <robertbaer@localnet.com> - 2015-10-12 19:44 -0700
      Re: OT: Reformatted update on table call problem (OOPS!) Robert Baer <robertbaer@localnet.com> - 2015-10-12 23:52 -0700

csiph-web