Skip to main content
Explorer
November 28, 2023
Solved

stm8, cpu register, cosmic

  • November 28, 2023
  • 2 replies
  • 1526 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

    AnsAnswer
    Graduate
    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/

    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.