Searching \ for '[PIC]:PCLATH still not working..part 2' 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=pic
Search entire site for: 'PCLATH still not working..part 2'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]:PCLATH still not working..part 2'
2001\03\30@163910 by Hardware Engineering

picon face
I'd accept that...but, I did this test and still does not work

This is not makin PIC's fun

(this code placed all calls the 'splash' routine calls inside the second page.
Even Goto's should retain the same page?)




       list      p=16F874    ; list directive to define processor

#include <p16F874.inc>        ; processor specific variable definitions

       __CONFIG  _HS_OSC & _WDT_OFF & _CP_OFF & _CPD_OFF & _BODEN_OFF & _LVP_OFF &
_WRT_ENABLE_ON & _PWRTE_ON & _DEBUG_OFF



       ERRORLEVEL -302         ;Supress incorrect bank selection message
       ERRORLEVEL -306         ;Supress Crossing page boundary message

       ERRORLEVEL +312         ;Page or Bank selection not needed for this device. No code
generated.
       ERRORLEVEL +307         ;Setting page bits.

       
#include        stc2.equ



DEBNC   macro   port,bit
       btfsc   port,bit        ;  Is the Button Pressed?
       goto    $+8             ;   No..so skip past this debounce
       movlw   0x0FF                
       movwf   Dlay                  
       decfsz  Dlay,1
       goto    $ - 1           ; wait for delay
       btfss   port,bit                ; If the button is active...wait if the button is still
active
       goto    $ - 1           ;   wait for it to become inactive
       endm

;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$


       org     0x000           ; The main line code starts here
main:
       goto    init

       org     0x004           ; interupt vector
       retfie                  ;return from interrupt

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


       org     0x060
init:
       movlw   0xFF            ; set for input
       movwf   TRISB           ; TRISB direction register
       movlw   0x3F            ; 0011 1111  upper two bits are outputs to LCD
       tris    PORTC           ; TRISC direction register

                               ; initilize port A, since it can be both an analog or digital port
       bcf     STATUS, RP0
       BCF     STATUS, RP1
       clrf    PORTA
       bsf     STATUS, RP0

       movlw   0x00
       tris    PORTA
       movlw   0x00            ; clear the register
       movwf   PORTA           ; and be sure all the relays are turned off

       movlw   0x00            ; set for output
       movwf   0x89            ; Port E TRISE direction register
       movlw   0x00            ; set for output
       movwf   0x88            ; Port D TRISD direction register

       BCF     STATUS, RP1
       BCF     STATUS, RP0

       clrf    PORTD
       clrf    PORTE

       call    InitLCD



am:
;       bcf     PCLATH,4
       bsf     PCLATH,3
       call    SPLASH
       bcf     PCLATH,3
       goto    am



InitLCD
       call    Delay  

       movlw   0x38  ; TWO Lines option
       movwf   ARG1
       call    SendLCDCommand
       call    Delay

       ; Send 0x0C (or 0x0F)
       movlw   0x0C
       movwf   ARG1
       call    SendLCDCommand
       call    Delay

       ; Send 0x03
       movlw   0x03
       movwf   ARG1
       call    SendLCDCommand
       call    Delay




       ; Delay 100ms
       call    Delay
       call    Delay
       
       ; Send 0x06   ** Set AUTOINC, and NO Shifting
       movlw   0x06
       movwf   ARG1
       call    SendLCDCommand
       call    Delay

       ; Send 0x02  ** (HOME)
       movlw   0x02
       movwf   ARG1
       call    SendLCDCommand
       call    Delay
       
       retlw   0


Delay
       movlw   DELAY_50MS_HI
       movwf   DELAYHI
       movlw   DELAY_50MS_LO
       movwf   DELAYLO

       movf    DELAYHI, W
       movwf   COUNTHI
       movf    DELAYLO, W
       movwf   COUNTLO
DelayLoop
       decfsz  COUNTLO,1
       goto    DelayLoop
       decfsz  COUNTHI,1
       goto    DelaySetup
       goto    DelayDone
DelaySetup
       movf    DELAYLO, W
       movwf   COUNTLO
       goto    DelayLoop
DelayDone
       retlw   0




CLEAR_LCD
       ; Send 0x01    ** Clear
       movlw   0x01
       movwf   ARG1
       call    SendLCDCommand
       call    Delay
       call    Delay
       return




       org     0x800


SPLASH:
       movlw   0x80    
       movwf   ARG1
       call    SendLCDCommand
       call    Delay2
       movlw   _T
       call    Send_LCD_Data
       movlw   _e
       call    Send_LCD_Data
       movlw   _s
       call    Send_LCD_Data
       movlw   _t
       call    Send_LCD_Data
       return



SendLCDCommand          ; SENDLCDCOMMAND Sends a byte as a command to the LCD.
       bcf     PORTC,6         ; LCD_RS_BIT
       movf    ARG1, W
       movwf   PORTD           ; OK. Data is on the LCD data pins
       bsf     PORTC,7         ;LCD_E_BIT
       bcf     PORTC,7         ;LCD_E_BIT
       retlw   0

Send_LCD_Data           ; SENDLCDDATA Sends a byte as a data to the LCD.
       bsf     PORTC,6 ; LCD_RS_BIT
       movwf   PORTD              ; OK. Data is on the LCD data pins
       bsf     PORTC,7 ;LCD_E_BIT
       bcf     PORTC,7 ;LCD_E_BIT

       movlw   DELAY_50MS_HI
       movwf   DELAYHI
       movlw   DELAY_50MS_LO
       movwf   DELAYLO
       call    Delay2

       return

Delay2
       movlw   DELAY_50MS_HI
       movwf   DELAYHI
       movlw   DELAY_50MS_LO
       movwf   DELAYLO

       movf    DELAYHI, W
       movwf   COUNTHI
       movf    DELAYLO, W
       movwf   COUNTLO
DelayLoop2
       decfsz  COUNTLO,1
       goto    DelayLoop2
       decfsz  COUNTHI,1
       goto    DelaySetup2
       goto    DelayDone2
DelaySetup2
       movf    DELAYLO, W
       movwf   COUNTLO
       goto    DelayLoop2
DelayDone2
       retlw   0


       end

____________________________________________________________________
Get free email and a permanent address at http://www.netaddress.com/?N=1

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


2001\03\31@003809 by Drew Vassallo

picon face
>I'd accept that...but, I did this test and still does not work
>
>This is not makin PIC's fun

It gets better.
See below.

>am:
>;       bcf     PCLATH,4
>         bsf     PCLATH,3
>         call    SPLASH
>         bcf     PCLATH,3
.          ^^^^^^^^^^^^ remove this line
>         goto    am

This is OK, except for the resetting of PCLATH here.  You need to do it
BEFORE you return from the SPLASH routine:


{Quote hidden}

.         bcf     PCLATH,3
.         ^^^^^^^^ put this line here (without the period)

>         return

--Andrew
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email spam_OUTlistservTakeThisOuTspammitvma.mit.edu with SET PICList DIGEST in the body


2001\03\31@061038 by Bob Ammerman

picon face
----- Original Message -----
From: Drew Vassallo <.....snurpleKILLspamspam@spam@HOTMAIL.COM>
To: <PICLISTspamKILLspamMITVMA.MIT.EDU>
Sent: Saturday, March 31, 2001 12:38 AM
Subject: Re: [PIC]:PCLATH still not working..part 2


{Quote hidden}

I didn't look closely at this code to see what _is_ wrong. But this isn't
the problem. The 'return' instruction does _not_ pay any attention to PCLATH
(it neither reads nor writes it). Instead, 'return' gets the _entire_ return
address off the stack.

Bob Ammerman
RAm Systems
(contract development of high performance, high function, low-level
software)


{Quote hidden}

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email EraseMElistservspam_OUTspamTakeThisOuTmitvma.mit.edu with SET PICList DIGEST in the body



'[PIC]:PCLATH still not working..part 2'
2001\04\01@180501 by Olin Lathrop
face picon face
> >;       bcf     PCLATH,4
> >         bsf     PCLATH,3
> >         call    SPLASH
> >         bcf     PCLATH,3
> .          ^^^^^^^^^^^^ remove this line
> >         goto    am
>
> This is OK, except for the resetting of PCLATH here.  You need to do it
> BEFORE you return from the SPLASH routine:

No you don't.  The full return address is saved on the stack, so the RETURN
instruction is not dependent on PCLATH.  It is best to restore PCLATH in the
calling routine than in the subroutine.  The subroutine should not have
knowledge of and dependency on where it was called from.  Think of the case
where the subroutine is called from more than one page.


********************************************************************
Olin Lathrop, embedded systems consultant in Littleton Massachusetts
(978) 742-9014, olinspamspam_OUTembedinc.com, http://www.embedinc.com

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


2001\04\01@204114 by Drew Vassallo

picon face
>No you don't.  The full return address is saved on the stack, so the RETURN
>instruction is not dependent on PCLATH.  It is best to restore PCLATH in
>the
>calling routine than in the subroutine.  The subroutine should not have
>knowledge of and dependency on where it was called from.  Think of the case
>where the subroutine is called from more than one page.

You're right.  But then I have no idea why that code won't work.  It looks
innocent enough.  Thought it might be worth a try.

Good luck.

--Andrew

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com

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


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