Using FreeRTOS v10.2.1 and FreeRTOS+TCP v2.0.11
grafted onto an STM32CubeIDE Project
Using STM32F407ZE
OK I’m probably doing something stupid, but I had firmware that was working fine until I put some floating point math in it.
quick rundown, I have this board, it has an Ethernet port it and uses ADC1 to read an analog pressure sensor. I’m converting the ADC counts to a KPA value to send back to the computer. its a simple ADC
COUNT / COUNTSPER_KPA.
the ethernet listens on a port using FreeRTOS+TCP receives a command to do something, processes command then returns the result. one of my commands is get pressure, where I do the ADC->kPa conversion and send it back. this works fine, until the client disconnects then the firmware gets locked at:
configASSERT( ( pxLink->xBlockSize & xBlockAllocatedBit ) != 0 );
in heap_4.c line 278
stack is:
vPortFree() at heap_4.c
prvDeleteTCB() at tasks.c
prvCheckTasksWaitingTermination() at tasks.c
prvIdleTask() at tasks.c
pxPortInitiaseStack at port.c
–end–
upon removing any calls to floating point math, the code runs without problems, and dumps the task accordingly. I was unable to recreate the problem on a new project with no TCP/IP so it may be related to that (FreeRTOS+TCP)?
Thanks for any input I get on this.
below is crapy pseudocode that is similar to what im doing
Pseudo code:
~~~
define COUNTSPERKPA 0.00811f
float adcTokPa(uint16
t advvalue) {
return ((float)adc
value)/COUNTSPER_KPA;
}
void send
response(Sockett client,float value) {
FreeRTOS_Send(client,&value,sizeof(float),0);
}
void connection
handler(void *params) {
Sockett *client_ptr = (Socket_t * )params;
Socket_t client = *client_ptr;
uint16_t cmd;
for(;;) {
bytesRecv = FreeRTOS_recv(client,&cmd,sizeof(uint16_t),0);
if(bytesRecv != sizeof(uint16_t)) {
if( bytesRecv < 0 ) {
//Some kind of Socket Error
//shutdown FreeRTOS Socket
vTaskDelete(NULL); //Should delete this connection handler
}
} else {
switch(cmd) {
//
case 42:
send_response(client,adcTokPa(adv_value));
break;
default:
break;
}
}
}
}
void listen
task(void * params) {
for(;;) {
Sockett client = FreeRTOS
Accept();
xCreateTask(connectionhandler,”ConHandle”,128,&client,CON
TASKPRIO,NULL);
}
}
~~~
}