View previous topic :: View next topic |
Author |
Message |
Rohit de Sa
Joined: 09 Nov 2007 Posts: 282 Location: India
|
Nokia 6610 LCD + '877 code issue |
Posted: Sun May 22, 2011 11:58 am |
|
|
I'm having a funny problem; I don't really know what the root cause is. I think its because my code spills over into the next ROM page (ie memory used is over 2048 words), but I'm not sure.
This is my code: Code: | void main()
{
float angle;
int8 val;
int8 x;
char mystr[11];
glcd_init(80);
glcd_cls(black);
// other LCD functions
while(1)
{
glcd_line(65,73,65+51*(float)cos[x]/128,73+51*(float)sin[x]/128,yellow);
x++;
// other functions
}
} | I haven't shown a bunch of other things like declarations, and the 'other LCD functions' since I've kinda worked out with a fair degree of certainty that they are not the offenders. The 'sin' and 'cos' functions are look-up table based.
The code posted above works fine. It compiles to less than 2048 words. If I use any other function (or combination of functions) that causes compilation to exceed 2048 words, then execution simply hangs. Nothing displays on the LCD. I've not yet located where in the code the execution actually stalls, but I know that even the initialization (glcd_init) is not completed successfully.
I haven't posted complete code; if you'd like me to post the driver or anything else, let me know.
PIC16F877 (NOT 877A!) @ 20MHz
Nokia 6610 LCD (PCF8833)
CCS v4.106
Rohit |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun May 22, 2011 3:04 pm |
|
|
Try to #org your const tables in other Rom pages. Maybe that will free up
some room in your current ROM page:
http://www.ccsinfo.com/forum/viewtopic.php?t=880&start=1
In that example, I've tried to pack them tightly together with no ROM
space between them. But you don't have to do that. You can start each
table at some convenient address within a ROM page. |
|
|
Rohit de Sa
Joined: 09 Nov 2007 Posts: 282 Location: India
|
|
Posted: Mon May 23, 2011 3:48 am |
|
|
I've shifted the tables to the last ROM page by using a #org directive. However, even now if my code (not including the tables) is longer than 2048 words the PIC stays in reset.
I've tried sprinkling a bunch of #separate directives over a few of the functions to see if I could shift some of the memory hogs to other ROM pages, but no go.
I'm starting to get irritated now - why should the PIC stay in reset? Does the '877 have hardware issues? Stack problems, and such like? I have to use an '877 right now, because its the only PIC I have on hand. I've ordered a couple of newer 16F882s which will be arriving in a few days. If its a silicon bug, it'll show up then.
Rohit |
|
|
Rohit de Sa
Joined: 09 Nov 2007 Posts: 282 Location: India
|
|
Posted: Mon May 23, 2011 4:03 am |
|
|
UPDATE:
Ok, the code seems to 'work' if I break the driver into functions and allocate each function a memory area (using #org). Now this approach is fine for some functions, but the method fails for other functions, which are themselves built up of multiple sub-functions. This is leading me to think that the 877 has ROM page switching issues. Is there a way I can validate that _this_ itself is the issue?
Rohit |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon May 23, 2011 12:04 pm |
|
|
A quick test would be to revert to a previous compiler version.
Maybe try vs. 4.093. |
|
|
|