完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
大家好,
我正在研究STM8AL3166并尝试修改SPI寄存器。 我的简单代码如下: int main(){ SPI_CR1 | = 0b00100100; / *配置为主设备和500 kHz com速度 } 正如数据表中所读,我用正确的地址创建了一个library.h: // STM8AL3166 SPI寄存器 #define SPI_CR1 *(unsigned char *)0x5200 // SPI控制寄存器1但是当我进入调试会话时,寄存器在执行指令后不会改变其值 有人遇到过这个问题吗?例如,当我对GPIO端口A执行相同操作时,我没有问题。 我可能在某个地方错过了一个配置吗? 请帮忙。 感谢您的时间, 大卫 以上来自于谷歌翻译 以下为原文 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 |
|
相关推荐
5个回答
|
|
大卫你好,首先用数据表验证地址。也可能是头文件中的错误。并验证编译器生成的代码。
以上来自于谷歌翻译 以下为原文 Hello David, First verify the addresses with the datasheet. May errors in the header files also. And verify code generated by compiler. |
|
|
|
你好维亚切斯拉夫,
谢谢你的回复。 我仔细检查了地址值,它是正确的。 头文件正在编译而没有任何错误,而且,我知道语法很好,因为我可以用我的代码修改GPIO寄存器。 '验证码生成'是什么意思?在构建日志中,如果您正在寻找,我没有任何警告也没有错误 在调试会话中,除了GPIO之外,我无法自由修改寄存器的值。当我更改一个值时,复位值由芯片自动设置。之后,似乎我对uP的每个寄存器都有这个问题。他是处于封锁模式还是类似的东西?现在我只想修改一个寄存器.. 感谢您的帮助, 大卫 以上来自于谷歌翻译 以下为原文 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 |
|
|
|
我的意思不是编译器没有错误和警告。我的意思是二进制指令代码的正确性。一切都应该有效,但不起作用。我在编译器的头文件和逻辑中反复遇到错误。唉。但是,我认为原因是别的。尝试另一个芯片或调试器。也许有些事情发生了故障。
以上来自于谷歌翻译 以下为原文 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. |
|
|
|
你好,
显然要修改寄存器,我们必须通过将CLK_PCKENR1中的相应位写为1来使能SPI。 之后我们可以修改SPI的寄存器。 再次感谢您的考虑, 问候 以上来自于谷歌翻译 以下为原文 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 |
|
|
|
大卫你好,我认为这是理所当然的。而且我没有考虑到这种错误的可能性。
以上来自于谷歌翻译 以下为原文 Hello David, I was think it as for granted. And I did not take into account the possibility of such a mistake. |
|
|
|
只有小组成员才能发言,加入小组>>
请教:在使用UDE STK时,单片机使用SPC560D30L1,在配置文件怎么设置或选择?里面只有SPC560D40的选项
2738 浏览 1 评论
3241 浏览 1 评论
请问是否有通过UART连接的两个微处理器之间实现双向值交换的方法?
1810 浏览 1 评论
3650 浏览 6 评论
6039 浏览 21 评论
1339浏览 4评论
202浏览 3评论
对H747I-DISCO写程序时将CN2的st-link复用为usart1,再次烧录时无法检测到stlink怎么解决?
353浏览 2评论
STM32G474RE芯片只是串口发个数据就发烫严重是怎么回事?
444浏览 2评论
STM32处理增量式编码器Z信号如何判断中断是正转的还是反向转的?
275浏览 2评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-25 21:43 , Processed in 1.156586 second(s), Total 87, Slave 70 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号