cancel
Showing results for 
Search instead for 
Did you mean: 

In sprintf gives a hardfault when a fixed string is printed to a buffer in seperate section with cache/dcache disabled.

PeterKwek
Associate II

Controller H743Zi (nucleo-H743ZI2)

STM32CubeIde : 1.4.2

Cube V1.8.0

cache: enabled

dcache: enabled

Seperate RAM Section with cache/dcachedisabled by MPU region

FreeRtos: CMSIS V1 10.21 / 1.02

// methode 1

uint8_t buffer[100]; //MPU region cache/dcache disabled

int length = sprintf((char*) buffer, "Test\r\n");

length += sprintf((char*) buffer+ length, "Test\r\n"); //this line FAIL

// methode 2

SECTION_CACHE_DISABLED uint8_t buffer[100]; //MPU region cache/dcache disabled

int length = sprintf((char*) buffer, "Test\r\n");

length += sprintf((char*) buffer+ length, "%d\r\n", “Test�?); //this line does NOT FAIL

//methode 3

uint8_t bufferRam[100]; // cache / dcache enabled

int length = sprintf((char*) bufferRam, "Test\r\n");

length += sprintf((char*) bufferRam + length, "Test\r\n"); //this does NOT FAIL

length += sprintf((char*) bufferRam + length, "%d\r\n", “Test�?); //this does NOT FAIL

Why does methode 1 fail?

0 REPLIES 0