Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

XMega dont stops to write at XRAM

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive
View previous topic :: View next topic  
Author Message
Kaiser48

Bascom Member



Joined: 04 Feb 2005
Posts: 18
Location: Berlin

germany.gif
PostPosted: Tue Nov 18, 2014 10:05 pm    Post subject: XMega dont stops to write at XRAM Reply with quote

It's my first Project with XMEGA128. I do write data to an external RAM using EBI and XRAM. I'm using only the lower 8 address bits and all things work fine so long
as a use a simple programm to write only a few data to some addresses and the programm ends. There is no endless loop and there are no Subroutines.
As soon as i declare a SUB (only declare it!!!, it's not essentiell to call it), the programm never stops to write data to the external bus.
I can't find the reason!?

[
$regfile = "xm128a1def.dat"
$crystal = 8000000 '8MHz
$hwstack = 64
$swstack = 40
$framesize = 40
$lib "xmega.lib"
$external _xmegafix_clear
$external _xmegafix_rol_r1014


Config Osc = Enabled, 32mhzosc = Enabled
Config Sysclock = 32mhz , Prescalea = 4 , Prescalebc = 1_1 'Internal 32MHz, prescaler = 4


CONFIG XRAM=3PORT, MODESEL0=SRAM, ADRSIZE0=128k, BASEADR0=&h20000, ALE=NOALE, WAITSTATE0=4
$xramsize = &h40000
waitms 1

Dim W As Word
Dim Tiefe As Word
Dim B As Byte
Dim LoTiefe As Byte
Dim HiTiefe As Byte

Const BaseADR = &h20000
Const NullAdres = BaseADR
Const EinsAdres = BaseADR + 1

'Declare Sub Set_PFC(PFC_Wert As Word)

Porth_dirset = &B1111_1111 : Porth = &B1111_0011 'WR, RD, ALE1, ALE2, CS0-3 = output : ALE1 & 2 auf 0 !!!
Portj_dirset = &B1111_1111 : Portj = &B1111_1111
Portk_dirset = &B1111_1111 : Portk = &B1111_1111

Tiefe = &h3FF
LoTiefe = Low(Tiefe)
HiTiefe = High(Tiefe)

Out NullAdres , LoTiefe
Out EinsAdres , HiTiefe

B = 0
W = 0
Do
B = W
Out NullAdres , B
B = High(W)
Out EinsAdres , B
Incr W
Loop until W = 1023

'Sub Set_PFC(PFC_Wert As DWord)
'do nothing
'End Sub

End
]

(BASCOM-AVR version : 2.0.7.7 )
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5921
Location: Holland

blank.gif
PostPosted: Tue Nov 18, 2014 11:41 pm    Post subject: Reply with quote

when you post code, you can best use the CODE tags. Makes it better readable.

there could be a few reasons. i advise to do a test to see if the processor reboots.
usually i do something like :

Code:
dim i as integer
do
   print i
   waitms 1000
loop
 


I did not show the config for the com. the idea is that if you check the terminal emulator output, the numbers must be increasing. if not it means the processor resets for some reason.

one of the reasons could be that processor is not programmed properly : use verify option to see if the code matches the image.

if you can not find it, create a sample that works, and that doesn't. then zip them and post them or send to support.

_________________
Mark
Back to top
View user's profile Visit poster's website
laborratte

Bascom Expert



Joined: 27 Jul 2005
Posts: 299
Location: Berlin

germany.gif
PostPosted: Wed Nov 19, 2014 1:24 am    Post subject: Reply with quote

you have to end (or endless loop) your program before you define your subs:

Code:
Out EinsAdres , B
Incr W
Loop until W = 1023

End '<-----------------HERE

Sub Set_PFC(PFC_Wert As DWord)
'do nothing
End Sub

 


otherwise you return from a subroutine that wasn't called.
crash.
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5921
Location: Holland

blank.gif
PostPosted: Wed Nov 19, 2014 10:05 am    Post subject: Reply with quote

ha, i did not see that laborratte Very Happy .

you can also use : CONFIG SUBMODE=NEW
which does not put the sub module code at the place you define them. See the help.

_________________
Mark
Back to top
View user's profile Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive 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