Gast
#1198228
Hallo
Ich will gewisse Analogwerte im uC wandeln und es an einem port
ausgeben. Ich habe einen Atmega16 im TQFP gehäuse.
könnt ihr mal drüberschauen?
$regfile = "m16def.dat"
$crystal = 1000000
$baud = 9600
$hwstack = 32 ' default
use 32 for the hardware stack
$swstack = 10 'default use
10 for the SW stack
$framesize = 40 'default use
40 for the frame space
Config Porta = Input
Config Portb = Output
Config Adc = Single , Prescaler = Auto
Start Adc
Print "START CONVERTER"
Dim W As Integer
Do
W = Getadc(0)
Select Case W
Case Is >= 205 : Portb = &B00000001
Case Is >= 232 : Portb = &B00000010
Case Is >= 259 : Portb = &B00000011
Case Is >= 286 : Portb = &B00000100
Case Is >= 313 : Portb = &B00000101
Case Is >= 340 : Portb = &B00000110
Case Is >= 367 : Portb = &B00000111
Case Is >= 394 : Portb = &B00001000
Case Is >= 421 : Portb = &B00001001
Case Is >= 448 : Portb = &B00001010
Case Is >= 475 : Portb = &B00001011
Case Is >= 502 : Portb = &B00001100
Case Is >= 529 : Portb = &B00001101
Case Is >= 556 : Portb = &B00001110
Case Is >= 583 : Portb = &B00001111
Case Is >= 610 : Portb = &B00011111
Case Is >= 637 : Portb = &B00101111
Case Is >= 664 : Portb = &B00111111
Case Is >= 691 : Portb = &B01001111
Case Is >= 718 : Portb = &B01011111
Case Is >= 745 : Portb = &B01101111
Case Is >= 772 : Portb = &B01111111
Case Is >= 799 : Portb = &B10001111
Case Is >= 826 : Portb = &B10011111
Case Is >= 853 : Portb = &B10101111
Case Is >= 880 : Portb = &B10111111
Case Is >= 907 : Portb = &B11001111
Case Is >= 934 : Portb = &B11011111
Case Is >= 961 : Portb = &B11101111
Case Is >= 988 : Portb = &B11111111
End Select
Print W
Loop
End