float point type cast. JSR   _PACK_K_to_k_Unary; hangs

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

float point type cast. JSR   _PACK_K_to_k_Unary; hangs

Jump to solution
624 Views
d0ct0r
Contributor III

Hello,

 

I am using CW 10.2 to program JM60. In my project I need operations with float points.

For some uncertain reason, the type cast operation with float point types hangs within _FSFLOAT subrotine. Its works smooth till it reach JSR   _PACK_K_to_k_Unary; instruction. As far as I understood its exit from that subrotine.

 

Here is part of my code (functional):

 

double si_c11x1;

signed int TempCntdec, PressCntdec;

 

main ()

{

// This type cast works perfectly fine

PressCntdec = (signed int) (out[0] <<8 | out[1]);

TempCntdec = (signed int) (out[2] <<8 | out[3]);

 

// This type cast hangs

si_c11x1 = ((double) PressCntdec);

/-------------------------------------------------------

}

 

s1_c11x1 and PressCntdec declared as external variables with type "double". I even put them to MY_ZEROPAGE segment using #pragma.

But still no luck with this. Same behaviour if I am try to do any operations like multiplication or division. Example:

s1_c11x1 = PressCntdec/64.0;

 

Doesn anybody have a clue what is wrong with it ? I am using Small memory model. I tried to play with stack size (no luck). I diid check and ansifs.lib has assigned to the project.

 

Regards,

Vlad

Labels (1)
Tags (1)
0 Kudos
1 Solution
392 Views
d0ct0r
Contributor III

Eventually I made it work. But I sacrifice USB stack for now and all the interrupts. At least it helps to make float arithmetic works as it suppose to. Then I'll add that extra staff one by one and will see where the problem is. Thanks for valuable advises !

 

View solution in original post

0 Kudos
4 Replies
392 Views
CompilerGuru
NXP Employee
NXP Employee

Make sure you are linking the correct libraries you want, it has libraries for double as IEEE32 and as IEEE64.

The readme.txt in lib/hc08c describes the libraries and the needed command line options.

 

The most likely cause thought is that the stack is not big enough, that can cause any kind of weird behavior. Increase the stack size in the prm file and see if this fixes the behavior.

Also I would not expect that allocating doubles in the zero page helps much. Certainly not in the runtime routines as those are all working with 16 bit pointers to the values.

 

Daniel

0 Kudos
392 Views
d0ct0r
Contributor III

 

Thanks for the prompt response ! I got some progress.

 

I increased STACK from 0x80 to 0x180. I put variables within main(), I choose default EEEE64 instead of EEEE32

Now type cast is working. However, next line send me to this :

 

INIT_SP_FROM_STARTUP_DESC()

; /*lint !e960 MISRA 14.3 REQ, not a null statement (instead: several HLI statements) */

 

Here is code:

PressCntdec = (signedint) (out[0] <<8 | out[1]);

uiPadc=PressCntdec>>6;

si_c11x1 = ((double) uiPadc);

si_c11x1 *= myc11;

 

The last string (multiplication) send the program pointer  to the mentioned subrotine.

 

myc11 declared as 'const double' outside of main () to keep those variable in ROM, since its a constant.

 

Regards,

Vlad

0 Kudos
392 Views
BlackNight
NXP Employee
NXP Employee

Hello,

well, depending on what else is going on your system (interrupts, etc), the 0x100 additional bytes might not be enough.

Simply give it as much RAM as you have (say at least give it 0x200 or more), and then see what happens.

 

BK

0 Kudos
393 Views
d0ct0r
Contributor III

Eventually I made it work. But I sacrifice USB stack for now and all the interrupts. At least it helps to make float arithmetic works as it suppose to. Then I'll add that extra staff one by one and will see where the problem is. Thanks for valuable advises !

 

0 Kudos