This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

what type of data should I choose?

Hello

I have a program written in assembler for 8051, I need to change it to a program in C for STM32F103. The old program has symbols for individual bytes in memory. e.g

in NFL byte:
SAVED EQU 18H; SAVED = 1 when state was saved
PRG EQU 19H; PRG = 1 when PROGR = 1
BWK EQU 1AH; BWK = 1 when FM = 1
PLUS EQU 1BH; button was '+' pressed
MINUS EQU 1CH; button was '-' pressed
FMERR EQU 1DH; FMERR = 1 when the FM memory is not resp.
Inoc EQU 1EH; Inoc = 1 the minimum brightness of the LED

Does the C language for STM32 also have an equivalent mechanism that allows access to individual memory bits in a similar way to 8051?

Parents
  • Bit level stuff on 8051 is achieved through non-standard C extensions.

    Bit level stuff on CM3/CM4 can be done via Bit-Banding which shadows a bit level version of another area and performs Read and RMW on that. Complex, and honestly not super efficient. Best used on SRAM, on peripherals is isn't sufficiently atomic to be safe in all circumstances.

    Portability of 8051 bit manipulation, and Cortex bit-banding not very portable, and perhaps best avoided unless specific use case is strong and localized.

    ARM implementations tend to have significantly large memory spaces, and peripheral register spaces, not really like 8051 SFR

    Would suggest thumbing through a copy of one of Joseph Yiu's Essential Cortex-Mx books, to apprise yourself of the part you're working with.

Reply
  • Bit level stuff on 8051 is achieved through non-standard C extensions.

    Bit level stuff on CM3/CM4 can be done via Bit-Banding which shadows a bit level version of another area and performs Read and RMW on that. Complex, and honestly not super efficient. Best used on SRAM, on peripherals is isn't sufficiently atomic to be safe in all circumstances.

    Portability of 8051 bit manipulation, and Cortex bit-banding not very portable, and perhaps best avoided unless specific use case is strong and localized.

    ARM implementations tend to have significantly large memory spaces, and peripheral register spaces, not really like 8051 SFR

    Would suggest thumbing through a copy of one of Joseph Yiu's Essential Cortex-Mx books, to apprise yourself of the part you're working with.

Children
No data