Skip to main content
Associate III
November 28, 2023
Solved

How to access STM8 cpu registers

  • November 28, 2023
  • 1 reply
  • 1414 views

Hello

How can I access STM8S CPU registers (Cosmic compiler)? When I write this "A = 0xff" (A is a processor register accumulator), then compiler writes this "#error cpstm8 main.c:17(3) A undefined". How to fix it?

    This topic has been closed for replies.
    Best answer by mƎALLEm

    Hello,

    You need to access internal CPU registers with assembly language. You can insert asm code inside C code.

    See https://www.cosmicsoftware.com/pdf/cxstm8_pd.pdf / page 2.

    PS: this thread is the duplication of this one: https://community.st.com/t5/stm8-mcus/stm8-cpu-register-cosmic/td-p/614181

    1 reply

    mƎALLEm
    mƎALLEmBest answer
    ST Technical Moderator
    November 28, 2023

    Hello,

    You need to access internal CPU registers with assembly language. You can insert asm code inside C code.

    See https://www.cosmicsoftware.com/pdf/cxstm8_pd.pdf / page 2.

    PS: this thread is the duplication of this one: https://community.st.com/t5/stm8-mcus/stm8-cpu-register-cosmic/td-p/614181

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