Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Modification to the v2.0.8.3 Sample for EDMA RAM Transfer

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> Share your working BASCOM-AVR code here
View previous topic :: View next topic  
Author Message
enniom

Bascom Member



Joined: 20 Oct 2009
Posts: 496

PostPosted: Sun May 23, 2021 11:27 am    Post subject: Modification to the v2.0.8.3 Sample for EDMA RAM Transfer Reply with quote

The sample provided needs to be modified by changing the Channel Mode in order for it work properly.

This is the original sample code:
Code:
'----------------------------------------------------------------
'                  (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

The problem is that the Channel Mode is not defined. Transferring values between RAM variables require the channel to defined in Standard Mode.

Possible options for channel mode are :

_ mode = PER0123
_ mode = STD0
_ mode = STD2
_ mode = STD02



The sample code needs to be modified as:
Code:
Config Edma = Enabled , Doublebuf = Disabled , Cpm = Rr , Chmode = Std0     ' Modified by specifying the Channel Mode

.... or by choosing one of the other modes with a Standard Channel.

Then the Config EDMACH# needs to be modified to use Channel 0 or 2 - depending on the mode selected.


E
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> Share your working BASCOM-AVR code here All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum