Ich brauch mal eine Erklärung

wilbo
Benutzer
Avatar
Gender:
Age: 69
Posts: 59
Registered: 11 / 2023
Subject:

Ich brauch mal eine Erklärung

 · 
Posted: 18.06.2025 - 16:45  ·  #1
Ich habe einen merkwürdigen Effekt,
im angehängten Projekt kommt es wenn ich beim auskommentieren der Unit U_ds3231 zu einem Assemblerfehler.
Die Units U_DS3231 und U_ILI9341 haben keine abhängigkeiten von einander. Eventuell kann bzw. mag mir jemand hier mal auf die Sprünege helfen

I have a strange effect,
in the attached project it comes to an assembler error when I comment out the unit U_ds3231.
The units U_DS3231 and U_ILI9341 have no dependencies on each other. Maybe someone here can or may help me on the spraying

Gruß wilbo
Attachments
Filename: (XMEGA32AU4).zip
Filesize: 8.29 KB
Title:
Download counter: 35
Merlin
Administrator
Avatar
Gender:
Age: 25
Posts: 1468
Registered: 03 / 2005
Subject:

Re: Ich brauch mal eine Erklärung

 · 
Posted: 19.06.2025 - 17:55  ·  #2
OK, it is a little subtle this one.

When you are defining variables then the variable is defined in the current memory space. That is why you you specify {$IDATA} by default before you specify your variables.

You specify the LCD_DDRCTRL like this:

Code
Unit U_ILI9341;
{.$W+}                  // enable/disable warnings for this unit
{$PCU}
// !!!!!! VON hier an aktuelle Hardware anpassen !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Define
MSPIorder_C0 = MSB;
MSPImode_C0 = 0;
MSPIpresc_C0 = 0;
MSPI_SS_C0 = none;                      // PortE.4

interface

uses;
Var
  LCD_DDRCTRL[@DDRA]                : byte;
  LCD_PORTCTRL[@PortA]              : byte;


Note that you are not specifying the memory space, so it is just left at whatever the current memory space is.

If you include the second file, in it it has a {$IDATA} statement so that LCD_DDRCTRL is correctly placed in the normal RAM area.

However if that file is omitted there is no {$IDATA} space so the memory space is left at the default which is {$DATA} or Register space.

You may think that include [@DDRA] would automatically point to the correct space and normally that would be true but not if, as in this case, the source is in the DSC file, because in that case the values are treated as numerical constants which have no data space associated with them.

So add a {$IDATA} directive before your var definition and your problem will go away.

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Okay, das ist etwas subtil.

Wenn Sie Variablen definieren, wird die Variable im aktuellen Speicherbereich definiert. Deshalb geben Sie standardmäßig {$IDATA} an, bevor Sie Ihre Variablen angeben.

Sie geben LCD_DDRCTRL wie folgt an:

Code
Unit U_ILI9341;
{.$W+}                  // enable/disable warnings for this unit
{$PCU}
// !!!!!! VON hier an aktuelle Hardware anpassen !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Define
MSPIorder_C0 = MSB;
MSPImode_C0 = 0;
MSPIpresc_C0 = 0;
MSPI_SS_C0 = none;                      // PortE.4

interface

uses;
Var
  LCD_DDRCTRL[@DDRA]                : byte;
  LCD_PORTCTRL[@PortA]              : byte;


Beachten Sie, dass Sie den Speicherplatz nicht angeben, sondern ihn einfach auf dem aktuellen Speicherplatz belassen.

Wenn Sie die zweite Datei einbinden, enthält diese eine {$IDATA}-Anweisung, sodass LCD_DDRCTRL korrekt im normalen RAM-Bereich platziert wird.

Wenn diese Datei jedoch weggelassen wird, gibt es keinen {$IDATA}-Speicherplatz, sodass der Speicherplatz auf dem Standardwert {$DATA} bzw. Registerspeicherplatz belassen wird.

Sie könnten annehmen, dass „include [@DDRA]“ automatisch auf den richtigen Speicherplatz verweist, und normalerweise ist das auch der Fall. Dies ist jedoch nicht der Fall, wenn sich die Quelle wie in diesem Fall in der DSC-Datei befindet, da die Werte in diesem Fall als numerische Konstanten behandelt werden, denen kein Datenspeicherplatz zugeordnet ist.

Fügen Sie daher vor Ihrer Variablendefinition eine {$IDATA}-Anweisung hinzu, und das Problem ist behoben.
wilbo
Benutzer
Avatar
Gender:
Age: 69
Posts: 59
Registered: 11 / 2023
Subject:

Re: Ich brauch mal eine Erklärung

 · 
Posted: 20.06.2025 - 16:49  ·  #3
Hallo Merlin,
vielen Dank für dein Erklärung, ich habe da schon 2 Tage drauf geschaut aber das ist mir nicht aufgefallen. Ich habe jetzt in die Unit U_ILI9341 die ($IDATA) Zeile eingetragen und alles funktioniert wie es soll. Ich hoffe es hat dich nicht zuviel Zeit gekostet.

Vielen dank nochmal
Gruß wilbo

Hello Merlin,
thank you for your explanation, I have been looking at it for 2 days but I didn't notice it. I have now added the ($IDATA) line to the U_ILI9341 unit and everything works as it should. I hope it did not cost you too much time.

Many thanks again
Greetings wilbo

PS: Falls es noch jemand brauchen kann Anhang
Attachments
unit DS3231_U1;

interface
// global part

{ $W+} // enable/disable warnings for this unit

uses;

{--------------------------------------------------------------}
{ Const Declarations }
const

{$IDATA}
{--------------------------------------------------------------}
{ Type Declarations }
type
DS_Record = record
DS_Sec : byte;
DS_Min : byte;
DS_Hour : byte;
DS_Day : byte;
DS_Date : byte;
DS_Months : byte;
DS_Year : byte;
end;
{--------------------------------------------------------------}
{ Var Declarations }
var
DSRTC : DS_Record;
{--------------------------------------------------------------}
{ functions }
function Get_DsRTC : boolean;
function Set_DsRTC : boolean;
implementation
// local part
{--------------------------------------------------------------}
{ Type Declarations }
type

{--------------------------------------------------------------}
{ Const Declarations }
const
DSAdress : byte = $68;
{--------------------------------------------------------------}
{ Var Declarations }
{$IDATA}
var

{--------------------------------------------------------------}
{ functions }
function Get_DsRTC : boolean;
begin
DisableInts;
if I2Cstat(DSAdress) then
I2Cout(DSAdress, $00);
I2Cinp(DSAdress, DSRTC);
ENABLEINTS($87);
return(true);
else
ENABLEINTS($87);
return(false);
endif;
end;

function Set_DsRTC : boolean;
begin
DisableInts;
{
DSRTC.DS_Sec:= ByteToBCD(RTCgetSecond);
DSRTC.DS_Min:= ByteToBCD(RTCgetMinute);
DSRTC.DS_Hour:= ByteToBCD(RTCgetHour);
DSRTC.DS_Day:= ByteToBCD(RTCgetWeekDay);
DSRTC.DS_Months:= ByteToBCD(RTCgetMonth);
DSRTC.DS_Date:= ByteToBCD(RTCgetDay);
DSRTC.DS_Year:= ByteToBCD(RTCgetYear);
}
if I2Cstat(DSAdress) then
I2Cout(DSAdress, $00, DSRTC);
ENABLEINTS($87);
return(true);
Filename: U_DS3231.pas
Filesize: 2.14 KB
Title:
Download counter: 71
Merlin
Administrator
Avatar
Gender:
Age: 25
Posts: 1468
Registered: 03 / 2005
Subject:

Re: Ich brauch mal eine Erklärung

 · 
Posted: 20.06.2025 - 21:04  ·  #4
No problem Wilbo.
Selected quotes for multi-quoting:   0

Registered users in this topic

Currently no registered users in this section

The statistic shows who was online during the last 5 minutes. Updated every 90 seconds.
MySQL Queries: 17 · Cache Hits: 15   81   96 · Page-Gen-Time: 0.030306s · Memory Usage: 2 MB · GZIP: on · Viewport: SMXL-HiDPI