Hi,
got a problem with xMega and 1Wire DS18B20.
[code:1:84ea0e5469]
$regfile = "xm32a4def.dat"
$crystal = 32000000
$lib "xmega.lib" : $external _xmegafix_clear : $external _xmegafix_rol_r1014
$hwstack = 32 ' default use 32 for the hardware stack
$swstack = 32 'default use 10 for the SW stack
$framesize = 32 'default use 40 for the frame space
Config Osc = Enabled , 32mhzosc = Enabled
Config Sysclock = 32mhz , Prescalea = 1 , Prescalebc = 1_1
Config Com5 = 115200 , Mode = Asynchroneous , Parity = None , Stopbits = 1 , Databits = 8
Config Serialin = Buffered , Size = 128
Config Serialout = Buffered , Size = 128
Open "COM5:" For Binary As #1
Config 1wire = PortE.1 'use this pin
Dim DigiData(8) As Byte , DSDATA$(4) as String * 6
DIM DSDataW(4) as word , DSDATA(4) as single
DIM TempA as word , TempB as word
Declare SUB DSDATACALC
Declare SUB DSREAD
Declare SUB DSRESET
DO
Waitms 250
CALL DSRESET
Waitms 750
CALL DSREAD
Print #1 , DSDATA$(1)
LOOP
End
SUB DSRESET
1wreset
1wwrite &HCC
1wwrite &H44
END SUB
SUB DSREAD
1wreset
1wwrite &HCC
1wwrite &HBE
DigiData(1) = 1wread(9)
1wreset
Call DSDATACALC
END SUB
[/code:1:84ea0e5469]
This works, is a mod from samples/xm128-1wire.bas
i need multiple Ports for 5 Sensors
so i have to write
1wreset PINx , x instead of 1wreset
1wwrite &HBE , 1 , PINx , x instead of 1wwrite &HBE
in this cases, the xMega sends data through 1Wire and the DS respondes, but thats All unreadable Data
Works on Mega64 without problems
any suggestions ?
sBronco
[b:84ea0e5469][color=red:84ea0e5469](BASCOM-AVR version : 2.0.7.6 )[/b:84ea0e5469][/color:84ea0e5469]
↧