Loading...
 

SW4STM32 and SW4Linux fully supports the STM32MP1 asymmetric multicore Cortex/A7+M4 MPUs

   With System Workbench for Linux, Embedded Linux on the STM32MP1 family of MPUs from ST was never as simple to build and maintain, even for newcomers in the Linux world. And, if you install System Workbench for Linux in System Workbench for STM32 you can seamlessly develop and debug asymmetric applications running partly on Linux, partly on the Cortex-M4.
You can get more information from the ac6-tools website and download (registration required) various documents highlighting:

System Workbench for STM32


Is SW4STM32 Little or Big Endian?

Hi All,

Pointers in C.

Is SW4STM32 Little or Big Endian? Which compiler decides GNU or the ARM Cross compiler?

example:
uint32_t TheDataItself = 0;
uint32_t *p32Data = &TheDataItself;
uint8_t *p8Data = (uint8_t*)p32Data;

Where does *p8Data point to? The MSB or the LSB of TheDataItself, a 4 byte unsigned integer as declared above.

(*p8Data+1) jumps the pointer 1 byte further. Correct?

Does (*p32Data+1) jump the pointer 3 bytes or 1 byte?

Greets,
Ben

PS: In everyone’s interest I solved my problem not exactly knowing the endian type. I threw a few trials and got what I wanted. See below. It’s about SPI only being able to shoot maximum 16 bits per transfer while I need at least 18 bit. Solved it by successfully splitting a 32 bit unsigned integer into two unsigned 16 bit integers. Still needed to create an uint8_t *pData for the HAL_SPI_Transmit()’s sake.


(...)

GPIOB->ODR |= 0x4000; // prepare PCM61P LE to HIGH

uint16_t cnt = 1;
uint32_t DAC_Word = 0;
uint32_t *p32Data = &DAC_Word; // p32Data is pointer to DAC_Word - assured both 32bit space!
uint16_t *p16Data = (uint16_t*)p32Data; // p8Data is pointer to p16Data!
uint8_t *p8Data = (uint8_t*)p32Data; // necessary for HAL_SPI_Transmit()

HAL_SPI_Transmit(&hspi2, p8Data, cnt, 10); // obligatory to prepare SPI hardware registers & flags

/* USER CODE END 2 */

/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */

for (DAC_Word=0;DAC_WordDR = *(p16Data+1); // most significan 16-bit word of DAC_Word
for (IdleTom=0;IdleTomODR |= 0x4000; // PCM61P LE to HIGH
SPI2->DR = *p16Data; // least significan 16-bit word of DAC_Word
for (IdleTom=0;IdleTomODR &= 0xBFFF; // PCM61P LE to LOW
}

/* USER CODE BEGIN 3 */

(...)


The HAL library might be easing a lot of work but it does some code bloating slowing down simple intentions. It’s a joy wading through it to look for the core instructions which are related to the MCU’s registers.

France

Hi Ben,

By default ARM is little-endian, whatever the compiler you use (its not the compiler who decides: its the MCU that works by default as little-endian but may be manually programmed to behave as big-endian for data).

In your example p8data raw value is the same as p32data, and it points to the first byte of a 32-bit value, which is the LSB in little-endian mode.

Regarding pointer arithmetic, its done in units of the size of the pointed-to items (that’s standard C semantics) so p8data+1 effectively increments the pointer raw value by 1 while p32data+1 increments it by 4 bytes.

Bernard (Ac6)