News:

PROTON pic BASIC Compilers for PIC, PIC24, dsPIC33

Main Menu

www.picgraphic.com

Started by trastikata, Nov 12, 2024, 10:44 PM

Previous topic - Next topic

trastikata

Hello normnet,

I am not familiar with such SD cards. I know only that "classic" SD cards support up to 25-30 MHz SPI writes and unofficially up to 70 MHz SPI reads.

In my tests I've found the bottleneck is when the byte is being processed by the card's MCU and not the actual SPI clock.

Peter Truman

Hi Trastikata

I have my boards back now so I decided I would get stuck into this - hope you don't mind but I have some questions (and a lot I don't yet understand)?

I decided I should start with your Blackboard example - so, following the instruction in your help file, I setup the file structure as recommended. The program won't currently compile.

The library files seem to be in the correct location? See snip but the compile is failing at

ERROR [Line 319]: Item 'TftDataLowByte' not found!(System.inc)


TftDataLowByte appears to be created with a pre-processor command

            $if TFT_IC = NT35510
                TftDataHighByte = bCommand
                TftDataLowByte = 0
            $else
                TftDataLowByte = bCommand
            $endif

So I don't really understand that? (but I see System.Inc is called from TFT_Graphic_Lib.inc)

A fair bit out of my depth at this point - am I missing something obvious?

Appreciate your help with this - I'm determined to get these screens working




trastikata

#62
Hello Peter,

TftDataLowByte is part of the parallel interface for 8-bit MCUs where the pixel data is usually sent over 16b bus. Thus TftDataLowByte represents the MCU 8-bit port connected to the lower 8 bits of the display interface.

Because there are a lot of possible combinations of display interfaces and controllers, the pre-processor needs to know exactly what hardware you are using.

Can you share information about:

Display interface (parallel or SPI)
Display controller
Display pixels
MCU type

I would be happy to help you getting started with the library. So if you have any questions, don't hesitate asking.

Besides there are probably bugs that I didn't catch and if there's something not working, let me know so I can test and correct it.

Peter Truman

Many thanks - I appreciate the help

I'm using a straight copy the contents of your Blackboard example from your picgraphic.com site (although I did try other examples as well, my old programmer doesn't allow the DS PIC so I've ordered a PICKIt 5 - not arrived yet)

Device = 18F67K22



Declare Xtal = 64

Declare Watchdog = OFF

Declare Warnings = Off

Declare Optimiser_Level = 3



'================ TFT SCREEN ================

$define TFT_IC               ST7789V

$define TFT_COM              SPI_1

$define TftScreenWidth       320

$define TftScreenHeight      240

$define TFT_CS               PORTF.7

$define TFT_RESET            PORTC.7

$define TFT_DC               PORTC.2

$define TFT_MOSI             PORTC.5

$define TFT_MISO             PORTC.4

$define TFT_SCLK             PORTC.3

$define _TFT_MOSI            _PORTC.5

$define _TFT_MISO            _PORTC.4

$define _TFT_SCLK            _PORTC.3



'================ TFT TOUCH ================

$define TOUCH_IC             XPT2046

$define TOUCH_COM            SPI_SW

$define Z_Threshold          600

$define TouchAveragePoints   2

$define TouchMedianDistance  8

$define T_CS                 PORTG.1

$define T_IRQ                PORTA.5

$define T_MOSI               PORTC.5

$define T_MISO               PORTC.4

$define T_SCLK               PORTC.3

$define _T_MOSI              _PORTC.5

$define _T_MISO              _PORTC.4

$define _T_SCLK              _PORTC.3



'================ MCU ================

$define McuType              0



'================ SD CARD ================

$define SDCardUsed           0

$define SDCardFatUsed        0

$define SD_COM               SPI_2

$define SD_CS                PORTG.3

$define SD_SDO               PORTD.4

$define SD_SDI               PORTD.5

$define SD_CLK               PORTD.6

$define _SD_SDO              _PORTD.4

$define _SD_SDI              _PORTD.5

$define _SD_CLK              _PORTD.6



'================ MEMORY ================

$define MemoryType           2

$define MEM_COM              SPI_2

$define MEM_CS               PORTA.2

$define MEM_MOSI             PORTD.4

$define MEM_MISO             PORTD.5

$define MEM_SCLK             PORTD.6

$define _MEM_MOSI            _PORTD.4

$define _MEM_MISO            _PORTD.5

$define _MEM_SCLK            _PORTD.6

$define MEM_PAGE_SIZE        256

$define MEM_SECTOR_SIZE      4096

$define MEM_SECTOR_COUNT     2048

$define MEM_FILE_COUNT       256

$define MEM_WRITE_DELAY      5



'================ FONT ================

$define FontSmooth           0

$define FontMaxSpace         8

$define FontMaxPixels        8

Include                      "TftLib\Fonts\BDF\F4_BDF_Ranchers-Regular-23.inc"

Include                      "TftLib\TFT_Graphic_Lib.inc"



Dim pButtonMode As Bit

Dim pBufferReset As Bit = 1

Dim wTouchToPointXOld As Word

Dim wTouchToPointYOld As Word



On_Hardware_Interrupt GoTo Isr

GoTo Main



Isr:

    Context Save

        T1CON.0 = 0

        pBufferReset = 1

        TMR1H = $63 : TMR1L = $C0

        PIR1.0 = 0

    Context Restore

   

Main:

    Clear

    SetCrystal()

    SetPins()

    SetTimer1()

    TftSetUp(0) 

    TftResetScreen(BLACK)

    TftTouchCalibration(3) 

    SetScreen()

    DelayMS 1000

   

    While 1 = 1

        If T_IRQ = 0 Then

            If TftTouchGetCoordinates(0) = 1 Then

                'Check if within board area, if not check buttons

                If wTouchToPointY > 44 And wTouchToPointY < 235 And wTouchToPointX > 4 And wTouchToPointX < 315 Then

                    'Print pixel

                    If pButtonMode = 0 Then

                        If pBufferReset = 0 Then

                            If Abs(wTouchToPointX - wTouchToPointXOld) < 3 Then

                                If Abs(wTouchToPointY - wTouchToPointYOld) < 3 Then

                                    TftPixel(wTouchToPointX, wTouchToPointY, GREEN)

                                    wTouchToPointXOld = wTouchToPointX

                                    wTouchToPointYOld = wTouchToPointY

                                    T1CON.0 = 0 : TMR1H = $63 : TMR1L = $C0 : T1CON.0 = 1

                                EndIf

                            EndIf

                        Else

                            TftPixel(wTouchToPointX, wTouchToPointY, GREEN)

                            wTouchToPointXOld = wTouchToPointX

                            wTouchToPointYOld = wTouchToPointY

                            pBufferReset = 0

                            T1CON.0 = 1

                        EndIf

                    Else

                        'Erase 4x4 pixel area

                        TftRectangleSNCP(wTouchToPointX, wTouchToPointY, 4,4, BLACK)

                    EndIf

                Else   

                    CheckButtons()

                EndIf

            EndIf

        EndIf

    Wend

End 

   

Proc CheckButtons()

    If wTouchToPointY > 6 And wTouchToPointY < 34 Then

        Select wTouchToPointX

            Case 25 To 95

                TftRectangleRC(120,5, 200,35, 10, 0,BURNISHED_BROWN, 2,-1)

                TftRectangleRC(20,5, 100,35, 10, 0,RED, 2,-1)

                pButtonMode = 0

            Case 125 To 195

                TftRectangleRC(20,5, 100,35, 10, 0,BURNISHED_BROWN, 2,-1)

                TftRectangleRC(120,5, 200,35, 10, 0,RED, 2,-1)

                pButtonMode = 1

            Case 225 To 295

                TftRectangleRC(20,5, 100,35, 10, 0,BURNISHED_BROWN, 2,-1)

                TftRectangleRC(120,5, 200,35, 10, 0,BURNISHED_BROWN, 2,-1)

                TftRectangleRC(220,5, 300,35, 10, 0,RED, 2,-1)

                TftRectangleSNTC(3,41, 316,236, BLACK)

                DelayMS 200

                TftRectangleRC(220,5, 300,35, 10, 0,BURNISHED_BROWN, 2,-1)

                TftRectangleRC(20,5, 100,35, 10, 0,RED, 2,-1)

                pButtonMode = 0

        EndSelect

    EndIf

EndProc



Proc SetScreen()

    TftResetScreen(BLACK) 

    'Outside frame

    TftRectangleTCG(0,0, 319,40, AZURE, WHITE, 1)

    TftRectangleETTCI(0,0, 319,40, ANTIQUE_RUBY, 2)

    TftRectangleETTCI(0,38, 319,239, ANTIQUE_RUBY, 2)

    'Print buttons

    TftRectangleRCG(20,5, 100,35, 10, ANTIQUE_BRASS,BRONZE, 1)

    TftRectangleRCG(120,5, 200,35, 10, ANTIQUE_BRASS,BRONZE, 1)

    TftRectangleRCG(220,5, 300,35, 10, ANTIQUE_BRASS,BRONZE, 1)

    TftRectangleRC(20,5, 100,35, 10, 0,BURNISHED_BROWN, 2,-1)

    TftRectangleRC(120,5, 200,35, 10, 0,BURNISHED_BROWN, 2,-1)

    TftRectangleRC(220,5, 300,35, 10, 0,BURNISHED_BROWN, 2,-1)

    TftSetBdfFont(4)

    TftPrintBdfString("Write", 34, 12, 480, 0, WARM_BLACK, WHITE, 1)

    TftPrintBdfString("Erase", 134, 12, 480, 0, WARM_BLACK, WHITE, 1)

    TftPrintBdfString("Reset", 234, 12, 480, 0, WARM_BLACK, WHITE, 1)

    TftRectangleRC(20,5, 100,35, 10, 0,RED, 2,-1) 

EndProc



'Set Fosc   

Proc SetCrystal()

    Clear

    OSCTUNE.6 = 1

    DelayMS 100

EndProc   



Proc SetPins()

    'Set all digital

    ANCON0 = 0

    ANCON1 = 0

    ANCON2 = 0



    SSP1STAT.6 = 1

    SSP1CON1 = %00100000

EndProc



Proc SetTimer1()

    T1CON.7 = 0 : T1CON.6 = 0 'FOSC /4

    T1CON.5 = 1 : T1CON.4 = 0 '1:4 Prescaler

    T1CON.3 = 0 'Dedicated T1 oscillator disabled

    T1CON.2 = 1 'Do not synchronize

    T1CON.1 = 0 '8-bit

    T1CON.0 = 0 'TMR1 ON / Off

    TMR1H = $63 : TMR1L = $C0

    INTCON.7 = 1 : INTCON.6 = 1 : PIR1.0 = 0 : PIE1.0 = 1

EndProc



Config_Start

  RETEN = On        ;Enabled

  INTOSCSEL = Low        ;LF-INTOSC in Low-power mode during Sleep

  SOSCSEL = Dig        ;digital

  XINST = OFF        ;Disabled

  FOSC = EC2        ;HS oscillator (High power, 16 MHz - 25 MHz)

  PLLCFG = On        ;Enabled

  FCMEN = OFF        ;Disabled

  IESO = OFF        ;Disabled

  PWRTEN = OFF        ;Disabled

  BOREN = OFF        ;Disabled in hardware, SBOREN disabled

  BORV = 0        ;3.0V

  BORPWR = High        ;BORMV set to high power level

  WDTEN = OFF        ;WDT disabled in hardware; SWDTEN bit disabled

  WDTPS = 1048576        ;1:1048576

  RTCOSC = SOSCREF        ;RTCC uses SOSC

  CCP2MX = PORTBE        ;RC1

  MSSPMSK = MSK7        ;7 Bit address masking mode

  MCLRE = On        ;MCLR Enabled, RG5 Disabled

  STVREN = On        ;Enabled

  BBSIZ = BB2K        ;2K word Boot Block size

  Debug = OFF        ;Disabled

  Cp0 = OFF        ;Disabled

  CP1 = OFF        ;Disabled

  CP2 = OFF        ;Disabled

  CP3 = OFF        ;Disabled

  CP4 = OFF        ;Disabled

  CP5 = OFF        ;Disabled

  CP6 = OFF        ;Disabled

  CP7 = OFF        ;Disabled

  CPB = OFF        ;Disabled

  CPD = OFF        ;Disabled

  WRT0 = OFF        ;Disabled

  WRT1 = OFF        ;Disabled

  WRT2 = OFF        ;Disabled

  WRT3 = OFF        ;Disabled

  WRT4 = OFF        ;Disabled

  WRT5 = OFF        ;Disabled

  WRT6 = OFF        ;Disabled

  WRT7 = OFF        ;Disabled

  WRTC = OFF        ;Disabled

  WRTB = OFF        ;Disabled

  WRTD = OFF        ;Disabled

  EBRT0 = OFF        ;Disabled

  EBRT1 = OFF        ;Disabled

  EBRT2 = OFF        ;Disabled

  EBRT3 = OFF        ;Disabled

  EBRT4 = OFF        ;Disabled

  EBRT5 = OFF        ;Disabled

  EBRT6 = OFF        ;Disabled

  EBRT7 = OFF        ;Disabled

  EBRTB = OFF        ;Disabled

Config_End 

As I understand it - the first 6 sections (after the declare's) setup the parameters for the screens etc which I presume come from the TFT_Graphic_Lib.exe tool? I.e.
TFT Screen, Controller, screen width etc)
TFT Touch
MCU
SD Card
Memory
and Font



(I stuck with your example settings - since I'm not ready to venture into changing them as yet)

I read this as using the 18F67K22 PIC with the ST7789V controller, with the SPI interface? Etc - as per the example.

I also tried the 'Demo Touch Menu from Flash Memory' example with the same result (TFTDataLowByte not found)

I've not been able to compile either file as yet so I'm not able to test my board setup (it should be the same as yours).

My setup is:
Proton IDE Ver 2.0.3.3
Loader Ver 1.0.3.2
Compiler Ver 4.0.3.3 (I think - not visible in the 'help about' panel)

Thanks again






trastikata

Hello Peter,

Not being able to compile in SPI interface mode is my mistake. After adding the 800x480 display which is using parallel interface in version 1.05 I misplaced one of the Parallel commands under SPI pre-processor directives and the compiler was looking for a variable used only in Parallel interface mode.

I've uploaded corrected version 1.06 and included the Blackboard example here.

Quotethe first 6 sections (after the declare's) setup the parameters for the screens etc which I presume come from the TFT_Graphic_Lib.exe tool

Correct, this section instructs the pre-processor which routines to use.


Peter Truman

I was really optimistic - the new file appeared to compile perfectly - until it hit the assembler  :-\

Sadly, these error messages are hard for me to follow - I found 'SWCURRENT_X_POSITION' in the Blackboard.asm file, but I have no clue what the problem is there. So, at this point I'm afraid I'm completely at sea.

I did try another example file - but got the same result.

I'm guessing this runs fine on your machine so likely something wrong at this end?

I'm sure we will get there in the end
Thanks again

trastikata

Hello Peter,

I've just tried the blackboard project project zip file attached here and after decompression it compiles on both my machines. Did you try compiling it?

Can you compress to a zip file your entire project folder, including the library (without the Tools folder which is 300 Mb ) that gives the errors and post it here so I can take a look at it.

Peter Truman

Sure - try this.

trastikata

Quote from: Peter Truman on Jan 11, 2025, 02:35 AMSure - try this.

I've tested the project folder you sent me and there's no problem compiling it. Maybe somebody else can try to see if they have the same problem compiling the folder project?

Looking at the ASM error it made me thinking - I had similar issue some time ago after Windows update. Peter, I can suggest trying the following steps one by one:

1. Try executing Positron with elevated rights as Administrator.
2. Move the project folder from the system folders (C:\USERS\PEEWEE\...) to the drive C:\Project or something like this.
3. If all doesn't help, remove Positron completely and re-install it by executing the installation file with elevated rights as Administrator.

In my case point 3 and then executing Positron with elevated rights as Administrator resolved the issue with Positron but I still have problem with Windows starting other applications from the User folder (C:\USERS\...) if the application starts with normal user privileges.

https://protoncompiler.com/index.php?msg=15895

Pepe

I've tested the project folder in W11 and there's no problem compiling it.

Peter Truman

Hi guys - digging myself a little hole here. I tried running as an administrator - no go
Moved my files to a new directory in my main drive (I had this file in my Microsoft One Drive which I thought might be a problem) - no go
So I removed Positron (Proton) and did a whole new fresh install - based on the Trial setup in the website Trial setup

Cleaned everything up but now of course - I can't compile anything since I need a new registration key from Les

So I've emailed him and asked him what to do (he may spot this here first) - I even dug out my old dongle but of course, that no longer does anything.

Just for interest - is there a way to preserve my credentials so, if I ever have to do this again, I don't get locked out?

Thanks for the ongoing assistance - one foot in front of the other an we will get there!

trastikata

Hi Peter,

as far as I know the license is now included in the set-up file that Les sends and you don't need a registration key anymore.

I see the trial set-up is an old version "4.0.1.8-1.1.0.8.exe" maybe this has something to do with the failed compilation.


Peter Truman

I had thought the key would have expired (should have checked) so, this time I've reinstalled via the last link from Les - the install went ok (Compiler ver 4.0.3.3) with the code in another directory of the hard drive (not onedrive) [where do I check for compiler updates?]

Ran as an administrator - but I still get the same error!

Obviously something wrong with my setup here - I'll install on my creaky old laptop (or on my wifes PC - if she will let me) and try from there. Tea time in Aus si I'll have another crack at it tomorrow

Thanks for the ongoing support - much appreciated. (I don't know why hardware is called 'hard' much easier than this lol!)

Peter Truman

The mystery deepens!

I installed Positron on my creaky old laptop (Windows 8 'airgap' lol), copied the TFT zip file - copied over the blackboard.bas file and ran the compiler! Identical result 'Duplicate label[SWCURRENT_X_POSITION' or redefining symbol that cannot be redefined]

Next step for me is to install Positron on my wifes PC and source the TFT files direct from the site - likewise with the blackboard.bas (so nothing copied from wither my PC or my laptop)

Beyond that I have no idea what to try next - if anyone has any insights I'd love to hear them!

 

top204

#74
I have just downloaded the "Peter_TFT.zip" file and compiled its contents, and it compiles perfectly with the latest compiler version of 4.0.5.1.

I also have an older version of 4.0.4.2 on my machine, so I tried it with that version, and it also compiled perfectly.

If it is version 4.0.1.8 you are using Peter, it is time for the "upgrade", because that version is now nearly 3 years old, from 2022 (see the 'Whats New.htm' file in the IDE's 'Docs' folder, or from the 'Help->Documents' toolbar item). It is not just additional devices and items added in the updates and upgrades. It is also anomaly corrections, or syntax tightening that occurs in them, so it is important to keep the compilers up to date when using third party libraries or sources, because they will, usually, have written it using the latest versions.

If an important or commercial source code is required to be kept, it is wise to also make a note in the .bas file's header text, as to what compiler version was used for its release, and than make a copy of that compiler version by zipping up the ProtonIDE folder in "Program Files (x86)", before installing an update or upgrade, then using that version for the commercial source code, until the code has been tested on the later compiler versions for validity and any altering that is required. Then alter the header text to reflect the changes made etc... This is standard practice for all languages, because later versions of a program have been updated for a reason, and sometimes that reason effects older source code.

To use an older version of the compilers, simply unzip the, previously zipped, ProtonIDE folder to the C: root, and use the IDE within that folder. "C:\ProtonIDE\"

To make a fresh 'scratch' start on a machine. Uninstall the compilers, then delete the ProtonIDE folder in "Program Files (x86)", or "Program Files" on 32-bit Operating Systems, and any desktop links. Then re-install the compilers.

Peter Truman

Thanks Les - I had looked at 'help > documents >whats new' section previously - I don't know if I'm being particularly dense at the moment (it does happen) but I'm still at a loss to know where to actually get the latest version of the compiler?

The html file certainly shows the list of corrections / additions, as you mentioned but there are no clickable links on the page that I can find. I looked at the same file in the PDS docs folder but that also has no clickable links.

Am I missing something fundamental here? Is that page supposed to be clickable? Likewise - I have nothing at all listed in the 'Downloads' section of the forum - no content in any of the categories?

Sorry to be a pain but that's the state of play down in Tasmania as of now. (I'm going to be really embarrassed if I missed something simple  :o

Thanks again - appreciate your help.


John Lawton

Hi Peter,

the latest version for purchase is linked from this forum page:
https://protoncompiler.com/index.php/board,94.0.html

Maintenance updates are linked from here:
https://protoncompiler.com/index.php/board,85.0.html

Does that help or have I missed something?

John

Peter Truman

Thanks John - that seems to be it - downloading now. So I followed your link backwards and - there it was, right in front of me! Now I feel very silly! I can only claim I was misled by the header 'Positron Updates' lol

Peter Truman

Yay! Compiles ok now (so that was obviously the problem) - Thanks to all concerned, much appreciated.

I'll try and find some time later today to have a crack at programming the boards