完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛|
X寄存器是否可用于写入tiMx_CCRyH / L寄存器?
以上来自于谷歌翻译 以下为原文 Is X register available for writing TIMx_CCRyH/L registers ? |
|
相关推荐
4个回答
|
|
|
我正在研究PWM输出的用法。我找到了一个代码,用于在FWLib源代码stm8s_tim3.c的TIM3_OC2Init函数中写入TIM3_CCR2H / L寄存器。源代码对定时器寄存器执行两次8位写操作,如下所示。
/ *设置脉冲值* / TIM3-> CCR2H =(u8)(TIM3_Pulse> 8); TIM3-> CCR2L =(u8)(TIM3_Pulse); 我认为当写操作被描述为一个16位写操作时,程序会更简单,如下所示。 volatile u16 TIM3_CCR2 @ 0x00532F; : TIM3_CCR2 =(u16)TIM3_Pulse; 但是使用16位变量写入定时器寄存器的程序已经失败,但是该行肯定被编译成源自X寄存器的LDW指令。 为什么这个程序失败了? LDW指令的WRITE操作顺序是否与定时器寄存器的预期不同? --- noritan.org [此消息由:st16于10-01-2010 15:34编辑] 以上来自于谷歌翻译 以下为原文 I am investigating the usage of the PWM output. I found a code to write the TIM3_CCR2H/L registers at the TIM3_OC2Init function of the FWLib source code stm8s_tim3.c The source code behaves two 8-bit write operations for the timer registers as follows. /* Set the Pulse value */ TIM3->CCR2H = (u8)(TIM3_Pulse >> 8); TIM3->CCR2L = (u8)(TIM3_Pulse); I assumed that the program would be more simple when the write operation is described as one 16-bit write operation like following. volatile u16 TIM3_CCR2 @ 0x00532F; : TIM3_CCR2 = (u16)TIM3_Pulse; But the program using a 16-bit variable to write the timer register has been failed, however the the line is certainly compiled into an LDW instruction sourced from X register. Why this program has been failed ? Is the WRITE operation order of the LDW instruction different from what the timer register expected ? --- noritan.org [ This message was edited by: st16 on 10-01-2010 15:34 ] |
|
|
|
|
|
嗨,
我认为这是一种安全机制,它首先在CCR1H之前写入CCR2H寄存器。 问候 阿尼斯 以上来自于谷歌翻译 以下为原文 Hi, I think that is a security mechanism that is consist to write first the CCR2H register before the CCR1H. Regards Anis |
|
|
|
|
|
嗨,阿尼斯,
你是对的,参见参考手册pag。 161第17.5.1段(适用于TIM1,但对其他计时器也有效)。在8位微控制器上,这种读写机制保护通常用于16位或10位寄存器的r / w访问,如ADC转换值的情况。 布拉佐夫 |
|
|
|
|
|
嗨,阿尼斯,布拉佐夫
我假设该机制是出于安全原因而许多其他具有16位定时器的8位MCU具有相同类型的机制。 STM7是合理的,因为STM7只有8位寄存器。 但是STM8有16位寄存器X和Y.我想知道为什么固件库仍然使用对16位定时器寄存器的8位访问,以及为什么STM8在16位X访问16位寄存器时会失败寄存器。 --- noritan.org 以上来自于谷歌翻译 以下为原文 Hi Anis, brazov I assumes that the mechanism is for security reason and many other 8-bit MCU with 16-bit timer have same kind of one. It is reasonable for STM7 because STM7 has 8-bit registers only. But STM8 has 16-bit registers X and Y. I wonder why the firmware library is still using 8-bit access to the 16-bit timer registers and why STM8 will fail if access to the 16-bit register by the 16-bit X register. --- noritan.org |
|
|
|
|
只有小组成员才能发言,加入小组>>
stm32mp157的异核通信的rpmsg_sdb的m4固件和a7驱动该如何编写?
1453 浏览 0 评论
stm32f103用freertos对一个采样率为1kHz的传感器,进行采样,数据出差
1502 浏览 0 评论
请教:在使用UDE STK时,单片机使用SPC560D30L1,在配置文件怎么设置或选择?里面只有SPC560D40的选项
3649 浏览 1 评论
3842 浏览 1 评论
请问是否有通过UART连接的两个微处理器之间实现双向值交换的方法?
2461 浏览 1 评论
STM32H7打开DCache后,出现了串口接收信息为空的现象,是哪里出了问题?
727浏览 5评论
用NANO STM32F103RBT6的开发板烧录不了是哪里出了问题?
663浏览 5评论
710浏览 5评论
外部中断触发类型为双边沿触发,进入中断回调后有什么办法判断该边沿是上升沿还是下降沿?
941浏览 5评论
STM32L071CBT6低温环境下无法正常工作是什么原因引起的?
745浏览 5评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-2 11:49 , Processed in 0.664236 second(s), Total 76, Slave 59 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
472