|
|
View previous topic :: View next topic |
Author |
Message |
Mani
Joined: 16 Mar 2004 Posts: 2
|
Program memory read problem |
Posted: Tue Mar 16, 2004 10:21 pm |
|
|
Hi,
Because of the const table limitation imposed on the size, I've stored my long table using the directive #rom at a certain page address (16F877). But whenever I try to access those data, unpredicted results show up. My code goes like the following:
int16 Get_charAddress (char character)
{
int16 charAddress;
if (character == ' ')
return Character8x8;
else
{
charAddress = 8*(character - 32);
return (Character8x8 + charAddress);
}
}
This piece of code is to generate a legal index out of a character passed. the real index corresponds to the character ascii value minus 32, and 8 is the number of bytes per character needed to represent it on graphical lcd the table goes like this:
#define Character8x8 0x1000 // page 2
#rom Character8x8 = {
0, 0, 0, 0, 0, 0, 0, 0, //' '
0, 6, 95, 95, 6, 0, 0, 0, //'!' Indexed by D'33'
0, 7, 7, 0, 7, 7, 0, 0, //'"'
20, 127, 127, 20, 127, 127, 20, 0, //'#'
36, 46, 107, 107, 58, 18, 0, 0, //'$'
70, 102, 48, 24, 12, 102, 98, 0, //'%'
all the way down
The main problem resides somewhere in here:
void GLCD_printf (char ch)
{
int8 i, i8;
int16 val;
if ( xPtr > (128 - font.width) )
{
xPtr = 0;
yPtr++;
if (yPtr == 8)
yPtr = 0;
}
if ( xPtr < 64 )
{
LcdSideSelect(LEFT);
LcdCommandWrite(Y_ADDRESS + xPtr);
}
else
{
LcdSideSelect(RIGHT);
LcdCommandWrite(Y_ADDRESS + xPtr - 64);
}
LcdCommandWrite(X_ADDRESS + yPtr);
for (i=0; i<font.width; i++)
{
val = read_program_eeprom(Get_charAddress(ch) + i);
i8 = make8(val, 0);
LcdDataWrite(i8);
xPtr++;
if (xPtr == 64)
{
LcdSideSelect(RIGHT);
LcdCommandWrite(X_ADDRESS + yPtr);
LcdCommandWrite(Y_ADDRESS);
}
}
}
still can't figure out where is the problem, anyone can help please? |
|
|
SteveS
Joined: 27 Oct 2003 Posts: 126
|
Program memory read problem |
Posted: Wed Mar 17, 2004 7:06 am |
|
|
From Help file on #ROM:
"Note that this directive does not prevent the ROM area from being used. See #ORG to reserve ROM."
That may be it. Otherwise I suggest trying to pinpoint the problem by making a small program to test what you think is the offending code; if available, use RS232 to output results to separate a rom-read problem from a display problem. Also look at the list file. It can be a bit tedious, but 'there's gold in them thar hills'.
- SteveS |
|
|
Mani
Joined: 16 Mar 2004 Posts: 2
|
Re: |
Posted: Wed Mar 17, 2004 8:56 am |
|
|
The problem is that I only have one serial port in my computer and the mouse is already using it. so it's impossible for me to use the RS232 to trace my program. and I've checked the hex file and the program memory table seems to be loaded properly at the assigned address. I've started to suspect everything, and got drifted too far. could it be possible that the program eeprom address should be passed to the read function as a constant value, that is, whatever needed modification to the index should be done at an earlier stage seperately, I'm not sure. I could use any hint please. |
|
|
SteveS
Joined: 27 Oct 2003 Posts: 126
|
|
Posted: Wed Mar 17, 2004 9:31 am |
|
|
If your LCD is basically working, you can debug with that. If you have the ICD you could step thru the code with that. I just happen to like debugging via RS232 - it's crude but works. If you have USB get a USB mouse or USB-232 converter - they are cheap. Every job is so much easier and enjoyable if you have the right tools.
Again, make the simplest code you can to divide the problem up. Try a small table without forcing its location and see if that works. Try accesing it with constant values if you think that may be it. Get some small victories.
- SteveS |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|