Renesas V850 port not supporting preserving FPU registers. Ideas please.

acollins22 wrote on Wednesday, May 02, 2018:

Hello,

I am working on an existing project based on the Renesas V850E2.

Occasionally I see a problem where a task’s floating point maths goes awry. Looking at the assembler code produced by the IAR C compiler I can see a point where, if a context switch occurred, it could cause this problem.

Looking into the portSAVE_CONTEXT and portRESTORE_CONTEXT macros in portasm.s85 for my port, I can’t see any attempt to save the FPU registers and I think this is the root cause of my problem.

The top of portSAVE_CONTEXT looks like this…

    prepare {r20,r21,r22,r23,r24,r25,r26,r27,r28,r29,r30}, 76 ,sp ; save general purpose registers
    sst.w   r19,72[ep]
    sst.w   r18,68[ep]
    sst.w   r17,64[ep]
    sst.w   r16,60[ep]

I need to modify it to save the FPU registers. I have tried increasing the amount of memory reserved by the prepare instruction to make space for my additions but the system won’t run afterwards so I am clearly doing something wrong and my V850 assembler knowledge isn’t strong enough yet to know what it is.

Has anyone used freeRTOS on a V850E3 or any other V850 with the FPU and has some code they could share please?

Thanks,

Andy.

rtel wrote on Wednesday, May 02, 2018:

Unfortunately I don’t think the device that port was written for even
had an FPU unit.

Did you also update pxPortInitialiseStack() in the V850 version of port.c?

acollins22 wrote on Wednesday, May 02, 2018:

Thank you Richard,

I wasn’t aware of pxPortInitialiseStack.

I’ll give that a try.

Thanks again,

Andy.