Skip to main content
Associate III
November 28, 2023
Solved

stm8, cpu register, cosmic

  • November 28, 2023
  • 2 replies
  • 1741 views

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.
    Best answer by Ans

    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
    November 28, 2023

    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
    November 28, 2023

    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.