hello I am using lpc1768 with mbed 2 + rtos and I try to migrate it to MBED-0S 5.
all my code is compilng wth MBED-OS V5.15 (I am getting it from online compiler “blinky” and it seems the latest version 5.14.2 regarding commit of blinky code)
but I am facing problem when trying to ready my parameter file in LocalFileSystem
for that I got a snippet code on bug report on same pb and try to solve the situation but unsucessfully
***here is the sample code tested witl latest firmware 141212 and previous one 21164 ****
*** with same result ***
int hits; // hit counter
void write(){
_led2=1;
FILE *fp=NULL;
fp= fopen("/local/out.txt", "a"); // use the append to ADD data to the out.txt file
fprintf(fp,"test %d \r\n", hits); // add test + hit count to the out.txt file
fflush (fp);
//free(fp); // mbed-os reported but not working
fclose(fp);
_led2=0;
}
int main()
{
while(1){ // keep looping round wating for button press
if (hits<200)
{
_led3=1;
write();
_led3=0;
ThisThread::sleep_for(1000); // small delay for debounce
hits++; // increase hit counter
}
_led4=!_led4;
}
}
thanks a lot for your help
******* RESULTS ****
led1 is blinking rapidly and lowly all the time
led2-3-4 are light on
file is create “out.txt” on file system with 1 line “test 0”
serial port is getting report
-
MbedOS Fault Handler ++
FaultType: HardFault Context: R0 : 00000001 R1 : 10003A1C
R2 : 00000017
R3 : 74007478
R4 : 00000001
R5 : 10003A1C
R6 : 10003A4C
R7 : 00000000
R8 : 000028D1
R9 : 00000000
R10 : 00000000
R11 : 00000000
R12 : 01010101
SP : 10003A18
LR : 000035DD
PC : 000035E6
xPSR : 01000000
PSP : 100039F8
MSP : 10007FA0
CPUID: 412FC230
HFSR : 80000000
MMFSR: 00000000
BFSR : 00000000
UFSR : 00000000
DFSR : 0000000A
AFSR : 00000000
Mode : Thread
Priv : Privileged
Stack: PSP– MbedOS Fault Handler –
++ MbedOS Error Info ++ Error Status: 0x80FF013D Code: 317 Module: 255 Error Message: Fault exception Location: 0x234F Error Value: 0x35E6
Current Thread: main Id: 0x10002628 Entry: 0x1E17 StackSize: 0x1000 StackMem: 0x10002AD8 SP: 0x10007F3C
For more info, visit: mbedos-error
– MbedOS Error Info –