That's because "start" is a 5 byte string and it will not fit in a byte or word variable. It will fit into a 5 byte array.
That's because "start" is a 5 byte string and it will not fit in a byte or word variable. It will fit into a 5 byte array.
If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
.
Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
.
There simply is no "Happy Spam" If you do it you will disappear from this forum.
ok well i had text deffined as a word so that will be why then!
So how do you use a 5 byte array?
Also the words that im currecntly using will be replaced and could be upo 16 characters long!
There's always different thought for x problem, if it was me, i would use one of the next approach.
1. Store Text string in internal or external EEPROM, Text variable would return the start address of your text string. Your string should be terminated by a NULL (or 0), so when you call the Display routine, it just read from the eeprom, show it, go to next character and continue untill it reach the NULL (0).
2. Almost like the above, but storing text String in the codespace. Something around the following
http://www.pbpgroup.com/modules/wfse...p?articleid=10 There's quite a few version of it on this forum.
Last edited by mister_e; - 10th November 2008 at 18:58.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Thanks for that mister_e!
ok so i have the code as this now:
If somone could point a way to a LCDOUT command to display one of the strings on there it would be greatly appreciated! As i have tried a few ways but due to my lack of understanding fail'************************************************* ***************
'* 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![]()
replacing HSEROUT with LCDOUT should work?
Which PIC you work with? The above is for 16F
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Im using the P16F876A
i tried
StartLoop ' This loop repeats continuously just as a test.
@ GetAddress _String1, _Addr ' Get address of String
gosub StringOut ' Send the String
LCDOUT $FE, 1, [13,10] ' New Line
@ GetAddress _AnotherString, _Addr ' Get address of String
gosub StringOut ' Send the String
LCDOUT $FE, 1, [13,10] ' New Line
pause 500
goto StartLoop ' Repeat
but this just gave me a bad expression
you don't need those square brackets []
try something like...
Code:Start @ GetAddress _AnotherString, _Addr ' Get address of String LCDOUT $FE,1 ' Here you place your LCD cusor where you want gosub StringOut ' Send the String pause 500 goto Start ' 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 LCDOUT Char ' Send first char Char = TwoChars & $7F ' Separate second char if Char = 0 then StringDone ' Look for Null char, Stop if found LCDOUT Char ' Send the second char Addr = Addr + 1 ' Point to next two characters goto StringOut ' Continue with rest of the string StringDone: return
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Bookmarks