完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
你好,
我正在使用CY8CKIT-04942XX工具包开发一个信号定时应用程序,但是我遇到了一个棘手的问题,我使用UDB 32位计数器来获取两个外部事件的时间戳。udb配置为一个自由运行在1MHz信号计数器的计数输入。时钟系统时钟”22mhz IMO(在规格按数据表)。由此产生的计数器的分辨率是1微秒。 我有一个引脚连接到一个信号,我叫触发启动事件序列。有一个ISR连接到这个引脚,以第一次阅读从counter_readcounter()反成全球UInt32变量。它使事件捕获问题的UDB计数器中断。第二事件信号,我叫MEP连接形成一个二引脚的UDB捕获引脚。相关的ISR然后读取udb身份登记和保存在第二全局变量的事件的时间戳。两ISR也锁定一个输出引脚,这样我可以监控的时序关系的信号和ISR的物理上的范围。 最后,主回路监视事件的时间变量和串口两次微秒的时间差报告。两个事件之间的时间徘徊在百毫秒(信号源是不精确的目的),和范围确认读数是一致的…大部分时间。 问题 经过大量的试验和错误,改变中断优先级和其他东西和测井资料我敲定了问题如下:有时事件捕获的高的话是不正确的。实际上,反字高出两个读数的价值回归。这听起来像一个双缓冲的柜台得到了同步。下面是示例日志摘录在不同的时代,在这里你可以看到复古的价值。我看这也在counter_readcounter()为好,但根据文档内部采用捕获机制的问题是相同的。以下是样品: 捕获:2786e0d,上映时间:276c3cd,偏移量:109120 捕获:2871f0a,上映时间:285751c,偏移量:109038 捕获:278ebaf,上映时间:294417b,偏移:4293175860(坏的捕获时间的高字= =对后两个记录高的词) 捕获:3f47d89,上映时间:3f2d25f,偏移:109354 捕获:402c081,上映时间:4011632,偏移量:109135 … 捕获:ab7e4076,上映时间:ab7ca3ac,偏移量:105674 捕获:ab82c60d,上映时间:ab812c1b,偏移:104946 捕获:ab7e40f8,上映时间:ab862be5,偏移:4294448403(坏的捕获时间的高字= =对后两个记录高的词) 捕获:ab8ce0b5,上映时间:ab8b45df,偏移量:105174 捕获:ab91e416,上映时间:ab904987,偏移:105103 … 捕获:f1af6c85,上映时间:f1ae0ba8,偏移:90333 捕获:f1b36113,上映时间:f1b212b1,偏移量:85602 捕获:f1b86902,上映时间:f1b6f36e,偏移量:95636 捕获:f1b37ab9,上映时间:f1bc3a5a,偏移:4294393951(坏的捕获时间的高字= =对后两个记录高的词) 捕获:f1c12f31,上映时间:f1bff240,偏移量:81137 这是触发和捕获ISRs: / / / / -------------------------------------------------------触发信号中断(中断优先级- 1)/ ------------------------------------------------------- cy_isr(trigger_isr)/ ~ 3.5我们从Trigger pin信号提高边缘TP0 { tp0_write(1U);//启动脉冲@ 3.5我们_ | - | _ @ 22mhz IMO/ * uint8 intrsrc = * / / /不需要找出哪些引脚中断如果只有一个引脚中断使用。trgin_clearinterrupt();mep_timer_setinterruptmode(0);/ /禁用中断释放时间= mep_timer_readcounter();//得到触发进步产生中断(文件是不正确的)mep_timer_readcapture();/ /清除FIFO(看来有时阅读仍然在FIFO)mep_timer_readstatusregister();/ /删除中断 mep_timer_setinterruptmode(mep_timer_status_capture_int_en_mask | mep_timer_status_overflow_int_en_mask);tp0_write(0U);/ / _ | - | _端脉冲~ 15.5我们@ 22mhz IMO } / / / / ------------------------------------------------------- MEP定时器ISR(中断优先级1)/ ------------------------------------------------------- cy_isr(mep_timer_isr){ char mep_str [ 200 ]; tp1_write(1U);mep_timer_setinterruptmode(0);/ /禁用中断uint8状态= mep_timer_readstatusregister();/ /清除中断做{ if((状态&;mep_timer_status_capture)){ mep_capture_time = mep_timer_readcapture();} 如果((状态&;mep_timer_status_fifonemp)){ /* mep_capture_time = * / mep_timer_readcapture();}如果((状态&;mep_timer_status_cmp)){ UInt32 CT = mep_timer_readcounter();sprintf(mep_str,比较触发:%lu rn”,CT);uart_2_uartputstring(mep_str);} 如果((状态&;mep_timer_status_overflow))/小时侧翻{ timerhours + +;sprintf(mep_str,“MEP定时器翻转:%ld rn”,timerhours);uart_2_uartputstring(mep_str);}状态= mep_timer_readstatusregister();}而(状态&;(mep_timer_status_overflow | mep_timer_status_cmp | mep_timer_status_capture | mep_timer_status_fifonemp));mep_timer_setinterruptmode(mep_timer_status_overflow_int_en_mask);/ /保持侧翻中断只有tp1_write(0U);/ / _ | - | _脉冲2 ~ 15.5我们@ 22mhz IMO } 以上来自于百度翻译 以下为原文 HI, I'm working with the CY8CKIT-049-42XX kit to develop a signal timing application, but I'm running into a nasty problem with a UDB 32-bit counter that I'm using to obtain time stamps of two external events. The UDB is configured as a free running up counter of 1MHz signal at the Count input. The clock is system clock @ 22MHz IMO (within specs as per the datasheet). The resulting counter resolution is therefore 1 microsecond. I have one pin attached to a signal I call trigger that starts the events sequence. There is an ISR attached to this pin that takes the first reading from the counter with Counter_ReadCounter() into a global uint32 variable. It then enables the event capture Interrupt of the UDB counter in question. The second event signal which I call MEP is connected form a second pin to the Capture pin of the UDB. The associated ISR then reads the UDB status register and saves the event time stamp on a second global variable. Both ISRs also toggles an output pin ON and OFF so I can monitor the timing relationship of signals and ISRs physically on the scope. Finally, the main loop monitors the event time variable and reports on the serial port both times and the time difference in microseconds. The time between both events hovers around 100 milliseconds (signal sources are not precise on purpose), and the scope confirms that the readings are in agreement …. MOST OF THE TIME. THE PROBLEM After much trial and error, changing interrupt priorities and other things and logging data I nailed down the problem to the following: Sometimes the high word of the event captured is incorrect. Actually the high word of the counter SHOWS THE VALUE OF TWO READINGS BACK. It sounds like a double buffering of the counter gets out of sync. Below is an excerpt of sample logs at different times where you can see the retro values. I have seen this also in the Counter_ReadCounter() as well, but since according to the documentation internally it also uses the capture mechanism the problem is the same. Here are the samples: Capture: 2786E0D, ReleaseTime: 276C3CD, Offset: 109120 Capture: 2871F0A, ReleaseTime: 285751C, Offset: 109038 Capture: 278EBAF, ReleaseTime: 294417B, Offset: 4293175860 (bad capture time high word == of high word of two records back) Capture: 3F47D89, ReleaseTime: 3F2D25F, Offset: 109354 Capture: 402C081, ReleaseTime: 4011632, Offset: 109135 .... Capture: AB7E4076, ReleaseTime: AB7CA3AC, Offset: 105674 Capture: AB82C60D, ReleaseTime: AB812C1B, Offset: 104946 Capture: AB7E40F8, ReleaseTime: AB862BE5, Offset: 4294448403 (bad capture time high word == of high word of two records back) Capture: AB8CE0B5, ReleaseTime: AB8B45DF, Offset: 105174 Capture: AB91E416, ReleaseTime: AB904987, Offset: 105103 .... Capture: F1AF6C85, ReleaseTime: F1AE0BA8, Offset: 90333 Capture: F1B36113, ReleaseTime: F1B212B1, Offset: 85602 Capture: F1B86902, ReleaseTime: F1B6F36E, Offset: 95636 Capture: F1B37AB9, ReleaseTime: F1BC3A5A, Offset: 4294393951 (bad capture time high word == of high word of two records back) Capture: F1C12F31, ReleaseTime: F1BFF240, Offset: 81137 Here are the trigger and capture ISRs: //------------------------------------------------------- // Trigger signal ISR - (interrupt priority 1) //------------------------------------------------------- CY_ISR(Trigger_ISR) // ~3.5 us from Trigger pin signal to raising edge to TP0 { TP0_Write(1u); // start of pulse @ 3.5 us _|-|_ @ 22MHz IMO /* uint8 intrSrc = */ // not need to find out which pin interrupted if only one pin interrupt is used. TRGIN_ClearInterrupt(); MEP_TIMER_SetInterruptMode(0); // Disable interrupts ReleaseTime = MEP_TIMER_ReadCounter(); // Get trigger in progress GENERATES INTERRUPT (documentation is incorrect) MEP_TIMER_ReadCapture(); // Clear FIFO ( it seems that sometimes this reading remains in the FIFO) MEP_TIMER_ReadStatusRegister(); // remove interrupt MEP_TIMER_SetInterruptMode(MEP_TIMER_STATUS_CAPTURE_INT_EN_MASK| MEP_TIMER_STATUS_OVERFLOW_INT_EN_MASK ); TP0_Write(0u); // _|-|_ end of pulse ~15.5 us @ 22MHz IMO } //------------------------------------------------------- // MEP Timer ISR (interrupt priority 1) //------------------------------------------------------- CY_ISR(MEP_Timer_ISR) { char mep_str[200]; TP1_Write(1u); MEP_TIMER_SetInterruptMode(0); // Disable interrupts uint8 status = MEP_TIMER_ReadStatusRegister(); // Clears the interrupt do { if ((status & MEP_TIMER_STATUS_CAPTURE) ) { MEP_Capture_Time = MEP_TIMER_ReadCapture(); } if ((status & MEP_TIMER_STATUS_FIFONEMP) ) { /* MEP_Capture_Time =*/ MEP_TIMER_ReadCapture(); } if ((status & MEP_TIMER_STATUS_CMP) ) { uint32 ct = MEP_TIMER_ReadCounter(); sprintf(mep_str,"Compare trigger at: %lurn", ct); UART_2_UartPutString(mep_str); } if ((status & MEP_TIMER_STATUS_OVERFLOW) ) // Hour rollover { TimerHours++; sprintf(mep_str,"MEP timer Roll over: %ldrn", TimerHours ); UART_2_UartPutString(mep_str); } status = MEP_TIMER_ReadStatusRegister(); } while(status & (MEP_TIMER_STATUS_OVERFLOW|MEP_TIMER_STATUS_CMP|MEP_TIMER_STATUS_CAPTURE|MEP_TIMER_STATUS_FIFONEMP)); MEP_TIMER_SetInterruptMode(MEP_TIMER_STATUS_OVERFLOW_INT_EN_MASK); // Keep rollover interrupt only TP1_Write(0u); // _|-|_ pulse 2 ~15.5 us @ 22MHz IMO } |
|
相关推荐
1个回答
|
|
嗨,Guillermo Gallo,
theplease使用PSoC Creator即PSoC Creator 4.2的最新版本构建解决问题的应用程序。 谢谢 加内什 以上来自于百度翻译 以下为原文 Hi Guillermo Gallo, ThePlease use the latest version of PSoC Creator i.e PSoC Creator 4.2 to build your application to resolve the issue. Thanks Ganesh |
|
|
|
只有小组成员才能发言,加入小组>>
752个成员聚集在这个小组
加入小组2069 浏览 1 评论
1826 浏览 1 评论
3639 浏览 1 评论
请问可以直接使用来自FX2LP固件的端点向主机FIFO写入数据吗?
1760 浏览 6 评论
1510 浏览 1 评论
CY8C4025LQI在程序中调用函数,通过示波器观察SCL引脚波形,无法将pin0.4(SCL)下拉是什么原因导致?
508浏览 2评论
CYUSB3065焊接到USB3.0 TYPE-B口的焊接触点就无法使用是什么原因导致的?
358浏览 2评论
CX3连接Camera修改分辨率之后,播放器无法播出camera的画面怎么解决?
410浏览 2评论
357浏览 2评论
使用stm32+cyw43438 wifi驱动whd,WHD驱动固件加载失败的原因?
855浏览 2评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-22 20:57 , Processed in 0.843292 second(s), Total 77, Slave 60 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号