'************************************************* ***************
'* Name : STRINGS.PBP *
'* Author : Darrel Taylor / John Barrat *
'* Date : 5/30/2003 *
'* Note: Strings must be NULL Terminated *
'************************************************* ***************
DEFINE LOADER_USED 1 ' If using bootloader
DEFINE OSC 4
DEFINE HSER_TXSTA 24h ' Use this for Higher Baud Rates
DEFINE HSER_SPBRG 25 ' 9600 Baud at 4mhz
'
DEFINE LCD_DREG PORTB 'Define PIC port used for LCD Data lines
DEFINE LCD_DBIT 4 'Define first pin of portb connected to LCD DB4
DEFINE LCD_RSREG PORTB 'Define PIC port used for RS line of LCD
DEFINE LCD_RSBIT 3 'Define Portb pin used for RS connection
DEFINE LCD_EREG PORTB 'Define PIC prot used for E line of LCD
DEFINE LCD_EBIT 0 'Define PortB pin used for E connection
DEFINE LCD_BITS 4 'Define the 4 bit communication mode to LCD
DEFINE LCD_LINES 2 'Define using a 2 line LCD
DEFINE LCD_COMMANDUS 2000 'Define delay between sending LCD commands
DEFINE LCD_DATAUS 50 'Define delay time between data sent.
' Control Buttons/Lines
' ---------------------
ButStart var Portc.0 ' Take this pin low momentarily to START timing
ButStop var Portc.1 ' Take this pin low momentarily to STOP timing
ButReset var Portc.2 ' Take this pin low momentarily to RESET clock
Butup var portc.3 ' Take this pin low momentarily to increase clock time
Butdwn var portc.4 ' Take this pin low momentarily to decrease clock time
Addr var word
TwoChars var word
Char var byte
Clear
goto StartLoop ' Required
String1:
@ da "This is a string",0
AnotherString:
@ da "Here is another string",0
'------------GetAddress Macro - Location insensitive -------------------------
ASM
GetAddress macro Label, Wout ; Returns the Address of a Label as a Word
CHK?RP Wout
movlw low Label
movwf Wout
movlw High Label
movwf Wout + 1
endm
ENDASM
StartLoop ' This loop repeats continuously just as a test.
@ GetAddress _String1, _Addr ' Get address of String
gosub StringOut ' Send the String
hserout [13,10] ' New Line
@ GetAddress _AnotherString, _Addr ' Get address of String
gosub StringOut ' Send the String
hserout [13,10] ' New Line
pause 500
goto StartLoop ' Repeat
StringOut: ' Send the string out via Hserout
Readcode Addr, TwoChars ' Get the 14 bit packed characters
Char = TwoChars >> 7 ' Separate first char
if Char = 0 then StringDone ' Look for Null char, Stop if found
hserout [Char] ' Send first char
Char = TwoChars & $7F ' Separate second char
if Char = 0 then StringDone ' Look for Null char, Stop if found
hserout [Char] ' Send the second char
Addr = Addr + 1 ' Point to next two characters
goto StringOut ' Continue with rest of the string
StringDone:
return
end
Bookmarks