- 打卡等级:初来乍到
- 打卡总天数:4
- 最近打卡:2025-05-01 06:58:22
金牌会员
- 积分
- 1331
|
发表于 2023-6-30 04:35:56
|
显示全部楼层
本帖最后由 jmg 于 2023-6-30 05:14 编辑
ainiw*** Published on 2023-6-29 17:19
This is the problem I am doing experiments now. I checked, and it seems that cascading needs to be counted synchronously. For the time being, it can only be entered in an interrupted way...
I think the overflow problem can be patched with a SW fixup, but since the timer chains are read when disabled, why bother ?
Using two interrupts to increment the high 16 bits of each counter is fine, provided the read is when counter is stopped. The 16b timer overflows are rare, and the int++ is simple.
This also saves two timers, and avoids two external pin bridges for cascade.
It would be nice to also eliminate that external Flip Flop. 
I think that is possible, with a little care, like this ? :
Using the now-spare timer3 or timer4, you can connect T3CLK0 to INTn_GATE of T0,T1 (replaces FF Q )
To Start Counter GATE you preload T3 to 0xFFFF, and enable T3 to Frequency in, with T3CLKO = LOW.
Then T3R=1 will toggle T3CLKO high on the next Fi =\_, enabling the counters.
T3INT: // Interrupt toggles T3CLKO on next Fin edge, after T3R is set elsewhere
T3R = 0
T3 = 0xFFFF
After the ~ 1 second window, you enable T3R again, and this time the next Fi =\_, disables the counters, and you can read the values. - Whole cycles in, and time for those whole cycles
Summary: Every T3R enable, enables a delayed output change on T3CLKO, which is triggered by Fi =\_, so this emulates the external D Flip Flop.
The spare Timer4 + prescaler, could be used for self-test option, by frequency generate on T4CLKO, jumper to Fin for testing.
The highest Fin when using T0,T3 pins will be limited to maybe ~ < sysclk/2, so an external small MCU (SO16 or TSSOP20) could be used as a prescaler.
eg the STC8H1K08 has XTALI pin which can be AC coupled, and it can /N to MCLKO pin.
A single pin and a few lines of code would select between CLKDIV = /1 and /50 on that external prescaler.
Based on tests with other vendor's 8051s that's probbly good to ~ 200MHz Fin ? (needs CLKDIV > 5 for MCU to run code )
I'm not sure how to handle out of range Fin, or how XITYPE affects upper Pin bandwidth ?
|
|