Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Config Base = 0 : Dimensionin SRAM & ERAM Order

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> Various
View previous topic :: View next topic  
Author Message
DennisH

Bascom Member



Joined: 25 Mar 2005
Posts: 13
Location: Melbourne Australia

australia.gif
PostPosted: Mon Oct 18, 2021 1:12 am    Post subject: Config Base = 0 : Dimensionin SRAM & ERAM Order Reply with quote

In a program under development there is a subtle difference in the way Sram and Eram is dimensioned.

I am using a 256 byte rotary buffer starting on an even boundary, eg, H200. If the buffer is indirectly
addressed using the X register (eg, using $ASM code) only the lower address byte changes which
simplifies code.

However, if Eram is dimensioned before Sram the buffer starts at H201. If the Sram is dimensioned before
the Eram the buffer starts at H200 - which is my desired result.

Apart from the address anomaly, both methods appear to run OK.

My question is what constraints are there on the order of dimensioning re eram, sram, bits, bytes, words, etc.

The following code is a brief example:

$regfile = "m2560def.dat"

'$prog Lb Fb Fbh Fbx
'
'$prog &HFF , &HFF , &HD8 , &HFD

$crystal = 16000000
$hwstack = 128
$swstack = 128
$framesize = 128

' the order of dimensioning eram and ram matters

' is important because when addressing via X reg only lower byte of X changes
' when array address is on even (H00) boundary


'--- test sample 1: A at address H201 ---

'Config Base = 0

'Dim E As Eram Byte
'Dim W As Eram Word

'Dim A(256) As Byte
'Dim I As Byte


'--- test sample 2: A at address H200 ---

Config Base = 0

Dim A(256) As Byte
Dim I As Byte

Dim E As Eram Byte
Dim W As Eram Word


' code
A(0) = 100
Print A(0)
Back to top
View user's profile
DennisH

Bascom Member



Joined: 25 Mar 2005
Posts: 13
Location: Melbourne Australia

australia.gif
PostPosted: Mon Oct 18, 2021 2:40 am    Post subject: Reply with quote

Update:

The problem seems to centre on the first dimensioning. Subsequent dimensions are correct.

This gives the required outcome:

Config Base = 0

Dim A(255) As Byte ' size changed to 255
Dim B(256) As Byte
Dim C(256) As Byte
Dim D(256) As Byte

Dim J As Word
Dim K As Byte

Dim E As Eram Byte
Dim W As Eram Word

-----------------------
' Memory allocations


A Byte(255) 0200 512
B Byte(256) 0300 768
C Byte(256) 0400 1024
D Byte(256) 0500 1280
J Word 0600 1536
K Byte 0602 1538
E EEPROM Byte 0000 0
W EEPROM Word 0001 1
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5921
Location: Holland

blank.gif
PostPosted: Mon Oct 18, 2021 9:07 am    Post subject: Reply with quote

you do not specify a version. so i will just focus on how it works in 2084.
some internal variables are dimensioned automatically depending on the used statements.
in order to get the first DIM statement starting on a boundary(that was required for xmega usb) the first user DIM statement will put memory on the first sram location. after that some internal variables could be located. for example config clock will create _day, _hour etc. variables.

you can always create one big array and use overlay to locate data inside this area.

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

Bascom Member



Joined: 25 Mar 2005
Posts: 13
Location: Melbourne Australia

australia.gif
PostPosted: Tue Oct 19, 2021 12:41 am    Post subject: Reply with quote

Mark, thanks.

Sorry for omitting the version number. I get the same results with 2081 and 2084.

The big master array with overlays is a great idea.

I already use quite a few overlays in my code - I should have thought of that!

Dennis
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> Various 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