Problem with INT and HD44780 LCD...

Started by sigint112 February 21, 2004
Hi,
im new to PIC Interrupts and i`ve tried to code a LCD clock.
I`m running the PIC16F84A with 6,4MHz but the codes doesn`t work.
(The LCD routines are ok... i`ve tested them).
Does anyone have any suggestions?

Thx,
SIGINT

The Code:

LCD_DATA EQU PORTB
LCD_DATA_TRIS EQU TRISB
LCD_CTRL EQU PORTA
LCD_RS EQU 0x00
LCD_RW EQU 0x01
LCD_E EQU 0x02 wait_loop EQU 0x20
loop EQU 0x22
temp EQU 0x21
w_temp EQU 0x22
s_temp EQU 0x23
hour EQU 0x24
minutes EQU 0x25
seconds EQU 0x26
clock_timer EQU 0x27
update EQU 0x28
tc EQU 0x64 org 0x00
goto INIT

org 0x04
goto ISR

INIT
bsf STATUS,RP0
clrf TRISA
clrf TRISB
bcf OPTION_REG,T0CS
bcf OPTION_REG,PSA
bsf OPTION_REG,PS0
bsf OPTION_REG,PS1
bsf OPTION_REG,PS2
bcf STATUS,RP0
clrf PORTA
clrf PORTB
clrf hour
clrf minutes
clrf seconds
movlw tc
movwf clock_timer
bsf INTCON,T0IE
movlw 0xff
movwf update
goto main WAIT
movlw 0xff
movwf wait_loop
wloop
decfsz wait_loop,F
goto wloop
return

xWAIT
movwf loop
inner_loop
call WAIT
decfsz loop,F
goto inner_loop
return

LCDPUTCMD
movwf temp
call LCDWAIT
bcf LCD_CTRL,LCD_RS
bcf LCD_CTRL,LCD_RW
swapf temp,W
bsf LCD_CTRL,LCD_E
movwf LCD_DATA
movlw 0x0f
call xWAIT
bcf LCD_CTRL,LCD_E
movlw 0x0f
call xWAIT
bsf LCD_CTRL,LCD_E
movf temp,W
movwf LCD_DATA
movlw 0x0f
call xWAIT
bcf LCD_CTRL,LCD_E
return LCDPUTDATA
movwf temp
call LCDWAIT
bsf LCD_CTRL,LCD_RS
bcf LCD_CTRL,LCD_RW
swapf temp,W
bsf LCD_CTRL,LCD_E
movwf LCD_DATA
movlw 0x0f
call xWAIT
bcf LCD_CTRL,LCD_E
movlw 0x0f
call xWAIT
bsf LCD_CTRL,LCD_E
movf temp,W
movwf LCD_DATA
movlw 0x0f
call xWAIT
bcf LCD_CTRL,LCD_E
return

LCDINIT
movlw 0xff
call xWAIT
bcf LCD_CTRL,LCD_RS
bcf LCD_CTRL,LCD_RW
bsf LCD_CTRL,LCD_E
movlw 0x03
movwf LCD_DATA
bcf LCD_CTRL,LCD_E
movlw 0x0f
call xWAIT
bsf LCD_CTRL,LCD_E
movlw 0x0f
call xWAIT
bcf LCD_CTRL,LCD_E
movlw 0x0f
call xWAIT
bsf LCD_CTRL,LCD_E
movlw 0x0f
call xWAIT
bcf LCD_CTRL,LCD_E
call LCDWAIT
bsf LCD_CTRL,LCD_E
movlw 0x02
movwf LCD_DATA
movlw 0x0f
call xWAIT
bcf LCD_CTRL,LCD_E
movlw 0x20
call LCDPUTCMD
movlw 0x0C
call LCDPUTCMD
movlw 0x01
call LCDPUTCMD
return

LCDWAIT
BSF STATUS,RP0
MOVLW 0x0FF
MOVWF LCD_DATA_TRIS
BCF STATUS, RP0
BCF LCD_CTRL, LCD_RS
BSF LCD_CTRL, LCD_RW
do_check
BSF LCD_CTRL, LCD_E
MOVF LCD_DATA, W
BCF LCD_CTRL, LCD_E
BSF LCD_CTRL, LCD_E
nop
nop
nop
nop
bcf LCD_CTRL, LCD_E
ANDLW 0x08
BTFSS STATUS, Z
GOTO do_check
lcdnotbusy
BCF LCD_CTRL, LCD_RW
BSF STATUS, RP0
MOVLW 0x000
MOVWF LCD_DATA_TRIS
BCF STATUS, RP0
return main
call LCDINIT
movlw 0x02
call LCDPUTCMD
bsf INTCON,GIE
mainloop
movf update,W
bcf STATUS,Z
xorlw 0xff
btfss STATUS,Z
goto end_main
bcf INTCON,GIE
movlw 0x00
movwf update
movlw 0x02
call LCDPUTCMD
movf hour,W
addlw 0x30
call LCDPUTDATA
movlw 0x3a
call LCDPUTDATA
movf minutes,W
addlw 0x30
call LCDPUTDATA
movlw 0x3a
call LCDPUTDATA
movf seconds,W
addlw 0x30
call LCDPUTDATA
bsf INTCON,GIE
end_main
goto mainloop

ISR
movwf w_temp
swapf STATUS,W
movwf s_temp
decfsz clock_timer,F
goto exit_int
movlw tc
movwf clock_timer
incf seconds,F
movf seconds,W
bcf STATUS,Z
xorlw 0x3c
btfss STATUS,Z
goto ret_from_int
movlw 0x00
movwf seconds
incf minutes,F
movf minutes,W
bcf STATUS,Z
xorlw 0x3c
btfss STATUS,Z
goto ret_from_int
movlw 0x00
movwf minutes
incf hour,F
movf hour,W
bcf STATUS,Z
xorlw 0x18
btfss STATUS,Z
goto ret_from_int
movlw 0x00
movwf hour
ret_from_int
movlw 0xFF
movwf update
exit_int
bsf INTCON, T0IE
bcf INTCON, T0IF
swapf s_temp,W
movwf STATUS
swapf w_temp,F
swapf w_temp,W
retfi
end




--- In , "sigint112" <SIGINT@f...> wrote:
> Hi,
> im new to PIC Interrupts and i`ve tried to code a LCD clock.
> I`m running the PIC16F84A with 6,4MHz but the codes doesn`t work.
> (The LCD routines are ok... i`ve tested them).
> Does anyone have any suggestions?
>

How about if you describe the behavior you are seeing? In other
words, what are you seeing that you shouldn't and what are you not
seeing that you should?



well without looking too far into your program I can tell you that what
I do is put the interupt routine right after the org 0x004 statement.
Then the last statement of the routine is retfie. On interrupt it
executes at the top of 0x004, and when finished it goes back to where
it came from. No goto's involved. --- sigint112 <> wrote:
> Hi,
> im new to PIC Interrupts and i`ve tried to code a LCD clock.
> I`m running the PIC16F84A with 6,4MHz but the codes doesn`t work.
> (The LCD routines are ok... i`ve tested them).
> Does anyone have any suggestions?
>
> Thx,
> SIGINT
>
> The Code:
>
> LCD_DATA EQU PORTB
> LCD_DATA_TRIS EQU TRISB
> LCD_CTRL EQU PORTA
> LCD_RS EQU 0x00
> LCD_RW EQU 0x01
> LCD_E EQU 0x02 > wait_loop EQU 0x20
> loop EQU 0x22
> temp EQU 0x21
> w_temp EQU 0x22
> s_temp EQU 0x23
> hour EQU 0x24
> minutes EQU 0x25
> seconds EQU 0x26
> clock_timer EQU 0x27
> update EQU 0x28
> tc EQU 0x64 > org 0x00
> goto INIT
>
> org 0x04
> goto ISR >
>
> INIT
> bsf STATUS,RP0
> clrf TRISA
> clrf TRISB
> bcf OPTION_REG,T0CS
> bcf OPTION_REG,PSA
> bsf OPTION_REG,PS0
> bsf OPTION_REG,PS1
> bsf OPTION_REG,PS2
> bcf STATUS,RP0
> clrf PORTA
> clrf PORTB
> clrf hour
> clrf minutes
> clrf seconds
> movlw tc
> movwf clock_timer
> bsf INTCON,T0IE
> movlw 0xff
> movwf update
> goto main > WAIT
> movlw 0xff
> movwf wait_loop
> wloop
> decfsz wait_loop,F
> goto wloop
> return
>
> xWAIT
> movwf loop
> inner_loop
> call WAIT
> decfsz loop,F
> goto inner_loop
> return
>
> LCDPUTCMD
> movwf temp
> call LCDWAIT
> bcf LCD_CTRL,LCD_RS
> bcf LCD_CTRL,LCD_RW
> swapf temp,W
> bsf LCD_CTRL,LCD_E
> movwf LCD_DATA
> movlw 0x0f
> call xWAIT
> bcf LCD_CTRL,LCD_E
> movlw 0x0f
> call xWAIT
> bsf LCD_CTRL,LCD_E
> movf temp,W
> movwf LCD_DATA
> movlw 0x0f
> call xWAIT
> bcf LCD_CTRL,LCD_E
> return > LCDPUTDATA
> movwf temp
> call LCDWAIT
> bsf LCD_CTRL,LCD_RS
> bcf LCD_CTRL,LCD_RW
> swapf temp,W
> bsf LCD_CTRL,LCD_E
> movwf LCD_DATA
> movlw 0x0f
> call xWAIT
> bcf LCD_CTRL,LCD_E
> movlw 0x0f
> call xWAIT
> bsf LCD_CTRL,LCD_E
> movf temp,W
> movwf LCD_DATA
> movlw 0x0f
> call xWAIT
> bcf LCD_CTRL,LCD_E
> return
>
> LCDINIT
> movlw 0xff
> call xWAIT
> bcf LCD_CTRL,LCD_RS
> bcf LCD_CTRL,LCD_RW
> bsf LCD_CTRL,LCD_E
> movlw 0x03
> movwf LCD_DATA
> bcf LCD_CTRL,LCD_E
> movlw 0x0f
> call xWAIT
> bsf LCD_CTRL,LCD_E
> movlw 0x0f
> call xWAIT
> bcf LCD_CTRL,LCD_E
> movlw 0x0f
> call xWAIT
> bsf LCD_CTRL,LCD_E
> movlw 0x0f
> call xWAIT
> bcf LCD_CTRL,LCD_E
> call LCDWAIT
> bsf LCD_CTRL,LCD_E
> movlw 0x02
> movwf LCD_DATA
> movlw 0x0f
> call xWAIT
> bcf LCD_CTRL,LCD_E
> movlw 0x20
> call LCDPUTCMD
> movlw 0x0C
> call LCDPUTCMD
> movlw 0x01
> call LCDPUTCMD
> return
>
> LCDWAIT
> BSF STATUS,RP0
> MOVLW 0x0FF
> MOVWF LCD_DATA_TRIS
> BCF STATUS, RP0
> BCF LCD_CTRL, LCD_RS
> BSF LCD_CTRL, LCD_RW
> do_check
> BSF LCD_CTRL, LCD_E
> MOVF LCD_DATA, W
> BCF LCD_CTRL, LCD_E
> BSF LCD_CTRL, LCD_E
> nop
> nop
> nop
> nop
> bcf LCD_CTRL, LCD_E
> ANDLW 0x08
> BTFSS STATUS, Z
> GOTO do_check
> lcdnotbusy
> BCF LCD_CTRL, LCD_RW
> BSF STATUS, RP0
> MOVLW 0x000
> MOVWF LCD_DATA_TRIS
> BCF STATUS, RP0
> return > main
> call LCDINIT
> movlw 0x02
> call LCDPUTCMD
> bsf INTCON,GIE
> mainloop
> movf update,W
> bcf STATUS,Z
> xorlw 0xff
> btfss STATUS,Z
> goto end_main
> bcf INTCON,GIE
> movlw 0x00
> movwf update
> movlw 0x02
> call LCDPUTCMD
> movf hour,W
> addlw 0x30
> call LCDPUTDATA
> movlw 0x3a
> call LCDPUTDATA
> movf minutes,W
> addlw 0x30
> call LCDPUTDATA
> movlw 0x3a
> call LCDPUTDATA
> movf seconds,W
> addlw 0x30
> call LCDPUTDATA
> bsf INTCON,GIE
> end_main
> goto mainloop
>
> ISR
> movwf w_temp
> swapf STATUS,W
> movwf s_temp
> decfsz clock_timer,F
> goto exit_int
> movlw tc
> movwf clock_timer
> incf seconds,F
> movf seconds,W
> bcf STATUS,Z
> xorlw 0x3c
> btfss STATUS,Z
> goto ret_from_int
> movlw 0x00
> movwf seconds
> incf minutes,F
> movf minutes,W
> bcf STATUS,Z
> xorlw 0x3c
> btfss STATUS,Z
> goto ret_from_int
> movlw 0x00
> movwf minutes
> incf hour,F
> movf hour,W
> bcf STATUS,Z
> xorlw 0x18
> btfss STATUS,Z
> goto ret_from_int
> movlw 0x00
> movwf hour
> ret_from_int
> movlw 0xFF
> movwf update
> exit_int
> bsf INTCON, T0IE
> bcf INTCON, T0IF
> swapf s_temp,W
> movwf STATUS
> swapf w_temp,F
> swapf w_temp,W
> retfi
> end >
>


__________________________________



> How about if you describe the behavior you are seeing? In other
> words, what are you seeing that you shouldn't and what are you not
> seeing that you should?

Sorry,
i forgot to tell what`s not working:
When i power the PIC the LCD keeps clear.. nothing is displayed, but
i`ve tested the LCD routines... they are ok.
But when i put the following part into the ISR i only get "0:0:1"
on the LCD:

movlw 0x02
call LCDPUTCMD #Clear LCD
movf hour,W
addlw 0x30
call LCDPUTDATA # Put hours on LCD
movlw 0x3a
call LCDPUTDATA # ":" on LCD
movf minutes,W
addlw 0x30
call LCDPUTDATA
movlw 0x3a
call LCDPUTDATA
movf seconds,W
addlw 0x30
call LCDPUTDATA




Ok ... now i got it working :)
I don`t know if the timing is ok... but here`s the code,it`s free for use:

LCD_DATA EQU PORTB #Bit 0-3 (4bit interface)
LCD_DATA_TRIS EQU TRISB
LCD_CTRL EQU PORTA
LCD_RS EQU 0x00 #Bit 0 of PORTA
LCD_RW EQU 0x01 #Bit 1
LCD_E EQU 0x02 #Bit 2 wait_loop EQU 0x20
loop EQU 0x22
temp EQU 0x21
w_temp EQU 0x22
s_temp EQU 0x23
p_temp EQU 0x24
clock_timer EQU 0x25
update EQU 0x26
wait_w EQU 0x27
tc EQU 0x18 #Timeconstant for 6,4MHz (maybe)

h1 EQU 0x28
h10 EQU 0x29
m1 EQU 0x2a
m10 EQU 0x2b
s1 EQU 0x2c
s10 EQU 0x2d
toggle EQU 0x2f # The ":" chars...

org 0x00
goto INIT

org 0x04
ISR
movwf w_temp
swapf STATUS,W
bcf STATUS,RP0
movwf s_temp
swapf PCLATH,W
movwf p_temp bcf STATUS,Z
decfsz clock_timer,F
goto exit_int
movlw tc
movwf clock_timer

btfsc PORTA,3
goto check_hour
movlw 0x0f
movwf clock_timer
goto inc_min
check_hour
btfss PORTA,4
goto inc_hour inc_sec
incf s1,F
movf s1,W
bcf STATUS,Z
xorlw 0x0A
btfss STATUS,Z
goto ret_from_int
movlw 0x00
movwf s1

incf s10,F
movf s10,W
bcf STATUS,Z
xorlw 0x06
btfss STATUS,Z
goto ret_from_int
movlw 0x00
movwf s10

inc_min
incf m1,F
movf m1,W
bcf STATUS,Z
xorlw 0x0A
btfss STATUS,Z
goto ret_from_int
movlw 0x00
movwf m1

incf m10,F
movf m10,W
bcf STATUS,Z
xorlw 0x06
btfss STATUS,Z
goto ret_from_int
movlw 0x00
movwf m10

inc_hour
incf h1,F
movf h1,W
bcf STATUS,Z
xorlw 0x0a
btfss STATUS,Z
goto ret_from_int
movlw 0x00
movwf h1

incf h10,F
movf h10,W
bcf STATUS,Z
xorlw 0x02
btfss STATUS,Z
goto ret_from_int
movf h1,W
bcf STATUS,Z
xorlw 0x04
btfss STATUS,Z
goto ret_from_int
movlw 0x00
movwf h1
movwf h10

ret_from_int

movf toggle,W
bcf STATUS,Z
xorlw 0x3a
movlw 0x3a
btfsc STATUS,Z
movlw 0xa0
movwf toggle movlw 0x02
call LCDPUTCMD
movf h10,W
addlw 0x30
call LCDPUTDATA
movf h1,W
addlw 0x30
call LCDPUTDATA
movf toggle,W
call LCDPUTDATA
movf m10,W
addlw 0x30
call LCDPUTDATA
movf m1,W
addlw 0x30
call LCDPUTDATA
movf toggle,W
call LCDPUTDATA
movf s10,W
addlw 0x30
call LCDPUTDATA
movf s1,W
addlw 0x30
call LCDPUTDATA

exit_int swapf p_temp,W
movwf PCLATH
swapf s_temp,W
movwf STATUS
swapf w_temp,F
swapf w_temp,W
bcf INTCON, T0IF
retfie

INIT
bsf STATUS,RP0
movlw 0x18
movwf TRISA
clrf TRISB
bcf OPTION_REG,T0CS
bcf OPTION_REG,PSA
bsf OPTION_REG,PS0
bsf OPTION_REG,PS1
bsf OPTION_REG,PS2
bcf STATUS,RP0
clrf PORTA
clrf PORTB
clrf h1
clrf h10
clrf m1
clrf m10
clrf s1
clrf s10
movlw tc
movwf clock_timer
goto main WAIT
movwf wait_w
movlw 0xFF
movwf wait_loop
wloop
decfsz wait_loop,F
goto wloop
movf wait_w,W
return

LCDPUTCMD
movwf temp
call LCDWAIT
bcf LCD_CTRL,LCD_RS
bcf LCD_CTRL,LCD_RW
swapf temp,W
bsf LCD_CTRL,LCD_E
movwf LCD_DATA
bcf LCD_CTRL,LCD_E
call WAIT
bsf LCD_CTRL,LCD_E
movf temp,W
movwf LCD_DATA
bcf LCD_CTRL,LCD_E
return LCDPUTDATA
movwf temp
call LCDWAIT
bsf LCD_CTRL,LCD_RS
bcf LCD_CTRL,LCD_RW
swapf temp,W
bsf LCD_CTRL,LCD_E
movwf LCD_DATA
bcf LCD_CTRL,LCD_E
call WAIT
bsf LCD_CTRL,LCD_E
movf temp,W
movwf LCD_DATA
bcf LCD_CTRL,LCD_E
return

LCDINIT
movlw 0xa0
movwf temp
lcdinitloop
call WAIT
decfsz temp,F
goto lcdinitloop
bcf LCD_CTRL,LCD_RS
bcf LCD_CTRL,LCD_RW
bsf LCD_CTRL,LCD_E
movlw 0x03
movwf LCD_DATA
bcf LCD_CTRL,LCD_E
call WAIT
call WAIT
call WAIT
bsf LCD_CTRL,LCD_E
call WAIT
call WAIT
call WAIT
bcf LCD_CTRL,LCD_E
call WAIT
call WAIT
call WAIT
bsf LCD_CTRL,LCD_E
call WAIT
call WAIT
call WAIT
bcf LCD_CTRL,LCD_E
call LCDWAIT
call WAIT
call WAIT
bsf LCD_CTRL,LCD_E
movlw 0x02
movwf LCD_DATA
call WAIT
call WAIT
call WAIT
bcf LCD_CTRL,LCD_E
movlw 0x20
call LCDPUTCMD
movlw 0x0C
call LCDPUTCMD
movlw 0x01
call LCDPUTCMD
return

LCDWAIT
BSF STATUS,RP0
MOVLW 0xFF
MOVWF LCD_DATA_TRIS
BCF STATUS, RP0
BCF LCD_CTRL, LCD_RS
BSF LCD_CTRL, LCD_RW
do_check
BSF LCD_CTRL, LCD_E
MOVF LCD_DATA, W
BCF LCD_CTRL, LCD_E
BSF LCD_CTRL, LCD_E
nop
nop
nop
nop
bcf LCD_CTRL, LCD_E
ANDLW 0x08
BTFSS STATUS, Z
GOTO do_check
lcdnotbusy
BCF LCD_CTRL, LCD_RW
BSF STATUS, RP0
MOVLW 0x000
MOVWF LCD_DATA_TRIS
BCF STATUS, RP0
return main
call LCDINIT
bsf INTCON,T0IE
bcf INTCON,T0IF
bsf INTCON,GIE
mainloop
goto mainloop

end



you might find that doing all that in the interrupt can cause a
problem. If you're WDT trips every 256 execution cycles and you're
still in the interrupt you'll get things with a funky smell.

What I do is set a bit in the interrupt to indicate that it's time to
refresh the LCD, then test the bit in the main program loop and if it's
set do the screen print, and clear the bit before the return.

That way I can have all kinds of ugly code to get the time on the
screen the way I want but the interrupt goes off without a hitch.

Regards, John.

--- sigint112 <> wrote:
> Ok ... now i got it working :)
> I don`t know if the timing is ok... but here`s the code,it`s free for
> use:
>
> LCD_DATA EQU PORTB #Bit 0-3 (4bit interface)
> LCD_DATA_TRIS EQU TRISB
> LCD_CTRL EQU PORTA
> LCD_RS EQU 0x00 #Bit 0 of PORTA
> LCD_RW EQU 0x01 #Bit 1
> LCD_E EQU 0x02 #Bit 2 > wait_loop EQU 0x20
> loop EQU 0x22
> temp EQU 0x21
> w_temp EQU 0x22
> s_temp EQU 0x23
> p_temp EQU 0x24
> clock_timer EQU 0x25
> update EQU 0x26
> wait_w EQU 0x27
> tc EQU 0x18 #Timeconstant for 6,4MHz (maybe)
>
> h1 EQU 0x28
> h10 EQU 0x29
> m1 EQU 0x2a
> m10 EQU 0x2b
> s1 EQU 0x2c
> s10 EQU 0x2d
> toggle EQU 0x2f # The ":" chars...
>
> org 0x00
> goto INIT
>
> org 0x04
> ISR
> movwf w_temp
> swapf STATUS,W
> bcf STATUS,RP0
> movwf s_temp
> swapf PCLATH,W
> movwf p_temp > bcf STATUS,Z
> decfsz clock_timer,F
> goto exit_int
> movlw tc
> movwf clock_timer
>
> btfsc PORTA,3
> goto check_hour
> movlw 0x0f
> movwf clock_timer
> goto inc_min
> check_hour
> btfss PORTA,4
> goto inc_hour > inc_sec
> incf s1,F
> movf s1,W
> bcf STATUS,Z
> xorlw 0x0A
> btfss STATUS,Z
> goto ret_from_int
> movlw 0x00
> movwf s1
>
> incf s10,F
> movf s10,W
> bcf STATUS,Z
> xorlw 0x06
> btfss STATUS,Z
> goto ret_from_int
> movlw 0x00
> movwf s10
>
> inc_min
> incf m1,F
> movf m1,W
> bcf STATUS,Z
> xorlw 0x0A
> btfss STATUS,Z
> goto ret_from_int
> movlw 0x00
> movwf m1
>
> incf m10,F
> movf m10,W
> bcf STATUS,Z
> xorlw 0x06
> btfss STATUS,Z
> goto ret_from_int
> movlw 0x00
> movwf m10
>
> inc_hour
> incf h1,F
> movf h1,W
> bcf STATUS,Z
> xorlw 0x0a
> btfss STATUS,Z
> goto ret_from_int
> movlw 0x00
> movwf h1
>
> incf h10,F
> movf h10,W
> bcf STATUS,Z
> xorlw 0x02
> btfss STATUS,Z
> goto ret_from_int
> movf h1,W
> bcf STATUS,Z
> xorlw 0x04
> btfss STATUS,Z
> goto ret_from_int
> movlw 0x00
> movwf h1
> movwf h10
>
> ret_from_int
>
> movf toggle,W
> bcf STATUS,Z
> xorlw 0x3a
> movlw 0x3a
> btfsc STATUS,Z
> movlw 0xa0
> movwf toggle > movlw 0x02
> call LCDPUTCMD
> movf h10,W
> addlw 0x30
> call LCDPUTDATA
> movf h1,W
> addlw 0x30
> call LCDPUTDATA
> movf toggle,W
> call LCDPUTDATA
> movf m10,W
> addlw 0x30
> call LCDPUTDATA
> movf m1,W
> addlw 0x30
> call LCDPUTDATA
> movf toggle,W
> call LCDPUTDATA
> movf s10,W
> addlw 0x30
> call LCDPUTDATA
> movf s1,W
> addlw 0x30
> call LCDPUTDATA
>
> exit_int > swapf p_temp,W
> movwf PCLATH
> swapf s_temp,W
> movwf STATUS
> swapf w_temp,F
> swapf w_temp,W
> bcf INTCON, T0IF
> retfie >
>
> INIT
> bsf STATUS,RP0
> movlw 0x18
> movwf TRISA
> clrf TRISB
> bcf OPTION_REG,T0CS
> bcf OPTION_REG,PSA
> bsf OPTION_REG,PS0
> bsf OPTION_REG,PS1
> bsf OPTION_REG,PS2
> bcf STATUS,RP0
> clrf PORTA
> clrf PORTB
> clrf h1
> clrf h10
> clrf m1
> clrf m10
> clrf s1
> clrf s10
> movlw tc
> movwf clock_timer
> goto main > WAIT
> movwf wait_w
> movlw 0xFF
> movwf wait_loop
> wloop
> decfsz wait_loop,F
> goto wloop
> movf wait_w,W
> return
>
> LCDPUTCMD
> movwf temp
> call LCDWAIT
> bcf LCD_CTRL,LCD_RS
> bcf LCD_CTRL,LCD_RW
> swapf temp,W
> bsf LCD_CTRL,LCD_E
> movwf LCD_DATA
> bcf LCD_CTRL,LCD_E
> call WAIT
> bsf LCD_CTRL,LCD_E
> movf temp,W
> movwf LCD_DATA
> bcf LCD_CTRL,LCD_E
> return > LCDPUTDATA
> movwf temp
> call LCDWAIT
> bsf LCD_CTRL,LCD_RS
> bcf LCD_CTRL,LCD_RW
> swapf temp,W
> bsf LCD_CTRL,LCD_E
> movwf LCD_DATA
> bcf LCD_CTRL,LCD_E
> call WAIT
> bsf LCD_CTRL,LCD_E
> movf temp,W
> movwf LCD_DATA
> bcf LCD_CTRL,LCD_E
> return
>
> LCDINIT
> movlw 0xa0
> movwf temp
> lcdinitloop
> call WAIT
> decfsz temp,F
> goto lcdinitloop
> bcf LCD_CTRL,LCD_RS
> bcf LCD_CTRL,LCD_RW
> bsf LCD_CTRL,LCD_E
> movlw 0x03
> movwf LCD_DATA
> bcf LCD_CTRL,LCD_E
> call WAIT
> call WAIT
> call WAIT
> bsf LCD_CTRL,LCD_E
> call WAIT
> call WAIT
> call WAIT
> bcf LCD_CTRL,LCD_E
> call WAIT
> call WAIT
> call WAIT
> bsf LCD_CTRL,LCD_E
> call WAIT
> call WAIT
> call WAIT
> bcf LCD_CTRL,LCD_E
> call LCDWAIT
> call WAIT
> call WAIT
> bsf LCD_CTRL,LCD_E
> movlw 0x02
> movwf LCD_DATA
> call WAIT
> call WAIT
> call WAIT
> bcf LCD_CTRL,LCD_E
> movlw 0x20
> call LCDPUTCMD
> movlw 0x0C
> call LCDPUTCMD
> movlw 0x01
> call LCDPUTCMD
> return
>
> LCDWAIT
> BSF STATUS,RP0
> MOVLW 0xFF
> MOVWF LCD_DATA_TRIS
> BCF STATUS, RP0
> BCF LCD_CTRL, LCD_RS
> BSF LCD_CTRL, LCD_RW
> do_check
> BSF LCD_CTRL, LCD_E
> MOVF LCD_DATA, W
> BCF LCD_CTRL, LCD_E
> BSF LCD_CTRL, LCD_E
> nop
> nop
> nop
> nop
> bcf LCD_CTRL, LCD_E
> ANDLW 0x08
> BTFSS STATUS, Z
> GOTO do_check
> lcdnotbusy
> BCF LCD_CTRL, LCD_RW
> BSF STATUS, RP0
> MOVLW 0x000
> MOVWF LCD_DATA_TRIS
> BCF STATUS, RP0
> return > main
> call LCDINIT
> bsf INTCON,T0IE
> bcf INTCON,T0IF
> bsf INTCON,GIE
> mainloop
> goto mainloop
>
> end >


__________________________________




What I have always been told by my mentors is that you shouldn't do any
processing in the ISR itself, but that you should be able to cause a state
change based on something that you do in the ISR.

Duane
On Sun, 22 Feb 2004, John Remington wrote:

> you might find that doing all that in the interrupt can cause a
> problem. If you're WDT trips every 256 execution cycles and you're
> still in the interrupt you'll get things with a funky smell.
>
> What I do is set a bit in the interrupt to indicate that it's time to
> refresh the LCD, then test the bit in the main program loop and if it's
> set do the screen print, and clear the bit before the return.
>
> That way I can have all kinds of ugly code to get the time on the
> screen the way I want but the interrupt goes off without a hitch.
>
> Regards, John.





--- In , dpmohne@z... wrote:
> What I have always been told by my mentors is that you shouldn't do any
> processing in the ISR itself, but that you should be able to cause a
state
> change based on something that you do in the ISR.
>
> Duane

Yes, i tried to do so... but for some strange reason it didn`t work :(
I wonder if the problem may be an interrupt during LCD output... but i
don`t know why this should be a problem.

Thx,
SIGINT


--- In , John Remington <jrem123@y...> wrote:
> you might find that doing all that in the interrupt can cause a
> problem. If you're WDT trips every 256 execution cycles and you're
> still in the interrupt you'll get things with a funky smell.
>
> What I do is set a bit in the interrupt to indicate that it's time to
> refresh the LCD, then test the bit in the main program loop and if it's
> set do the screen print, and clear the bit before the return.
>
> That way I can have all kinds of ugly code to get the time on the
> screen the way I want but the interrupt goes off without a hitch.
>
> Regards, John.
>

Hi John,
i tried to use a flag to tell the main loop to update the LCD, but for
some strange reason it didn't work. It might be a problem with an
interrupt during LCD update, but i don't see why this should be a
problem... by the way: i never use the WDT, so it's no prob to me ;)

Thx,
SIGINT