ST意法半导体
直播中

蓝孝增

8年用户 173经验值
私信 关注
[问答]

如何错误的读取Cosmic序列

错误的读取Cosmic的序列

以上来自于谷歌翻译


以下为原文



Wrong regs reading sequence from Cosmic

回帖(2)

薛静斗

2019-7-12 14:10:43
指令(u16)(((u16)TIM1-> CNTRH<< 8)|(u16)(TIM1-> CNTRL))
 
在我看来有两侧左侧和右侧和编译器根据其转换为组装的规则将从右侧或左侧开始,或者在这种情况下它从右侧开始。
所以我认为最好将这条指令分成两条指令:
 
u16 uiTemp;
 
uiTemp =(u16)TIM1-> CNTRH<< 8);
uiTemp | =(u16)(TIM1-> CNTRL);
 
返回uiTemp;
 
它有点长,但它不会导致错误的阅读顺序
 
再见

以上来自于谷歌翻译


以下为原文




the instruction (u16)(((u16)TIM1->CNTRH << 8) | (u16)(TIM1->CNTRL))

In my opinion has Two side the left side and Right side and the compiler according to its rules of converting to assembly will begin from the right or from the left, in or case here it begin from the right.  
So I think it's better to seperate this instruction in two instructions :  

u16 uiTemp;  

uiTemp = (u16)TIM1->CNTRH << 8);  
uiTemp |= (u16)(TIM1->CNTRL);  

return uiTemp;  

it's a little bit long but it don't cause a wrong reading sequence  

ciao
举报

蓝孝增

2019-7-12 14:48:04
非常感谢COSMIC。
 
实际上,特定的构造线取自ST库stm8s_tim1.c,我希望按照标准C行为编写。
我也认为嵌入式联合是更好的方法。
ST应该被告知,并且重新发布了libriries。
 
非常感谢您的问候
弗朗切斯科

以上来自于谷歌翻译


以下为原文




Many thanks to COSMIC.

In fact the particular construct line was taken from the ST library stm8s_tim1.c, that I expected to be written in accordance with a standard C behaviour.  
I also think that the embedded union is the better way.  
ST should be informed about, and the libriries reissued.  

Many thanks again with regards  
Francesco
举报

更多回帖

发帖
×
20
完善资料,
赚取积分