Menu

Max7219 libraries use

G. C.
2023-10-20
2023-10-21
  • G. C.

    G. C. - 2023-10-20

    Hi there,
    I just joined the forum.. Saw by serendipity in the past days this amazing compiler for PICs (let me tell you immediately that it's a really great initiative and the developers team deserves a BIG thank you for sharing their knowledge).

    Just after installing and tried successfully simple I/Os programs, I am trying something more complex . Reading the examples of use of the MAX7219 lib it seems possible to use generic pins of any uC for sending commands to the matrix modules, can you confirm this? Or it's mandatory to use the SPI HW peripheral unit?

    I tried several commands for sending some strings to the matrix modules, but do not get an output and would like to ask what's wrong with the source code I am writing at the bottom of this post (I use a 16F886 with an external 8 MHz crystal and some generic port pins that are already soldered onto a proto board and can't be redirected as this uC has not the PPS). Any suggestion is welcome..

    Another question about the programmer: at present I have an ICD3 and use it with Microchip IPE once GCB has created the HEX file.. It's a bit boring to move back and forth from the two environments, so if there is a way to make use of ICD3 as a programmer directly from GCB IDE would be great..

    Also, there is plenty of chines clones of Pickit2/3 to buy on the web, do you have a suggestion on wich one to buy that will surely work with GCB (I saw even a Pickit 3.5 version..?!?).

    Thanks in advance and regards,
    GC

    '''GCBASIC Program.
    '''--------------------------------------------------------------------------------------------------------------------------------
    '''Description:  [Program for led matrix prototype]
    '''
    '''@author     [GC]
    '''@licence    GPL
    '''@version    [0.1]
    '''@date       [19 oct 2023]
    '''********************************************************************************
    
    '''----- Includes
      #include <Max7219_LEDMATRIX_Driver.h>
    
    
    '''----- Configuration
    #config OSC = HS
    
    
    '''----- Define Hardware settings
    #chip 16f886, 8
    
    
    'Set SPI pins for the Max7219
      #define Max7219_SCK   portc.3 
      #define Max7219_DI    portc.5        
      #define Max7219_CS    portc.7
    
    'I do not use this pin (output from the max7219 modules), but the compiler wants its to be defined
      #define Max7219_DO portc.0
    
      'Specifics for device configuration
      #define MAX7219_X_Devices 4
    
    
    '''----- Variables
    
    '''----- Interrupts
    
    '''----- Main body of program
    dir portc.3 out
    dir portc.5 out
    dir portc.7 out
    
    Max7219_LEDMatrix_Brightness ( 1 )
    
    
    Do forever
    
        MAX7219_LEDMATRIX_GLCDCLS
        GLCDPrint  (2, 0, "Hi there, trying the led matrix!")
        wait 3 s
    
        MAX7219_LEDMATRIX_GLCDCLS
        Max7219_LEDMatrix_ScrollMessage ("bye bye bye bye bye bye..",10)
        wait 3 s
    
    Loop
    
    
    '''----- Subroutines
    
    '''----- Lookup Tables
    
     

    Last edit: Anobium 2023-10-20
  • Anobium

    Anobium - 2023-10-20

    Welcome G.C.

    Thank you for the kind words. I am am sure that each of the team is very grateful.


    Just after installing and tried successfully simple I/Os programs, I am trying something more complex . Reading the examples of use of the MAX7219 lib it seems possible to use generic pins of any uC for sending commands to the matrix modules, can you confirm this? Or it's mandatory to use the SPI HW peripheral unit?

    The default for the MAX7219 library is to use any valid I/O. To enable SPI HW then you would add #define MAX7219_LEDMatrix_HardwareSPI


    I tried several commands for sending some strings to the matrix modules, but do not get an output and would like to ask what's wrong with the source code I am writing at the bottom of this post (I use a 16F886 with an external 8 MHz crystal and some generic port pins that are already soldered onto a proto board and can't be redirected as this uC has not the PPS). Any suggestion is welcome..

    I think you have DataOut and DataIn swapped. DO is DataOut fom the uC.


    Another question about the programmer: at present I have an ICD3 and use it with Microchip IPE once GCB has created the HEX file.. It's a bit boring to move back and forth from the two environments, so if there is a way to make use of ICD3 as a programmer directly from GCB IDE would be great..

    ICD3 can be setup. To automatically program.

    In Preferences add a new tool with the following parameters. Drag this new tool to the top of the 'programmer to use' list..

    [tool = ICD2_pic_ipecmd_program_release_from_reset_ext]
    desc = MPLAB-IPE ICD3 CLI for PIC using external power
    type = programmer
    command = %mplabxipedirectory%\ipecmd.exe
    params = -TICD3 -P%chipmodel%  -F"%filename%" -M  -E -OL
    workingdir = %mplabxipedirectory%
    useif = 
    progconfig = 
    

    If this does work... as I cannot test. Please upload the working configuration ( so, I can add this to the Gold Build). Attach to a post.

    If this does not work. Ping me directly. I will help you add. ( So, , I can add this to the Gold Build!) :-)


    Also, there is plenty of chines clones of Pickit2/3 to buy on the web, do you have a suggestion on wich one to buy that will surely work with GCB (I saw even a Pickit 3.5 version..?!?).

    Buy a PK2 kit and the software from www.pickitplus.co.uk Much more functional and a lot faster. And, it supports the project. :-)

     
    • G. C.

      G. C. - 2023-10-21

      Thank Anobium!!

      1) Just swapping the DI/DO pins definition solved the problem, as you said. I was confused thinking that Max7219_DO was an attribute of the driver chip, and not of the uC. I should have got right when the compiler required assignment od DO pin,wich is of course absolutely necessary. And now removing the "DI" line creates no warning/error..
      2) I saw the pickkits, lot of choices and thinking to wich one to order.. Just an assurance: yr pickit 2 works also with the recent PIC, right (it seems also with the PIC24 family..)?
      I saw some discussions where the PICKIT2 (but I think they were referring to the "original") was not a good choice for newer model, recommending the PICKIT3..
      3) As per the ICD3 programming: I tried to configure an additional programmer as you suggested, but it does'nt work and when compilig get an error like this ".. can't open file ... C:\prog..etc.. \MPLAB_clusters for reading". I guess It means I have to set up correctly the IPE directory.. But invoking the IPE by the Shell window using the directory I put onto the programmers preferences, it gets launched correctly. I'll try to play around it and find out how to make it work.. Perhaps putting a PATH somewhere I should overcome the issue.

      Thanks a lot and have a good day,
      GC

       
      • Anobium

        Anobium - 2023-10-21

        Great is working.

        Pickit2 is better. Has basic USART terminal and basic logical analysers.

        PICKIT+ software supports all the new chips. I am adding 18FxxQ20 at the moment.

        Re ICD3. Do not struggle -ping me. Let us get on a call.

         
    • G. C.

      G. C. - 2023-10-21

      Here are some details:

      MPLAB IPE directory:
      C:\Program Files\Microchip\MPLABX\v6.15\mplab_platform\mplab_ipe
      this contains icd3cmd.exe, ipecmd.exe, pk3cmd.exe files etc..

      Directory of the mplab_ipe64.exe file:
      C:\Program Files\Microchip\MPLABX\v6.15\mplab_platform\bin

      Attached pictures of the error msg and programmers parameters.
      Rgds,
      GC!

       
      • Anobium

        Anobium - 2023-10-21

        Send me you USE.INI file. I will edit and send back.

        or, try this

        The issue is that you have hard coded the application location - use %mplabxipedirectory%\ipecmd.exe

        I also think there is no space in `TICD3"

        Then, ensure the the mplabxipedirectory in the Tool Variables table is set to the correct location C:\Program Files\Microchip\MPLABX\v6.15\mplab_platform\mplab_ipe

         
        • G. C.

          G. C. - 2023-10-21

          Thanks for yr kind support..

          I removed the space in TICD3, used %mplabxipedirectory%\ipecmd.exe, and checked the and changed the mplabxipedirectory (wich was wroong, see the picture attached).
          But the error is still there. I am attaching you the USE.INI file too.

          GC

           
          • Anobium

            Anobium - 2023-10-21

            There are few errrors in the programmer.

            Try this. Find tool = mplab_ipe64 and delete the whole section. Use this.

            You still has hard coded locations and you are passing the mplab directory as a parameter.

            [tool = mplab_ipe_ICD3_use_ext_power]
            desc = MPLAB-IPE ICD3 CLI for PIC using external power
            type = programmer
            useif = 
            progconfig = 
            command = %mplabxipedirectory%\ipecmd.exe
            params = -TICD3 -P%chipmodel% -M -F"%filename%" -OL
            workingdir = %mplabxipedirectory%\ipecmd.exe
            

            I am assuming that you do have MPLAB 6.15 installed as shown in the section toolvariables

            mplabxipedirectory = C:\Program Files\Microchip\MPLABX\v6.15\mplab_platform\mplab_ipe
            

            If you are using another version of MPLAB then update the tool parameter.

            Then, save the USE.INI and select this programmer in the Prefs Editor. You must reselect the parameter after editing.

             
            • G. C.

              G. C. - 2023-10-21

              I have done as you said, removed the section tool = mplab_ipe64,

              and copied/pasted and saved into the USE.INI file this one:

              [tool = mplab_ipe_ICD3_use_ext_power]
              desc = MPLAB-IPE ICD3 CLI for PIC using external power
              type = programmer
              useif =
              progconfig =
              command = %mplabxipedirectory%\ipecmd.exe
              params = -TICD3 -P%chipmodel% -M -F"%filename%" -OL
              workingdir = %mplabxipedirectory%\ipecmd.exe

              Then relaunched GCB, tried Hex&Flash, this time got this output:

              Downloading program ...MPLAB-IPE ICD3 CLI for PIC using external power
              Calling : C:\Program Files\Microchip\MPLABX\v6.15\mplab_platform\mplab_ipe\ipecmd.exe
              Parameters : -TICD3 -P16F886 -M -F"C:\Users\GC\Documents\Matrix\GCB Project\main.hex" -OL
              DFP Version Used : PIC16Fxxx_DFP,1.4.149,Microchip
              Programmer not found.

              This time it's only the programmer not found... We're improving, but still not there.

               
              • G. C.

                G. C. - 2023-10-21

                Thisi is what the Pro Editor and preferences in the tool tab look like

                 
              • Anobium

                Anobium - 2023-10-21

                I may have it!

                -TICD3 should be -TPICD3 ( a missing P).

                I just checked the Help for IPECMD

                T        P = Tool Selection.
                                      E.g -TPRICE for RealICE -TPPK3 for PICKIT3
                                     S = Specific Tool Selection using Serial No.
                                      E.g -TSBUR1234566
                                     Short Name for Tools
                                     REALICE - RICE
                                     ICD3    - ICD3
                                     PICKIT3 - PK3
                                     PM3     - PM3
                                     ICD4     - ICD4
                                     ICE4     - ICE4
                                     PICKIT4  - PK4
                                     SNAP    - SNAP
                                     PKOB3    - PKOB
                                     PKOB4    - PKOB4
                                     J-32      - J32
                

                Edit, test and let us know the result. When it works post the USE.INI section that works. We do not want people in the future to have to learn all this. :-)

                 
                • G. C.

                  G. C. - 2023-10-21

                  Great, this time you nailed it..!!! It works, this is the output once i simply edited the command parameters in the preferences:

                  Downloading program ...MPLAB-IPE ICD3 CLI for PIC using external power
                  Calling : C:\Program Files\Microchip\MPLABX\v6.15\mplab_platform\mplab_ipe\ipecmd.exe
                  Parameters : -TPICD3 -P16F886 -M -F"C:\Users\GC\Documents\Matrix\GCB Project\main.hex" -OL
                  DFP Version Used : PIC16Fxxx_DFP,1.4.149,Microchip


                  Connecting to MPLAB ICD 3...
                  Currently loaded firmware on ICD 3
                  Firmware Suite Version.....01.56.10
                  Firmware type..............Midrange
                  Target voltage detected
                  Target device PIC16F886 found.
                  Device Revision ID = 2
                  Device Erased...
                  Programming...
                  The following memory area(s) will be programmed:
                  program memory: start address = 0x0, end address = 0x65f
                  configuration memory
                  Programming/Verify complete
                  ICD3 Program Report
                  2023-10-21, 15:09:31
                  Device Type:PIC16F886
                  Program Succeeded.
                  Operation Succeeded
                  (Download time: 29.25 seconds)

                  Attached the latest USE.INI file.

                  Many thanks to you, happy to have given also a little help to other potential users of the ICD3..
                  Have a good weekend,
                  GC

                   
                  • Anobium

                    Anobium - 2023-10-21

                    Brillant. Good to know it works.

                    It is slow to program but that is the nature of ICD3 and the use of PK3CMD. A PICKit2 would take a second.... :-)

                    Thanks for the USE.INI. I will merge into the master ini file for others in the future.

                    :-)

                     
        • G. C.

          G. C. - 2023-10-21

          Now I tried this:in the Programmer Editor, after having changed the directory in the tool variables to the correct one, C:\Program Files\Microchip\MPLABX\v6.15\mplab_platform\mplab_ipe :

          File:
          %mplabxipedirectory%\ipecmd.exe

          Command line parameters:
          %mplabxipedirectory%\ipecmd.exe -TICD3 -P%chipmodel% -F" %filename%" -M -E -OL

          Working directory:
          %mplabxipedirectory%

          and got the following terminal output, but not the previous error message of file not found (this time is the programmer and Hex file not found!):

          Downloading program ...MPLAB-IPE ICD3 CLI for PIC using external power
          Calling : C:\Program Files\Microchip\MPLABX\v6.15\mplab_platform\mplab_ipe\ipecmd.exe
          Parameters : C:\Program Files\Microchip\MPLABX\v6.15\mplab_platform\mplab_ipe\ipecmd.exe -TICD3 -P16F886 -F" C:\Users\GC\Documents\Matrix\GCB Project\main.he
          x" -M -E -OL
          DFP Version Used : PIC16Fxxx_DFP,1.4.149,Microchip
          Programmer not found.
          Hex File not found

          A warning has been generated:

          Warning: The chip may not have programmed properly. Programmer returned status (36)

           
  • mmotte

    mmotte - 2023-10-20

    Max7219 also drives 8 digit 7 segment displays available on ebay and others.

    Here is a driver for Max7219 7seg.

    BR
    Mike

     
    • G. C.

      G. C. - 2023-10-21

      Yes Mike, I saw the potential of this chip in conjuction with GCBasic.. and there are plenty of additional graphic devices/displays supported with libraries that simplify the firmware creation.. I am sure I'll have some fun with GCB in the future.
      Bye, GC

       

Log in to post a comment.