Searching \ for '[PIC]:PCLATH still not working..code review?' 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: 'PCLATH still not working..code review?'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]:PCLATH still not working..code review?'
2001\03\30@085400 by Hardware Engineering

picon face
ok...i removed everything from the code except the necessary pieces to just
sent the word "test" to the LCD.  First I kept the code in the same page and
it works fine...then changed to call from the second page, and it fails to
display.  

-------------------------------------------------------------------------
       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

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

       org     0x004           ; interupt vector
       retfie                  ;return from interrupt


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:
       bsf     PCLATH,3
       call    SPLASH
       bcf     PCLATH,3
       goto    am




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    Delay

       return



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
       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



; General DELAY routine
; Inputs:
;    DELAYHI   -   Initial Countdown value MSB
;    DELAYLO   -   Initial Countdown value LSB
; Uses:
;    COUNTHI   -   Counter value MSB
;    COUNTLO   -   Counter value LSB
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



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


SendLCDData             ; 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
       call    Delay
       retlw   0

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

LDC                                     ; long delay loop
       movlw   d'40'
       movwf   TEMP
LDCLOOP:
       call    Delay
       decfsz  TEMP,1
       goto    LDCLOOP
       return


       org     0x800


SPLASH:
       movlw   0x80    
       movwf   ARG1
       call    SendLCDCommand
       call    Delay
       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




       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\30@100908 by rchock, Steve

flavicon
face
Looks as if "SPLASH" is in a different page as everything else. When you
call
"send_lcd_data" and "SendLCDCommand" you are not switching back to the page
that
those routines are in. This causes your program to go to the "boonies".
Hope this helps!!

Best regards,
Steve


Steven Kosmerchock
Radio Frequency Systems
Phoenix,  Arizona  USA
(WORK) http://www.rfsamericas.com

http://www.geocities.com/researchtriangle/lab/6584

"Great spirits have always encountered violent
oppposition from mediocre minds."--A.Einstein



{Original Message removed}

2001\03\30@120538 by Olin Lathrop

face picon face
{Quote hidden}

You set PCLATH correctly before calling SPLASH and restore it
afterwords, but you forgot to do this inside SPLASH when calling
SENDLCDCOMMAND, DELAY, etc.

You should check out my GCALL and related macros in STD.INS.ASPIC at
http://www.embedinc.com/pic.  GCALL (Global CALL) automatically does
the PCLATH diddling before and after calling a subroutine.  MCALL
(Module CALL) is for calling a subroutine withing a module, which is
assumed to be all within one page.



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

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


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