| 数据搜索系统,热门电子元器件搜索 |
|
P87LPC767FD 数据表(PDF) 14 Page - NXP Semiconductors |
|
|
|||||||||||||||||||||||||||||
P87LPC767FD 数据表(HTML) 14 Page - NXP Semiconductors |
|
14 / 60 page ![]() Philips Semiconductors Product data 87LPC767 Low power, low price, low pin count (20 pin) microcontroller with 4-kbyte OTP and 8-bit A/D converter 2001 Aug 07 11 Code Examples for the A/D The first piece of sample code shows an example of port configuration for use with the A/D. This example sets up the pins so that all four A/D channels may be used. Port configuration for analog functions is described in the section Analog Functions. ; Set up port pins for A/D conversion, without affecting other pins. mov PT0AD,#78h ; Disable digital inputs on A/D input pins. anl P0M2,#87h ; Disable digital outputs on A/D input pins. orl P0M1,#78h ; Disable digital outputs on A/D input pins. Following is an example of using the A/D with interrupts. The routine ADStart begins an A/D conversion using the A/D channel number supplied in the accumulator. The channel number is not checked for validity. The A/D must previously have been enabled with sufficient time to allow for stabilization. The interrupt handler routine reads the conversion value and returns it in memory address ADResult. The interrupt should be enabled prior to starting the conversion. ; Start A/D conversion. ADStart: orl ADCON,A ; Add in the new channel number. setb ADCS ; Start an A/D conversion. ; orl PCON,#01h ; The CPU could be put into Idle mode here. ; orl PCON,#02h ; The CPU could be put into Power Down mode here if RCCLK = 1. ret ; A/D interrupt handler. ADInt: push ACC ; Save accumulator. mov A,DAC0 ; Get A/D result, mov ADResult,A ; and save it in memory. clr ADCI ; Clear the A/D completion flag. anl ADCON,#0fch ; Clear the A/D channel number. pop ACC ; Restore accumulator. reti Following is an example of using the A/D with polling. An A/D conversion is started using the channel number supplied in the accumulator. The channel number is not checked for validity. The A/D must previously have been enabled with sufficient time to allow for stabilization. The conversion result is returned in the accumulator. ADRead: orl ADCON,A ; Add in the new channel number. setb ADCS ; Start A/D conversion. ADChk: jnb ADCI,ADChk ; Wait for ADCI to be set. mov A,DAC0 ; Get A/D result. clr ADCI ; Clear the A/D completion flag. anl ADCON,#0fch ; Clear the A/D channel number. ret |
|
链接网址 |
| 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 |