Skip to main content
Associate III
Nov 28, 2023 11:22 AM UTC
Solved

stm8, cpu register, cosmic

Hello

 

How can I access CPU registers using the Cosmic compiler?

For example, when I access register A, the compiler throws an error A is undefined (This is shown in the picture and also the project files).

 

picture.png

 

    This topic has been closed for replies.
    AnsBest answer
    Associate III
    Nov 28, 2023 1:13 PM UTC

    You've to define address for any register. Check datasheet and see what's the address of A register and then define it accordingly. 
    Checkout this guide: https://lujji.github.io/blog/bare-metal-programming-stm8/

    2 replies

    AnsBest answer
    Associate III
    Nov 28, 2023 1:13 PM UTC

    You've to define address for any register. Check datasheet and see what's the address of A register and then define it accordingly. 
    Checkout this guide: https://lujji.github.io/blog/bare-metal-programming-stm8/

    mƎALLEm
    ST Technical Moderator
    Nov 28, 2023 1:21 PM UTC

    Hello,

    If "A" is a an internal core register you need to access it in assembly language.

    If "A" is a peripheral register you need to define the address of "A" and access it by pointer in C.

    To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.