English 中文(简体)
PIC 16F88 ADC 实例?
原标题:PIC 16F88 ADC example?

所以我有一个IPC 16F88, 我设法用它做了几件事, 但现在我在想如何将模拟转换成数字转换?

在互联网上我尝试过许多例子, 但没有成功: (如果有人能说明如何使用ADCON0/1和类似的东西, 我会很感激。

非常感谢。

Edit: this is my code:

START
    banksel TRISA
    clrf    TRISB
    movlw   0xff
    movwf   TRISA
    movlw   b 11000111 
    movwf   OPTION_REG
    movlw   b 00000001 
    movwf   ADCON1
    banksel PORTB
    clrf    PORTB   
LOOP
    btfss   PIR1,ADIF
    goto    LOOP
    bsf ADCON0,GO   
WAIT
    btfsc   ADCON0,GO
    goto    WAIT
    movf    ADRESH,W
    movwf   PORTB,W
END
问题回答

从《事先知情同意程序》数据表中得出:

The ADRESH:ADRESL registers contain the 10-bit result of the A/D conversion. When the A/D conversion is complete, the result is loaded into this A/D result register pair, the GO/DONE bit (ADCON0<2>) is cleared and the A/D interrupt flag bit ADIF is set. The block diagram of the A/D module is shown in Figure 11-1.

After the A/D module has been configured as desired, the selected channel must be acquired before the conversion is started. The analog input channels must have their corresponding TRIS bits selected as inputs. To determine sample time, see Section 11.1. After this acquisition time has elapsed, the A/D conversion can be started. The following steps should be followed for doing an A/D conversion:

  1. Configure the A/D module: • Configure analog pins / voltage reference / and digital I/O (ADCON1) • Select A/D input channel (ADCON0) • Select A/D conversion clock (ADCON0) • Turn on A/D module (ADCON0)
  2. Configure A/D interrupt (if desired): • Clear ADIF bit • Set ADIE bit • Set GIE bit 3. Wait the required acquisition time.
  3. Start conversion: • Set GO/DONE bit (ADCON0)
  4. Wait for A/D conversion to complete, by either: • Polling for the GO/DONE bit to be cleared OR • Waiting for the A/D interrupt
  5. Read A/D Result register pair (ADRESH:ADRESL), clear bit ADIF if required.
  6. For next conversion, go to step 1 or step 2 as required. The A/D conversion time per bit is defined as TAD. A minimum wait of 2TAD is required before next acquisition starts.

您没有在开始转换前等待获取时间。 其它一切似乎都是正确的 。





相关问题
PIC question..~ [closed]

I am currently undertaking software engineering program in one of the local universities at my country. And i am interesting in software and hardware. So i decided to learn it by myself. One of my ...

USB HID protocol question

I m implementing USB on a PIC 18F2550 using a generic HID interface. I ve set up the HID profile configuation to have a single 64 byte message for both inputs and outputs. Now it s basically working. ...

Interfacing PIC Microcontroller with Java on PC using USB

HI! I want to interface PIC18F4550 with Java program and make it cross-platform initially. There are only one way I now Java has is javacomm. But i want it to be USB because not every laptop has RS232 ...

Free PIC C compiler [closed]

I am looking for a free, and possibly open source C compiler for PIC. I might go without C, but I would like to get both options. There are various compilers out there, but since I have never done ...

Sending data over tcpip using Microchip s PIC18F

All of the examples in the TCPIP Demo App are built using a custom program that designs a webpage that triggers callbacks when the webpage is changed. Is it possible to get a value from a sensor ...

One Wire Problem

I need your qualified help! I m programing in C++, using a PIC 18F87J50 and trying to connect DS18B20 at my H0 Port! I think my underlying programing is correct so.... the problem I have (think I ...

热门标签