Reading ADC on PIC16F877A

Discussion in 'Embedded Systems and Microcontrollers' started by MOHD AZUARI BIN MUSTAPHA, Jan 13, 2015.

  1. MOHD AZUARI BIN MUSTAPHA

    Thread Starter New Member

    Jan 12, 2015
    1
    0
    Hello,
    I'm using PIC 16f877a, my problem is how to write program that need a range for ADC
    for exampe:
    100<x>120 to turn led_1 on
    1020<x>150 to turn led_2 on

    x = adresh value

    can anyone help me
     
  2. MrChips

    Moderator

    Oct 2, 2009
    12,421
    3,355
    Please do not post on a year old thread.
    Please do not hijack someone else's question. Start your own thread.
     
  3. joeyd999

    AAC Fanatic!

    Jun 6, 2011
    2,675
    2,717
    Well, you could start with a compare function:

    Code (Text):
    1.  
    2. ;**************************************************
    3. ;** COMP16 -- Compare 2 sixteen bit numbers      **
    4. ;**   if oper11:0 = oper01:0, Z=1, C=1, Plus     **
    5. ;**   if oper11:0 > oper01:0, Z=0, C=1, Plus     **
    6. ;**   if oper11:0 < oper01:0, Z=0, C=0, Minus    **
    7. ;**************************************************
    8.  
    9. comp16  movfw   oper01
    10.     subwf   oper11,w
    11.     btfss   status,z
    12.     return
    13.  
    14.     movfw   oper00
    15.     subwf   oper10,w
    16.     return
    17.  
    18.  
     
Loading...