|
|
View previous topic :: View next topic |
Author |
Message |
chava
Joined: 07 Sep 2003 Posts: 56
|
ram in pic16c57c |
Posted: Mon Mar 15, 2004 2:17 pm |
|
|
Hello
I use pic16c57c ( yes, yes, still somewhere around the globe people use stone-age-tools)
I have a function that should do:
long x,y // 0 < x,y <1500
int32 result;
result=(x*1000)/y
I tryed several ways, including unions and so, to reduce ram use but I couldnt, the "not enough ram" error message keeps bugging me.
does anyone has an idea?
chava [email protected] |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Mar 15, 2004 2:31 pm |
|
|
Piclist has an ASM code generator that might be useful.
http://www.piclist.com/techref/piclist/codegen/constdivmul.htm
Just set it for 16-bit register size, multiply by 1000, and error = 0.
Also, CCS used to publish ASM routines for 32-bit math.
To find this code, go to http://www.google.com and search for this:
mul32 add32 CCS
Then click on the link for "cached" (not the main link - it won't work).
You'll see the code. |
|
|
Ttelmah Guest
|
Re: ram in pic16c57c |
Posted: Mon Mar 15, 2004 2:54 pm |
|
|
chava wrote: | Hello
I use pic16c57c ( yes, yes, still somewhere around the globe people use stone-age-tools)
I have a function that should do:
long x,y // 0 < x,y <1500
int32 result;
result=(x*1000)/y
I tryed several ways, including unions and so, to reduce ram use but I couldnt, the "not enough ram" error message keeps bugging me.
does anyone has an idea?
chava [email protected] |
Obvious question. Have you used *=16 in the device statement?.
Though the chip only has 72 bytes of RAM, it is organised in four pages, so the long pointers are needed to access more than than 24 bytes.
Best Wishes |
|
|
chava
Joined: 07 Sep 2003 Posts: 56
|
I did and... |
Posted: Mon Mar 15, 2004 3:59 pm |
|
|
Hi Ttelmah, thank you for your attention
I did
#device *=16
but an error message applyed:
"Extra characters on preprocessor command line"
so I did
#device *=8
this compiled but in the watch window I dont see all the bits of the value(the int32 value)
here is what I did:
long x=0,y=0;
int32 result=0;
x=500;y=600;
result=1000*x;
result=result/y;
but in the watch I see: result = 0x0000A120 instead of 0x00007A120
do you have a clue why?
I set the property of this variable ( in the watch window) to hex, high:low, 32 bit |
|
|
chava
Joined: 07 Sep 2003 Posts: 56
|
did it !!!! |
Posted: Mon Mar 15, 2004 4:07 pm |
|
|
did it !!!!!! thanks
|
|
|
Ttelmah Guest
|
Re: I did and... |
Posted: Mon Mar 15, 2004 4:19 pm |
|
|
chava wrote: | Hi Ttelmah, thank you for your attention
I did
#device *=16
but an error message applyed:
"Extra characters on preprocessor command line"
so I did
#device *=8
this compiled but in the watch window I dont see all the bits of the value(the int32 value)
here is what I did:
long x=0,y=0;
int32 result=0;
x=500;y=600;
result=1000*x;
result=result/y;
but in the watch I see: result = 0x0000A120 instead of 0x00007A120
do you have a clue why?
I set the property of this variable ( in the watch window) to hex, high:low, 32 bit |
I think you need to talk to CCS. The chip is an 'oddity', in that it is a 16 family device, that compiles with the PCB compiler (12bit instruction code). Technically, the PCB compiler does not support more than 5bit pointers (allowing a maximum of 32 RAM addresses to be accessed). If you load the 'symbol map', you will find that the pointer size is being reported as 5bit. Yet the include' file for the chip refers to the 72 RAM locations...
You can (should be able to) access memory beyond the limits, using the 'read_bank', and 'write_bank' functions, so it is possible that you could get the code to work, if you moved some of your other (int) variables into one of the higher banks, and accessed them with this function. It might (just) free enough RAM to make it work. However CCS should really fix this fault, so that the full RAM can be accessed on the chip.
Best Wishes |
|
|
chava
Joined: 07 Sep 2003 Posts: 56
|
make32 |
Posted: Tue Mar 16, 2004 7:09 am |
|
|
Hi Ttelmah
I solved it by using the make32 function:
Code: | long x=200;
int32 result;
result=make32(0,x)*1000; |
However, when I run this code at my computer it run as expected-good, but when I came to work today , and put this code part in a program, something strange happen:
when the debugger reaches the line of the multipication, it enters an endless loop. I press f9, the debugger run for a while, and then returns to that line again, so that it executing this line over and over.
do you have an idea of what's wrong? |
|
|
|
|
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
|