1. rafey maher

    Thread Starter New Member

    Aug 5, 2009
    9
    0
    hi.. i have atmega16 and i have connected a potentiometer on the adc channel0 and want to see the converted or digital data on the computer
    so i have made a program in which the adc output is transmitted serially to pc.. but i think there is a problem in the code... can any1 plz rectify it...??

    note: asynchronous mode, baud rate 9600, parity bit none, 8 bit character size, division factor 8, stop bit 1.

    clr r23
    out $07,r23 //adcmux
    ldi r16,$c3
    out $06,r16 //adscra
    ldi r25,$ff
    out $11,r25 //port d as output or txd as output
    out $20,r23 //ubrrh data
    ldi r17,$16
    out $09,r17 //ubrrl data (16)h or (22)d for baud rate 9600
    clr r18
    out $0b,r18 //ucsra data
    ldi r19,$08
    out $0a,r19 //ucsrb data
    ldi r20,$86
    out $20,r20 //ucsrc data
    next: sbis $0b,5 //checking for udre
    rjmp next
    sbi $06,6 //set bit start conversion in adcsra
    check: sbis $06,4 // checking for adif in adcsra
    rjmp check
    lds r27,$04 //read the data from adcl
    out $0c,r27 // send the data to udr
    sbi $06,4 // set bit adif (reseting the bit actually)
    jmp next //repeating
     
  2. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    Here is the code you posted using the code tags.

    hgmjr
     
Loading...