'----------------------------------------------------------------
' (c) 1995-2020, MCS
' xm128A1-DMA.bas
' This sample demonstrates DMA with an Xmega32E5
'-----------------------------------------------------------------
$regfile = "xm32e5def.dat"
$crystal = 32000000
$hwstack = 64
$swstack = 40
$framesize = 40
'first enable the osc of your choice
Config Osc = Enabled , 32mhzosc = Enabled
'configure the systemclock
Config Sysclock = 32mhz , Prescalea = 1 , Prescalebc = 1_1
Config Com1 = 38400 , Mode = Asynchroneous , Parity = None , Stopbits = 1 , Databits = 8
Dim Ar(100) As Byte , Dest(100) As Byte , J As Byte
For J = 1 To 100
Ar(j) = J ' create an array and assign a value
Next
Print "DMA DEMO"
Config Edma = Enabled , Doublebuf = Disabled , Cpm = Rr ' enable DMA
'you can configure 4 DMA channels
Config Edmach0 = Enabled , Burstlen = 1 , Chanrpt = Enabled , Tci = Off , Eil = Off , Sar = None , Sam = Inc , Dar = None , Dam = Inc , _
Trigger = 0 , Btc = 100 , Sadr = Varptr(ar(1)) , Dadr = Varptr(dest(1))
Start Edmach0 ' this will do a manual/software DMA transfer, when trigger<>0 you can use a hardware event as a trigger source
For J = 1 To 50
Print J ; "-" ; Ar(j) ; "-" ; Dest(j) ' print the values
Next
End |