| 数据搜索系统,热门电子元器件搜索 |
|
ST9 数据表(PDF) 85 Page - STMicroelectronics |
|
|
|||||||||||||||||||||||||||||
ST9 数据表(HTML) 85 Page - STMicroelectronics |
|
85 / 146 page ![]() 85/146 ST9 USER GUIDE as the Load register. The solution is to initialise the MFT with REG0R in capture mode by set- ting the RM0 bit of the TCR register to ensure Free-Running Mode. When we need to load a value in the counter, we temporarily clear the RM0 bit. Then we set REG0R to the value that must be written in the counter. The CP0 bit in the FLAGR register is pulsed high to write the contents of REG0R into the counter. Then we set bit RM0 again. 4.4.3.2 Initialisation The code for initializing the MFT is given below. Note: The ICR register sets the input to Autodiscrimination mode. In this mode, the lower four bits are irrelevant. void ConfigTimer1 ( void ) { SelectPage (T1D_PG) ; T_REG0R = 0 ;/* This register is used to preload the counter */ T_REG1R = 0 ;/* This register is used to read the counter */ /* T_CMP0R and T_CMP1R are not used */ T_TCR = Tm_cen ;/* enable counter */ /* The counter will not start until the Global Counter Enable is set in register CICR */ T_TMR = Tm_rm0 ;/* capture using REG0R and monitor using REG1R */ /* This mode is not desired, but is implies free-running, which we need */ T_ICR = Tm_ab_aa ;/* inputs used in autodiscriminating mode */ /* For so, the port 3 must be set to input on pins P3.4 and P3.6 */ T_PRSR = 0 ;/* prescaler rate = 1 */ T_OACR = 0 ;/* output A not used */ T_OBCR = 0 ;/* output B not used */ T_FLAGR = 0 ;/* not used */ T_IDMR = 0 ;/* not used */ } 4.4.3.3 Reading To read the value of the counter, you need to capture it in one of the registers, since the counter itself does not have an address and cannot be read directly. There are two ways of reading the counter: Set one of the registers REG0R or REG1R to Capture mode. A pulse on bit CP0 or CP1, re- spectively, transfers the contents of the counter to the corresponding register. |
|
链接网址 |
| ALLDATASHEET是否为您带来帮助? [ DONATE ] |
关于 Alldatasheet | 广告服务 | 联系我们 | 隐私政策 | 数据表链接 | 链接交换 | 制造商名单 All Rights Reserved©Alldatasheet.com |
| Russian : Alldatasheetru.com | Korean : Alldatasheet.co.kr | Spanish : Alldatasheet.es | French : Alldatasheet.fr | Italian : Alldatasheetit.com Portuguese : Alldatasheetpt.com | Polish : Alldatasheet.pl | Vietnamese : Alldatasheet.vn Indian : Alldatasheet.in | Mexican : Alldatasheet.com.mx | British : Alldatasheet.co.uk | New Zealand : Alldatasheet.co.nz |
|
Family Site : ic2ic.com |
icmetro.com |