Searching \ for '[PIC]: PCLATH still problems...code here..long pos' 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 problems...code here..long pos'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: PCLATH still problems...code here..long pos'
2001\03\30@142146 by Hardware Engineering

picon face
I did a smaller version of my code where it only sends a "test" to the
display.  If the code is all in the same page it works fine, but only placing
the code for the display call in the other page, it wont work.

here is the code.  This ought not to be so hard...

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


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

       ; 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



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


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