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.