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?

  • The whole point of the 'C' programming language is that it is not different for STM32 than for any other target.

    The way you allocate variables is not specific to the target.

    This is very basic 'C' stuff.

    I would recommend that you start by learning 'C' basics on a PC rather than on an embedded microcontroller.
    Once you have mastered the basics on a PC, then you can move on to the added complications for cross-development to an embedded target.

    Here are some 'C' learning & reference materials to get you started - including a free online textbook:

    blog.antronics.co.uk/.../

  • 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.

  • Hello Karol,

    You can find a link to "The Definitive Guide to ARM® Cortex®-M3 and Cortex®-M4 Processors, Third Edition " and other good resources at:

    keil.com/books

    In the "ARM Microcontroller" section.

    The "Definitive guide..." has a great section on bit banding.

    ====

    Also, search on Youtube for "bit banding". There is a decent video here:

    www.youtube.com/watch