Truncated match.
PICList
Thread
'Store data in rom (f877)'
2000\04\16@051001
by
Soon Lee
Hello everyone
Got a big program here hope you can help me
I try to store text msg using retlw but they can exceed 256 bytes
it will cause stack overflow causing the whole program to restart
if the whole program is within 256 then everything is ok and perfect
is something to do with the retlw
Is there any other way of storing text msg in 16f877
can any one help me on this
thanks
regards
soon lee
2000\04\16@071327
by
Thorsten Klose
|
Soon Lee wrote:
> Is there any other way of storing text msg in 16f877
> can any one help me on this
You can store the string via "da" directive and read it
out directly.
An example:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MY_STRING da "Hello World!", 0
[..]
LCD_BUFFER equ 0x54
[..]
SWITCHBANK_0_2
movlw (MY_STRING & 0xff) ; store Lo Byte
movwf EEADR
movlw (MY_STRING >> 8) ; store Hi Byte
movwf EEADRH
SWITCHBANK_2_0
[..]
LCD_PrintText
LCD_PrintTextLoop
SWITCHBANK_0_3
bsf EECON1, EEPGD ; point to program memory
bsf EECON1, RD ; EEPROM Read
nop
nop
SWITCHBANK_3_2
incf EEADR, F ; increment memory pointer
skpnz
incf EEADRH, F
rlf EEDATA, W ; shift in bit7 of low byte
rlf EEDATH, W
SWITCHBANK_2_0
movwf LCD_BUFFER ; only for testing
tstf LCD_BUFFER
bz LCD_PrintTextEnd
call LCD_SendChar ; print out first char
SWITCHBANK_0_2
movf EEDATA, W ; load low byte
andlw 0x7f
SWITCHBANK_2_0
bz LCD_PrintTextEnd
call LCD_SendChar ; print out second char
goto LCD_PrintTextLoop
LCD_PrintTextEnd
return
--
_____________________________________________
_/ uC-Stuff for MIDI at http://go.to/uCApps /_______
/ Music is aesthetisized frequency (Klaus Schulze) /
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2000\04\16@075318
by
Alan B Pearce
Store the string in EEPROM which will allow you save code space, and when this
overflows put the rest in RETLW instructions.
Otherwise use an external EEPROM.
2000\04\16@132139
by
Soon Lee
Hi Pearce
Retlw only can be used within 256 byte of mermory, if the return address
crosses the 256 block it will cause stack overflow, i have try on the mplab.
as long as the return address and the retlw is in the same 256 block it is
ok but else .....
regards
soon lee
----- Original Message -----
From: Alan B Pearce <spam_OUTA.B.PearceTakeThisOuT
RL.AC.UK>
To: <.....PICLISTKILLspam
@spam@MITVMA.MIT.EDU>
Sent: Sunday, April 16, 2000 7:52 PM
Subject: Re: Store data in rom (f877)
> Store the string in EEPROM which will allow you save code space, and when
this
> overflows put the rest in RETLW instructions.
>
> Otherwise use an external EEPROM.
2000\04\16@133426
by
Alan B Pearce
>Retlw only can be used within 256 byte of mermory, if the return address
>crosses the 256 block it will cause stack overflow, i have try on the mplab.
>as long as the return address and the retlw is in the same 256 block it is
>ok but else .....
It was while I was writing the piece that I realised the new 16F877 is limited
to 256 bytes EEPROM as well, which is why I suggested using the EEPROM for most
of the table, then when you get an overflow incrementing the EEPROM address
counter, go on to use RETLW method. This would be alright for up to 512 bytes of
data.
There have been methods published in the list and I think there is aa AN note
from microchip on how to cross page boundaries when using RETLW tables. Look in
the Piclist FAQ.
If you do not mind adding a chip and having the data stored outside the pic
chip, then an I2C interface is probably the easiest.
2000\04\16@195501
by
Thorsten Klose
Alan B Pearce wrote:
> It was while I was writing the piece that I realised the new 16F877 is limited
> to 256 bytes EEPROM as well, which is why I suggested using the EEPROM for most
> of the table, then when you get an overflow incrementing the EEPROM address
> counter, go on to use RETLW method. This would be alright for up to 512 bytes of
> data.
Why are you using the data EEPROM on 16F877? Just take the program memory,
you can read it out like the data EEPROM and there is enough space for
up to 16000 7-Bit characters... see my example above.
Best Regards, Thorsten.
--
_____________________________________________
_/ uC-Stuff for MIDI at http://go.to/uCApps /_______
/ Music is aesthetisized frequency (Klaus Schulze) /
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2000\04\17@080458
by
Soon Lee
16000 characters?
0x3fff=14 bits
the upper byte is truncated to 0x3F
how you store the first 7 then the next seven?
using what code.
please enlighten me
regards
soon lee
{Original Message removed}
2000\04\17@123343
by
Don Hyde
|
It's not impossible to use a table or retlw's that's larger than 256
locations, just a little more trouble since you need to use and compute a
double-precision pointer.
; GetByteFromBigTable -- fetches a byte from a table larger than 256
locations
; pointerlow and pointerhigh are the double-precision pointer into the
table.
; NOTE -- PCLATH is altered, so you will need to restore it before
executing
; any goto or call instructions!
GetByteFromBigTable:
movlw low BigTable ;start adding pointer to address of table
addwf pointerlow,w
movwf temp ;low half of double-precision add
movlw high BigTable ;now start the high half
movwf PCLATH
skpnc
incf PCLATH,f ;propagate the carry, if any from
low half
movfw pointerhigh
addwf PCLATH,f
movfw temp
movwf PCL ;jump into the table
BigTable:
retlw 'a'
retlw 'b'
etc.
Note that BigTable does not need to be in the same page with
GetByteFromBigTable, and does not need to either start or end on a page
boundary.
> {Original Message removed}
2000\04\17@173008
by
Thorsten Klose
Soon Lee wrote:
> 16000 characters?
> 0x3fff=14 bits
> the upper byte is truncated to 0x3F
> how you store the first 7 then the next seven?
> using what code.
> please enlighten me
Simply use the "da" directive of MPASM (see help page)
See my example in <38F99D21.74F98D83
KILLspamgmx.de> how to
handle it.
Best Regards, Thorsten.
--
_____________________________________________
_/ uC-Stuff for MIDI at http://go.to/uCApps /_______
/ Music is aesthetisized frequency (Klaus Schulze) /
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
More... (looser matching)
- Last day of these posts
- In 2000
, 2001 only
- Today
- New search...