完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
你好!注意到:使用定时器=PLBIZTMRYOR32比特(TMRA ID2);由于两个不同的计时器的两个16位读不涉及到一个32位的优化,可能会导致问题。Mr Iday2)-Gt;TMRx,它运作良好。有其他人看到这个问题吗?我认为这是PLIB实现中的一个错误。
以上来自于百度翻译 以下为原文 Hi! just noticed that using: timer = PLIB_TMR_Counter32BitGet(TMR_ID_2); can cause problems due to the two 16 bit reads to the two different timers involved not beeing optimized into one 32 bit. I see frequent inconsistent results. However if I hand-code the access: timer=((volatile tmr_registers_t*)TMR_ID_2)->TMRx; it works well. Has anybody else seen this problem? I consider this a bug in the PLIB implementation. |
|
相关推荐
6个回答
|
|
我猜手工编码的访问是“工作”的,因为它只读取计数器的低端部分。为了读取完整的32位计数器,如果高的部分发生变化,需要重新读取低端部分,所以我会做一些类似的事情(省略索引检查):PLBIB模板UTI32 32 T TMRYA32 32位寄存器16位寄存器安全(TMRY)。TyrMyReaveT*Re=((TMRA RealSts**)(index));TMRA Reavest*tRMR*HOLD=((TMRA RealStss*T*)(索引+0x0200 U));UInt32-T ValLo,ValHuy;DO {ValHe==(UTInt3}t)(TMR-Hig & Gt;TMRx);ValLo=(UTInt3}t)(TMRLU->TMRx);}(ValHy.)=(UTIN 32×T)(TMR-Hyg & Gt;TMRx);/ /如果高部分改变返回((ValHy≪lt;16u)ValLo)重复;}
以上来自于百度翻译 以下为原文 I guess the hand coded access "works" since it only reads the low part of the counter. To read the full 32 Bit counter the low-part needs to be re-read if the high part changes, so I'd do something like this (omitting index check): PLIB_TEMPLATE uint32_t TMR_Counter32BitGet_In16BitRegister_Safe( TMR_MODULE_ID index ) { tmr_registers_t volatile * tmrLow = ((tmr_registers_t *)(index)); tmr_registers_t volatile * tmrHigh = ((tmr_registers_t *)(index + 0x0200u)); uint32_t valLow, valHigh; do { valHigh = (uint32_t)(tmrHigh->TMRx); valLow = (uint32_t)(tmrLow->TMRx); } while(valHigh != (uint32_t)(tmrHigh->TMRx)); // repeat if HighPart changed return((valHigh << 16u) | valLow); } |
|
|
|
实际上它做了一个32位的读取并读取完整的计数器!这是没有记录的!数据表声明它应该在上16位返回0。然而,它确实返回正确的高位。Microchip有人能证实吗?最后,我写了以下内容:UTI32 32位计数器32位BIT保存(TMRMuleMexEdID索引){UInt32t Val1=0;IF(TMRx),VAR1=(UTIN 32)((TMRSReistSts:Value*)索引)-& gt;;;}返回(VAL1);}
以上来自于百度翻译 以下为原文 Actually it does an 32 bit read and reads the complete counter! This is not documented! The datasheet states it should return 0 in the upper 16 bit. However it does return the correct high bits. Can someone from Microchip confirm this? I ended up writing the following: uint32_t Counter32BitGetSave(TMR_MODULE_ID index) { uint32_t val1 = 0; if( _TMR_MODULE_ID_IS_EVEN(index) ) { val1 = (uint32_t)((tmr_registers_t volatile *)index)->TMRx; } else { PLIB_ASSERT(false, "This Timer instance does not support PLIB_TMR_Counter32BitGet"); } return ( val1 ); } |
|
|
|
|
|
|
|
参见FRM的“32位定时器考虑”第143.2.1节:
以上来自于百度翻译 以下为原文 See section 14.3.2.1, "32-bit Timer Considerations" of the FRM: |
|
|
|
|
|
|
|
我认为有人应该向支持报告,所以可能在未来的PLIB实现中得到修复。有志愿者吗?眨眼:
以上来自于百度翻译 以下为原文 I think someone should report it to the support, so maybe it might get fixed in a future PLIB implementation. Any volunteers? wink: |
|
|
|
只有小组成员才能发言,加入小组>>
4839 浏览 9 评论
1842 浏览 8 评论
1756 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
2968 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2072 浏览 5 评论
467浏览 1评论
1120浏览 1评论
303浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
371浏览 0评论
268浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-5-6 02:28 , Processed in 0.949215 second(s), Total 80, Slave 64 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号