while it's alive..
Darrel, i've made changes as per your recommandation,
So, the skipchar label down here take care of characters not to be sent to LCD.
that works!
and then I had the *brilliant* idea to add something else...which failed.
I know we're, but not sure why.
Next I wanted to disable interrupt while I do my little LED dance at start, and send some message on the LCD.
It seems like the code will stop at > ; @ INT_ENABLE RX_INT; this seem buggy...
Do you see why I couldn't disable/enable INterrupts at start, or at that specific place?
I taught maybe i should put this in a sub routine?
Code:
; @ INT_DISABLE RX_INT ; Ignore input at initialisation
HIGH LedPort ' Some visual sign of life for the PIC
Pause 500
LOW LedPort
pause 50
lcdout $FE,1 'LCD INIT
lcdout $FE,2
LCDOUT "LCD SERIAL - READY"
PAUSE 300 ' Timeout for LCD to settle
; @ INT_ENABLE RX_INT ; this seem buggy...
' * * * * Main program starts here * * * * * * * *
loop:
For i = 0 to 10 ' Delay for .02 seconds (10*2mS)
Pause 2 ' Use a short pause within a loop
Next i ' instead of one long pause
For i = 0 to 10 ' Delay for .02 seconds (10*2mS)
Pause 2 ' Use a short pause within a loop
Next i ' instead of one long pause
skipachar: ; Will come back here if a char has to be skipped
skipchar=0 ; reset the flag so next char could be displayed
display: ' dump the buffer to the LCD
IF errflag Then error ' Handle error if needed
IF index_in = index_out Then
goto loop ' loop if nothing in buffer
endif
GoSub getbuf ' Get a character from buffer
if skipchar=1 then skipachar ; with goto up there, skipping display of the last read char
LCDOut bufchar ' Send the character to LCD
IF col > 20 Then ' Check for end of line
col = 1 ' Reset LCD location
LCDOut $fe,$c0,REP " "\20 ' Clear line-2 of LCD
LCDOut $FE,2 ' Tell LCD to return home
EndIF
if ShowRTC=1 then
LCDOut $FE,$D4,"RTC ACTIVED"
EndIF
GoTo display ' Check for more characters in buffer
' Subroutines
;Disable ' Don't check for interrupts in this section
getbuf: ' move the next character in buffer to bufchar
@ INT_DISABLE RX_INT
index_out = (index_out + 1) ' Increment index_out pointer (0 to 63)
' Reset pointer if outside of buffer
IF index_out > (buffer_size-1) Then index_out = 0
bufchar = buffer[index_out] ' Read buffer location
if skipLCDComm>0 then
skipLCDComm=skipLCDComm-1
endif
;Routine for buffering LCD commands
if (GrabBkLt=1) then
; WE have signal to watch for value for LCD backlight next
; LCDOut $FE,$94,"BACKLIGHT set:<",#bufchar,">" ; for debug only
HPWM 1,bufchar ,1250 ; Setting Pulse Mod to desired value
' Observe minimum FREQ for given OSC speed. 20Mhz is 1221Hz
Low LedPort ; Debug only
GrabBkLt=0 ; All is done, signal to close the loop
skipchar=1 ; to skip displaying this char in main loop
endif
;Following will trigger the routine up here on the next chr received
; but if skip if $fe has been called 2 shots ago
if (bufchar=20) and (skipLCDComm=0) then ; 14h, trigger for special LCD command
HIGH LedPort ; Debug only
GrabBkLt=1 ; Signal to get the value of backlight level
skipchar=1 ; ;to skip displaying this char in main loop
endif
;Prevent value of 14h to be trapped for other command, we memorize previous call of $FE (254)
if bufchar=254 then
skipLCDComm=2 ;
endif
@ INT_ENABLE RX_INT
Return
Bookmarks