cancel
Showing results for 
Search instead for 
Did you mean: 

stm8, cpu register, cosmic

MykolaLevun
Associate III

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

 

1 ACCEPTED SOLUTION

Accepted Solutions
Ans
Associate III

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/

View solution in original post

2 REPLIES 2
Ans
Associate III

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/

SofLit
ST Employee

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 on "Accept as Solution" on the reply which solved your issue or answered your question.