18F14Q40 ST7789V2 LCD variable type declar. missing or incorrect Base.inc

Started by okmn, Aug 21, 2024, 11:43 AM

Previous topic - Next topic

okmn

hi guys,
i am trying transfer my 18F27Q43 code to 18F14Q40
the code had no error for 18F27Q43 with ST7789v2 lcd

error line is in Base.inc  file of user Atomix

Dim EEADDR  As EEADR.Word...this is the error line shown by the positron

Could you possibly have any suggestions?

Device 18F14Q40
Declare Xtal = 64
Declare Create_Coff On
'***********************************************************************
Config_Start
FEXTOSC = OFF      ' External Oscillator Mode Selection->Oscillator not enabled
RSTOSC = HFINTOSC_64MHZ      ' Power-up Default Value For COSC->HFINTOSC with HFFRQ = 64 MHz And CDIV = 1:1

FCMENP = OFF      ' Fail-Safe Clock Monitor Enable - Primary Xtal Enable->Fail-Safe Clock Monitor enabled; timer will flag FSCMP bit and OSFIF interrupt on EXTOSC failure.
CLKOUTEN = OFF      ' Clock Out Enable->CLKOUT function is disabled
FCMEN = OFF      ' Fail-Safe Clock Monitor Enable->Fail-Safe Clock Monitor disabled
CSWEN = On      ' Clock Switch Enable->Writing To NOSC And NDIV is allowed
FCMENS = OFF      ' Fail-Safe Clock Monitor Enable - Secondary Xtal Enable->Fail-Safe Clock Monitor Disabled
PR1WAY = On      ' PRLOCKED One-Way Set Enable->PRLOCKED Bit can be cleared And Set only once

MVECEN = OFF      ' Multivector Enable->Interrupt contoller does not use vector table to prioritze interrupts
MCLRE = EXTMCLR      ' Master Clear (MCLR) Enable->If LVP = 0, MCLR Pin is MCLR; If LVP = 1, RE3 pin function is MCLR
BOREN = OFF      ' Brown-out Reset Enable->Brown-out Reset disabled
PWRTS = PWRT_64      'Power-up Timer Selection->PWRT set at 64ms
IVT1WAY = On      ' IVTLOCK One-Way Set Enable->IVTLOCKED Bit can be cleared And Set only once
LPBOREN = OFF      ' Low-Power BOR Enable->Low-Power BOR disabled

XINST = OFF      ' Extended Instruction Set Enable->Extended Instruction Set And Indexed Addressing Mode disabled
LVP = On      ' Low-Voltage Programming Enable->Low voltage programming enabled. MCLR/VPP Pin function is MCLR. MCLRE configuration Bit is ignored
ZCD = OFF      ' ZCD Disable->ZCD module is disabled. ZCD can be enabled by setting the ZCDSEN Bit of ZCDCON
STVREN = On      ' Stack Overflow/Underflow Reset Enable->Stack full/underflow will cause Reset
BORV = VBOR_1P9      ' Brown-out Reset Voltage Selection->Brown-out Reset Voltage (VBOR) Set To 1.9V
PPS1WAY = On      ' PPSLOCKED One-Way Set Enable->PPSLOCKED Bit can be cleared And Set only once; PPS registers remain locked after one clear/set cycle

WDTCPS = WDTCPS_31      ' WDT Period Select->Divider ratio 1:65536; software control of WDTPS
WDTE = OFF      ' WDT Operating Mode->WDT Disabled; SWDTEN is ignored

WDTCWS = WDTCWS_7      ' WDT Window Select->window always open (100%); software control; keyed access not required
WDTCCS = SC      ' WDT Input Clock Selector->Software Control

SAFEN = OFF      ' Storage Area Flash (SAF) Enable->SAF disabled
BBEN = OFF      ' Boot Block Enable->Boot block disabled
BBSIZE = BBSIZE_512      ' Boot Block Size Selection->Boot Block size is 512 words

WRTB = OFF      ' Boot Block Write Protection->Boot Block not Write protected
WRTC = OFF      ' Configuration Register Write Protection->Configuration registers not Write protected
WRTD = OFF      ' Data EEPROM Write Protection->Data EEPROM not Write protected
WRTAPP = OFF      ' Application Block Write Protection->Application Block not write protected
WRTSAF = OFF      ' Storage Area Flash (SAF) Write Protection->SAF not Write Protected

Cp = On      ' User Program Flash Memory And Data EEPROM Code Protection->PFM And Data EEPROM Code protection enabled
Config_End
'NDIV 1; NOSC HFINTOSC;
OSCCON1 = $60
'SOSCPWR Low power; CSWHOLD may proceed;
OSCCON3 = 0
'EXTOEN disabled; HFOEN disabled; MFOEN disabled; LFOEN disabled; SOSCEN disabled; ADOEN disabled; PLLEN disabled;
OSCEN = $00
'HFFRQ 64_MHz;
OSCFRQ = $08
OSCTUNE = 0

LATA = 0
LATB = 0
LATC = 0

TRISA = $28
TRISB = 0
TRISC = $1C

ANSELA = 0
ANSELB = 0
ANSELC = $1C
WPUA = $20
WPUB = 0
WPUC = 0

ODCONA = 0
ODCONB = 0
ODCONC = 0

SLRCONA = $37
SLRCONB = $F0
SLRCONC = $FF

INLVLA = $3F
INLVLB = $F0
INLVLC = $FF
RB4I2C = 0
RB6I2C = 0
IOCAP = 0
IOCAN = $20
IOCAF = 0
IOCBP = 0
IOCBN = 0
IOCBF = 0
IOCCP = 0
IOCCN = 0
IOCCF = 0

TMR0H = $0B
TMR0L = $DC
T0CON1 = $76
T0CON0 = $97
INTCON0bits_IPEN = 0
IOCAFbits_IOCAF5 = 0
PIR0bits_IOCIF = 0
PIR3bits_TMR0IF = 0
T0CON0bits_T0EN = 1
''==========================================================
Proc ADC_Read(Channel As Byte),Word
    ADPCH = Channel
    ADCON0bits_ADON = 1
          DelayUS 200
          'Start the conversion
          ADCON0bits_GO = 1
          While ADCON0bits_GO = 1 :      Wend         ' Poll the GO_DONE flag for completion of conversion
          ADCON0bits_ADON = 0                         ' Disable the ADC, to save power
          ADPCH = $3B                                 'Set the ADC channel to AVss
          Result.LowByte = ADRESL
          Result.HighByte = ADRESH
EndProc
''==========================================================
Proc Switch_Read()
    Switch_1_Select = 0
    Switch_2_Select = 1
    DelayMS 1   
    Switch_1 = 15-(PORTB & %00001111)
    Switch_1_Select = 1
    Switch_2_Select = 0
    DelayMS 1   
    Switch_2 = 15-(PORTB & %00001111)
           
EndProc
''==========================================================
'------------------------------- Use Displays -------------------------------
$define LCD_USE_TFT_130_240_240

$define LCD_RST     PORTC.0
$define LCD_CS      PORTC.1
$define LCD_DC      PORTC.2
$define LCD_CLK     PORTC.3 
$define LCD_DAT     PORTC.4
$define LCD_CLK_HIGH        ' set for display 1.3 inches 240x240

'--------------------------------- Library ----------------------------------
Include "Lib\LCD\LCD_GFX.inc"
'Include "Lib\LCD\Font\Std_5x8.inc"
Include "Lib\LCD\Font\SegoeUI_13x16.inc"
'Include "Lib\LCD\Font\Digital-7_Mono.inc" 
'Include "Lib\LCD\Font\Tahoma.inc"
'----------------------------- Select Display -------------------------------
LCD_Select(LCD_TFT_130_240_240)
'==========================================================

LCD_Init()
Symbol Switch_1_Select = LATB.4
Symbol Switch_2_Select = LATB.5
Dim Switch_1 As Byte = 0
Dim Switch_2 As Byte = 0
Dim Sample_Count As Byte = 0
Dim Channel_No As Byte = 0
Dim ADC_Value As Word = 0
Dim Analog_Value[2] As Word = 0
Dim Temp As Dword = 0
Set LATC.5


     LCD_Rotation(0)
     LCD_Clear()
     LCD_Color = BLACK'WHITE'GREY
     LCD_BackColor = BLACK     
'     LCD_RectFill(0,0,240,240)     
    Lcd_Zoom = 1
    LCD_Rotation(2)
    Lcd_Zoom = 2
'    LCD_SetFont(Std_5x8)
'    LCD_SetFont(Tahoma)
'    LCD_SetFont(Digital-7_Mono)
    LCD_SetFont(SegoeUI_13x16)
MAIN:
    Switch_Read()
    For Channel_No = 0 To 1
        For Sample_Count = 0 To 49
            ADC_Value = ADC_Read(Channel_No)
            Temp = Temp + ADC_Value
        Next Sample_Count
        Analog_Value[Channel_No] = (Temp/50)
        Temp = 0
    Next Channel_No   
    Temp = 0
        If Analog_Value[0]<2000 Then LCD_Color = WHITE  'LCD_BackColor = WHITE     
        If Analog_Value[0]>1999 And Analog_Value[0]<3000 Then LCD_Color = GREEN 'LCD_BackColor = GREEN         
        If Analog_Value[0]>2999 And Analog_Value[0]<3750 Then LCD_Color = YELLOW 'LCD_BackColor = YELLOW
         If Analog_Value[0]>3749 Then LCD_Color = CYAN 'LCD_BackColor = CYAN
'             LCD_BackColor = WHITE
        LCD_TextColor( LCD_Color ,BLACK) 'LCD_Color
'        LCD_RectFill(0,0,240,40)
'        LCD_RectFill(0,168,240,70)
'        Print At 1,40," AN0:",#Analog_Value[0],"    "
'        Print At 1,72," AN1:",#Analog_Value[1],"    "
'        Print At 1,104," SW-1:",Dec1 Switch_1,"     "
'        Print At 1,136," SW-2:",Dec1 Switch_2,"     "
        Print At 1,20," ",#Analog_Value[0],"    "
        Print At 1,60," ",#Analog_Value[1],"    "
        Print At 1,100," ",Dec1 Switch_1,"      "
        Print At 1,140," ",Dec1 Switch_2,"      "         
 
GoTo MAIN



top204

As with most things with the microchip logo on them, they have very few standards, and SFR name changes are common.

With the 18F14Q40 devices, and the other newer Q devices, they use the names: EEADRL and EEADRH and not EEADR and EEADRH. See inside the device's .ppi file in its "SFR Definitions" section.

They now actually use very different SFR names, such as: NVMADR, with 'NVM' instead of 'EE', but I look for particular SFR names and add more recognisable names where I can when the .ppi files are being created. However, I cannot make SFR names up or remove SFR names, because they must follow the names in a device's datasheet as well, otherwise, it can cause confusion.

So try changing it to:

Dim EEADDR As EEADRL.Word

There may be other changes in the newer Q devices, but the only way to find out is to try it. :-)


okmn

Quote from: top204 on Aug 21, 2024, 12:31 PMAs with most things with the microchip logo on them, they have very few standards, and SFR name changes are common.

With the 18F14Q40 devices, and the other newer Q devices, they use the names: EEADRL and EEADRH and not EEADR and EEADRH. See inside the device's .ppi file in its "SFR Definitions" section.

They now actually use very different SFR names, such as: NVMADR, with 'NVM' instead of 'EE', but I look for particular SFR names and add more recognisable names where I can when the .ppi files are being created. However, I cannot make SFR names up or remove SFR names, because they must follow the names in a device's datasheet as well, otherwise, it can cause confusion.

So try changing it to:

Dim EEADDR As EEADRL.Word

There may be other changes in the newer Q devices, but the only way to find out is to try it. :-)




i tried  Dim EEADDR As EEADRL.Word  it is ok.

 but  i have second new  error now it is  about this line in Base.inc files;


Dim ADCRES  As ADRES.Word

okmn

i changed that line like this   and no have error   it is ok now.
Dim ADCRES  As ADRESL.Word 

top204

What you can do is wrap the alias creators within preprocessor comparisons, so if the SFR name exists, it will use it, and if not, it will use another name:

$ifdef _EEADR
    Dim EEADDR As EEADR.Word
$else
    Dim EEADDR As EEADRL.Word
$endif

$ifdef _ADRES
    Dim ADCRES As ADRES.Word
$else
    Dim ADCRES As ADRESL.Word
$endif


Each SFR on a device is also held within the device's .def file, and have a preceding underscore, so the code above states that:

If the ADRES SFR exists, alias to that, otherwise, alias to the ADRESL SFR. The same with EEADR...

The compiler .def files are held in the folder: "C:\Program Files (x86)\ProtonIDE\PDS\Includes\Defs\", and the preprocessor reads the .def file for the device chosen with the "Device" directive when it runs.