| 数据搜索系统,热门电子元器件搜索 |
|
HT46R46 数据表(PDF) 20 Page - Holtek Semiconductor Inc |
|
|
|||||||||||||||||||||||||||||
HT46R46 数据表(HTML) 20 Page - Holtek Semiconductor Inc |
|
20 / 42 page ![]() HT46R46/HT46C46/HT46R47/HT46C47 Rev. 1.00 20 December 28, 2004 The following two programming examples illustrate how to setup and implement an A/D conversion. In the first exam- ple, the method of polling the EOCB bit in the ADCR register is used to detect when the conversion cycle is complete, whereas in the second example, the A/D interrupt is used to determine when the conversion is complete. Example: using EOCB Polling Method to detect end of conversion clr INTC.3 ; disable A/D interrupt in interrupt control register mov a,00100000B mov ADCR,a ; setup ADCR register to configure Port PB0~PB3 as A/D inputs and select ; AN0 to be connected to the A/D converter mov a,00000001B mov ACSR,a ; setup the ACSR register to select fSYS/8 as the A/D clock Start_conversion: clr ADCR.7 set ADCR.7 ; reset A/D clr ADCR.7 ; start A/D Polling_EOC: sz ADCR.6 ; poll the ADCR register EOCB bit to detect end of A/D conversion jmp polling_EOC ; continue polling mov a,ADR ; read conversion result from the ADR (HT46R46/HT46C46) or ; ADRH, ADRL (HT46R47/HT46C47) register mov adr_buffer,a ; save result to user defined register : : jmp start_conversion ; start next A/D conversion Example: using Interrupt method to detect end of conversion set INTC.0 ; interrupt global enable set INTC.3 ; enable A/D interrupt in interrupt control register mov a,00100000B mov ADCR,a ; setup ADCR register to configure Port PB0~PB3 as A/D inputs and select ; AN0 to be connected to the A/D converter mov a,00000001B mov ACSR,a ; setup the ACSR register to select fSYS/8 as the A/D clock start_conversion: clr ADCR.7 set ADCR.7 ; reset A/D clr ADCR.7 ; start A/D : : ; interrupt service routine EOC_service routine: mov a_buffer,a ; save ACC to user defined register mov a,ADR ; read conversion result from the ADR (HT46R46/HT46C46) or ; ADRH, ADRL (HT46R47/HT46C47) register mov adr_buffer,a ; save result to user defined register clr ADCR.7 set ADCR.7 ; reset A/D clr ADCR.7 ; start A/D mov a,a_buffer ; restore ACC from temporary storage reti |
|
链接网址 |
| 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 |