Error Status: 0x80FF0144 Code: 324 Module: 255

Hello! I am trying to receive a command (in the form of a string) from a serial port from my laptop to a STNUCLEO-F767ZI development board, store that data, then use it to control the frequency of a blinking LED and the time it stays on. The first half of my code works; it can receive and store a string of numbers as integers. However, Mbed OS crashes whenever it gets past that. Using Arduino IDE’s serial monitor, this is what is printed when I send over the string ‘1005000’:

I got '1005000

Servo velocity: ‘100’
Servo time: ‘5000’

++ MbedOS Error Info ++
Error Status: 0x80FF0144 Code: 324 Module: 255
Error Message: Assertion failed: !(flags & osFlagsError)
Location: 0x800A403
File: .\mbed-os\rtos\source\Thread.cpp+176
Error Value: 0x0
Current Thread: main Id: 0x20005E0C Entry: 0x800B159 StackSize: 0x1000 StackMem: 0x20004868 SP: 0x200057C8
For more info, visit: mbedos-error
– MbedOS Error Info –

= System will be rebooted due to a fatal error =
= Reboot count(=5) reached maximum, system will halt after rebooting =⸮

This is my code; I used the empty Mbed 6 program template, and the only file I edited is main.cpp. I am using the latest version of Mbed Studio, and all of my tools are up to date.

/*

  • Copyright (c) 2020 Arm Limited and affiliates.
  • SPDX-License-Identifier: Apache-2.0
    */

#include “mbed.h”

// Create a serial object
using ThisThread::sleep_for;
static BufferedSerial pc(USBTX, USBRX);

//variables start

int onTime = 20;
int servoVelocity = 0;
int servoTime = 0;
int timeLeft = 0;

//variables end

//functions start
int arrayConcat (char array[], int
arrayStart
, int dataLength) {
int dummy = 0;
int dest = 0;
for (int i = 0; i < dataLength; i++) {
dummy = (array[i + arrayStart] - 48) * pow(10, dataLength - i - 1);
dest = dest + dummy;
}
return dest;
}

//functions end
int main(void)
{
//setup
pc.set_baud(9600);
char buffer[10] = {};
PwmOut servoXPin(LED1);
//setup end

while (1) {
    if (pc.readable()) {
        sleep_for(100ms);
        pc.read(buffer, 10);  //get data from pc and store it in buffer
        printf("I got '%s'\n\n", buffer);

        servoVelocity = arrayConcat(buffer, 0, 3);
        servoTime = arrayConcat(buffer, 3, 4);
        
        printf("Servo velocity: '%d'\n", servoVelocity);
        printf("Servo time: '%d'\n", servoTime);
    }

    while (timeLeft) {    
        servoXPin.period_ms(servoVelocity); 
        servoXPin.pulsewidth(.5f);
        timeLeft -= servoVelocity;
    }
    
    
    for (int i = 0; i <= 10; i++) {
        buffer[i] = {};     //clear buffer
    }
}

}

Hello,

I do not know, but your code is running and no crash occurred, only the behavior of LED is not like expected.

After some modification it is like I expected, but of course I do not know what exactly do you want to achieve.

//functions end
int main(void){
    //setup
    pc.set_baud(9600);
    char buffer[10] = {};
    PwmOut servoXPin(LED1);
    //setup end

    while (1) {
        if (pc.readable()) {
            sleep_for(100ms);
            pc.read(buffer, 10);  //get data from pc and store it in buffer
            printf("I got '%s'\n\n", buffer);

            servoVelocity = arrayConcat(buffer, 0, 3);
            servoTime = arrayConcat(buffer, 3, 4);

            printf("Servo velocity: '%d'\nServo time: '%d'\n", servoVelocity, servoTime);
            
            servoXPin = (float)servoVelocity/100; 
            memset (buffer,0,sizeof(buffer));
        }
        if(servoVelocity > 0){
            timeLeft = servoTime;
            while (timeLeft) {    
                timeLeft-=100;
                sleep_for(100ms);
            }
            servoXPin = 0;
        }
    }
}

BR, Jan

What settings/Mbed versions are you using? In this code, I send a string of 7 numbers: the first 3 numbers are to be interpreted as the period (in milliseconds) of a PWM pin while the latter 4 numbers are to be interpreted as the time the PWM stays active. I will try running your code on my end to see if it will work.

The latest 6.15.1.

I got '1005000
'

Servo velocity: '100'
Servo time: '5000'

I got '0101000
'

Servo velocity: '10'
Servo time: '1000'

I got '0505000
'

Servo velocity: '50'
Servo time: '5000'

BR, Jan

Using your code, the program doesn’t crash anymore; however, I still cannot get the PWM pin to stop flashing. I think at this point my issue has been resolved. Thanks for your help!

It is working in my case.

BR, Jan