Darrel,
Thanks so much for your help. I've got it displaying the large values perfectly.
Eric
Darrel,
Thanks so much for your help. I've got it displaying the large values perfectly.
Eric
Hi!
I have been away from PIC and PICbasic world over one and a half year now. However, I'm back again and run to a really strange thing. I have slightly over 28 k code where I need 36 bits for calculations, so I found that wonderful N-bit_Math (just beautiful). There is however, something strange going on.
the code for N-bits is as suggested by Darrel. And compiles without errors and warnings, as long as .... here is the code:
There are three comments (A,B and C). Depending on what combination you have will give different results for the compilation. As it is "now", SetPoint not involved, it compiles OK.Code:PRECISION CON 5 SYSTEM ' 5*8 = 40 bits, byte size for registers include "N-Bit_Math.pbp" define OSC 48 ' used clock frequenze SetPoint VAR BYTE[PRECISION] Position VAR BYTE[PRECISION] Error VAR BYTE[PRECISION] Current VAR BYTE[PRECISION] MyVar VAR BYTE[PRECISION] by var byte wo var word LHi var word LMi var word LLo var word LHi = $7: LMi = $2174: LLo = $6FD9 for by = 0 to 4 select case by case 0,1 : wo = LLo case 2,3 : wo = LMi case 4 : wo = LHi end select ' SetPoint[2] = wo & $FF 'A if (by & 1) = 0 _ then by= by ' SetPoint[by] = wo & $FF ' B else by=by ' SetPoint[by] = wo >> 8 ' C endif next by @ MATH_DIV _SetPoint, _Position, _Error
If I enable A then there are two warnings one saying both in the .mac file and ..pbppic18.lib file that "Address exceeds maximum range for this processor".
If I enable B and/or C without A then there is one Error (126) in pbppic18.lib saying "argument out of range (32816 not between 0-32767) and bunch of warnings, all saying "Address exceeds maximum range for this processor" in .lib and .mac files.
If I copy that to a new file and compile it then there are no problems to compile it.
I have been looking around the rest of the code to found something strange but can not image what it would be.
I'm using PicBasic pro 2.50b, MPASM and target is 18F4550.
The real question is:
What can in a code (the rest of it), what could make the compiler to act like that. Any ideas ?
Any suggestion what to look for? Please help....
If you un-comment B or C, then you end up with invalid statements.
But in general, it looks like your program is larger than the chips memory.
No way to know with only a snippet of your code.
And, it would be easier to load the SetPoint this way ...Code:@ MOVE?CP 21746FD9h, _SetPoint SetPoint(4) = 7
DT
Thanks Darrel,
chips memory should be 32k (18F4550) and within the IF statement only two times by = by and not any SetPoint "statements" then the compiled size is 28692 bytes. That is the strange thing here, how can one explain that?
I tested this:
@ MOVE?CP 21746FD9h, _SetPoint
SetPoint(4) = 7
no problems, once,
BUT
when there more than one then the problems are "familiar"from those earlier mentioned. It seems that .... only guessing, that the compiler is allergic to SetPoint
![]()
of course not so, but again there is something here that I do not grasp...
OR
do I miss something from the hole picture here
Here is the code with more @ MOVE?CPs:
Code:@ MOVE?CP 21746FD9h, _SetPoint SetPoint(4) = 7 @ MATH_DIV _SetPoint, _Position, _Error @ MOVE?CP 21756FD9h, _SetPoint SetPoint(4) = 6 @ MATH_DIV _SetPoint, _Position, _Error @ MOVE?CP 21766FD9h, _SetPoint SetPoint(4) = 5 @ MATH_DIV _SetPoint, _Position, _Error @ MOVE?CP 21776FD9h, _SetPoint SetPoint(4) = 4 @ MATH_DIV _SetPoint, _Position, _Error
There's no way for me to tell what's happening, since your snippets all compile.
If I had your whole program, maybe I could see what's going on.
DT
Thanks Darrel,
the hole program is big, but here it is attached:
Maybe you can see with one small glance what is the cause of the error, the origin (that is me, but...). I sure wish to find the problem, what is causing this mysterious behavior.
Nevertheless, maybe you can see the problem with one glance...
I don't think the file was accepted.
Try adding a .txt extension.
DT
Bookmarks