2017-11-27 03:55 AM
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 1But 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
2017-11-27 04:25 AM
Hello David, First verify the addresses with the datasheet. May errors in the header files also. And verify code generated by compiler.
2017-11-27 07:32 PM
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
2017-11-27 11:00 PM
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.
2017-11-29 04:40 AM
Hello,
Apparently to modify the register, we have to enable the SPI by writing the corresponding bit in CLK_PCKENR1 at 1.
After that we can modify the registers of the SPI.
Thank again for you consideration,
Regards
2017-12-08 11:45 AM
Hello David, I was think it as for granted. And I did not take into account the possibility of such a mistake.