Thanks for reading this. I am using FreeRTOS 9.0.0 on Zynq ZC702 and trying to implement a binary TCP server on port 7081. Using FreeRtos Labs 160919 and Xilinx SDK 2016.3
Everything goes fine, unless you try to assign a value to a float, then FreeRTOS crashes.
I have already set:
"#define configUSETASKFPU_SUPPORT 2", in FreeRTOSConfig.h
The code snippet that crashes FreeRTOS is:
static uint8t counter;
counter = 1;
UL1_RMS = (float)counter;
Is there anything more that should be configured in order to handle float values in a task?
Thanks in advance for your help.
Your post is a bit similar to this one.
Can you try the same conversion somewhere in
main(), just before calling
vTaskStartScheduler()? Will that also crash?
Does the problem also occur when using
In addition - does this problem occur inside an interrupt? There is a
known issue with alignment for floats in V9.0.0. If this is the case
please either make the assignment outside of the ISR, or get back to me
and I can let you know the fix.
Hi Hein and RTE,
Thank you very much for your answer, I will try to explain more in detail the problem:
The binary parser I am trying to implement on port 7081 is quite similar to the one implemented in FreeRTOS labs for the echo server:
- There is a server listening for incomming connections to port 7081
- When there is a new connection it spawns a task to handle it
- The handler decodes the command and then answer back the data, result, etc.
There is not any interrupt involved in my code, unless the handling of sockets in FreeRTOS is interrupt driven???
Here is the structure I am filling with values inside the task that handle values:
char Ip0; // 1
char Ip1; // 2
char Ip2; // 3
char Ip3; // 4
Then when you handle this inside the task:
Assign and address to pointer:
StandardInfo_p = (StandardInfo_t *)FIRST_BYTE_ANSWER_PTR;
Then assing a value to the elements inside the structure:
counter = 1;
StandardInfo_p->Ip0 = (char)counter;
StandardInfo_p->Ip1 = (char)counter;
StandardInfo_p->Ip2 = (char)counter;
StandardInfo_p->Ip3 = (char)counter;
Everything is OK until you start assigning a value to float, then it crashes:
StandardInfo_p->UL1_RMS = (float)counter;
StandardInfo_p->UL2_RMS = (float)counter;
StandardInfo_p->UL3_RMS = (float)counter;
When using another commands that do not use floats everything is OK.
Thanks again for your help.
What is the value of FIRSTBYTEANSWER_PTR? It must be a value that
results in your floating point variables within the structure being
8-byte aligned. I don't think this is a FreeRTOS issue.
Thank you very much for your help, you are right.
That's the value of FIRSTBYTEANSWER_PTR where pucTxBuffer was allocated previously.
That resulted in floats not been 8-byte aligned:
define SIZEOFHEADER 4
define SIZEOFANSWER 3
define FIRSTBYTEANSWERPTR ((uint8t *)(pucTxBuffer + SIZEOFHEADER + SIZEOFANSWER))
Thanks again, best regards,