Skip to main content
Visitor II
November 27, 2017
Question

Modify SPI register

  • November 27, 2017
  • 1 reply
  • 1299 views
Posted on November 27, 2017 at 12:55

Hello Everyone,

I am working on the STM8AL3166 and try modify the SPI register. 

My simple code is as below :

int main() {

   SPI_CR1 |= 0b00100100;      /* Configure as master and 500 kHz com speed

}

As read in the datasheet, I made a library.h with the correct address :

//STM8AL3166 SPI REGISTER

#define SPI_CR1 *(unsigned char*) 0x5200       //SPI Control Register 1   

But when I go in the debug session, the register does not change his value after executing the instruction

Is someone has encountered this problem? When I do the same for GPIO port A for instance, I have no problem.

May I am missing one configuration somewhere?

Please help.

Thank you for your time,

David

    This topic has been closed for replies.

    1 reply

    Visitor II
    November 27, 2017
    Posted on November 27, 2017 at 13:25

    Hello David, First verify the addresses with the datasheet. May errors in the header files also. And verify code generated by compiler.

    david.yeAuthor
    Visitor II
    November 28, 2017
    Posted on November 28, 2017 at 03:32

    Hello Vyacheslav,

    Thank you for replying.

    I double checked the address value and it is the correct one.

    The header file is compiling without any errors and also, I know that the syntax is good because I can modify the GPIO register with my code.

    What do you mean by 'verify code generated'? In the build log I have no warning and no errors if this is what you are looking for

    In debugging session, I cannot freely modify the value of the registers except for the GPIO ones. When I change a value, the reset value is automatically set by the chip. Afterwards, it seems that I have this problem for every register of the uP. Is he in a blocked mode or something like that? For now I just want to modify a register..

    Thank you for the help,

    David

    Visitor II
    November 28, 2017
    Posted on November 28, 2017 at 07:00

    I meant not the absence of errors and warnings from the compiler. I mean the correctness of the binary instructions code. Everything should work but does not work. I repeatedly encountered errors in the headers and logic of compilers. Alas. However, I think that the reason is something else. Try another chip, or a debugger. Maybe something is malfunctioning.