serial communication

Discussion in 'Embedded Systems and Microcontrollers' started by mah, Apr 4, 2010.

  1. mah

    Thread Starter Active Member

    Mar 15, 2010
    276
    2
    hi every body
    could you help me to do a program convert analog value to digital using pic16f877 and send it via serial port
    thank you
     
  2. Papabravo

    Expert

    Feb 24, 2006
    10,178
    1,799
    Sure. What have you got so far?
     
  3. Tahmid

    Active Member

    Jul 2, 2008
    344
    25
    Hi,
    Which language and compiler are you using?
    How far have you progressed?
    Do you require 10-bit value or 8-bit value?
     
  4. Tahmid

    Active Member

    Jul 2, 2008
    344
    25
    Hi,
    In mikroBASIC, you could do it like this:
    Code ( (Unknown Language)):
    1. program ADC_UART_16F877
    2. '16F877
    3. 'Clock: 8MHz
    4.  
    5. dim ADCResult as word
    6.  
    7. main:
    8.      UART1_Init(9600) 'Initialize UART at 9600bps
    9.      while true
    10.            ADCResult = ADC_Read(0) >> 2 'Read analog value from channel 0 and convert to 8-bit
    11.            UART1_Write(ADCResult) 'Write to serial port
    12.            delay_ms(100)
    13.      wend
    14. end.
    Hope this helps.
    Tahmid.
     
Loading...