• AVR Freaks

Using Mikromedia for PIC32 with Microchip Graphics Library

Page: 12 > Showing page 1 of 2
Author
ISCODE
New Member
  • Total Posts : 4
  • Reward points : 0
  • Joined: 2013/02/05 16:13:22
  • Location: 0
  • Status: offline
2013/02/05 23:43:47 (permalink)
0

Using Mikromedia for PIC32 with Microchip Graphics Library

Hi!
I'm using the Mikromedia board for PIC32 based on PIC32MX460F512L device, developed by Mikroelektronika design partner. I need to use this board and display TFT 320x240 QVGA with Microchip Graphics Library.
This display uses HX8347 driver and the serial memory (SPI) M25P80 to save the touch screen coordinates, both supported by Graphics Library. I'm using the Microchip Graphics Library v2012-10-15 and I've managed to integrate the library to this board I can successfully use the primitive functions and GOL objects as Buttons and Meters with 16bits color depth. But for an unknown reason the touch screen doesn't works, It seems that something is missing in the device configuration, according debugger ICD3 the program is locked waiting the answer of serial memory M25P80 on the file M25P80.c in funtion SST25ResetWriteProtection(); I checked all definitions and SPI channels, as well as the signal clock and CS all seems to be right, but whatever I do the program continues locked in that code.
The same way if I put in the code the function TouchInit(NVMWrite, NVMRead, NVMSectorErase, NULL); for touch screen initialization, on the screen display the text "Performing touch screen calibration Touch screen to continue" to proceed the calibration, however even if you press the touch screen is not detected, the screen doesn't change, as if never touch it. I suspect it is a ADC configuration because the funtion TouchGetX() and TouchGetY() are never executed.
I have not modified any files of M25P80.c, TouchScreen.c or TouchScreenResistive.c with corresponding files x.h only integrate the project.
I think need some help I'm lost and don't know what to do.
#1

27 Replies Related Threads

    Lurch
    Super Member
    • Total Posts : 640
    • Reward points : 0
    • Joined: 2010/08/04 14:05:04
    • Location: 0
    • Status: online
    Re:Using Mikromedia for PIC32 with Microchip Graphics Library 2013/02/06 01:49:21 (permalink)
    0
    What SPI pins are you using? The USB version of 32MX has its USB pins where the others have SPI1. I would check that first of all. If there is a conflict, you may need to change the pins - hopefully only in the HardwareProfile.h.
    Sounds in any case like the M25P80 is not responding.
    #2
    ISCODE
    New Member
    • Total Posts : 4
    • Reward points : 0
    • Joined: 2013/02/05 16:13:22
    • Location: 0
    • Status: offline
    Re:Using Mikromedia for PIC32 with Microchip Graphics Library 2013/02/06 10:49:00 (permalink)
    0
    SPI channel used is number 2
    USB is mounted on RG2 and RG3 pins.
    post edited by ISCODE - 2013/02/06 11:01:01
    #3
    ISCODE
    New Member
    • Total Posts : 4
    • Reward points : 0
    • Joined: 2013/02/05 16:13:22
    • Location: 0
    • Status: offline
    Re:Using Mikromedia for PIC32 with Microchip Graphics Library 2013/02/06 10:56:10 (permalink)
    0
    SPI channel used is number 2, the pins are
     
    #define SST25_CS_TRIS    TRISCbits.TRISC2
    #define SST25_CS_LAT      LATCbits.LATC2
    #define SST25_SCK_TRIS  TRISGbits.TRISG6
    #define SST25_SDO_TRIS  TRISGbits.TRISG8
    #define SST25_SDI_TRIS   TRISGbits.TRISG7
     
    In case of CS first is executed the instruction  PORTSetPinsDigitalOut(IOPORT_C, BIT_2); to make sure that the CS is a digital pin.
    After instruction SST25Init((DRV_SPI_INIT_DATA*)pInitData); everything runs normally until it gets to the function SST25ResetWriteProtection(); specifically in the loop library that show below, along with definitions are in a file x.h
     
    #define SST25_CMD_RDSR  (unsigned) 0x05
    #define SST25_STATUS_MASK (unsigned) 0x60
    #define SST25_WEL_STATUS (unsigned) 0x02
    #define SST25CSLow()    SST25_CS_LAT = 0;
    #define SST25CSHigh()   SST25_CS_LAT = 1;
     
    SST25CSLow();
    while (1) {
            SPIPut (spiInitData.channel, SST25_CMD_RDSR);
            SPIGet (spiInitData.channel);

            status = 0xFF;
            while ((status & SST25_STATUS_MASK) > 0)
            {
                SPIPut(spiInitData.channel, 0);
                status = SPIGet(spiInitData.channel);
            }
            if ((status & SST25_WEL_STATUS) == SST25_WEL_STATUS)
                break;
        }
        SST25CSHigh();
     
    The break is never executed, consequently the loop while(1) never is break, funtion SPIGet return always 0 and SST25_WEL_STATUS = 0x02 the if instruction is not true and the break is not executed.
     
    USB is mounted on RG2 and RG3 pins.
    #4
    Mysil
    Super Member
    • Total Posts : 3326
    • Reward points : 0
    • Joined: 2012/07/01 04:19:50
    • Location: Norway
    • Status: offline
    Re:Using Mikromedia for PIC32 with Microchip Graphics Library 2013/02/08 11:30:47 (permalink)
    0
    Hi,
    I am also using the mikromedia board from mikro elektronika.
    Have got Primitives demo and Graphic Objects Library demo to work. Still struggling with USB stuff.
     
    Started using the board some time ago with graphics library 3.04 when the HX8347 display driver was not ready for PIC32. Have done a heap of changes, especially to the display driver, M25P80 driver and to the Hardware profile.
     
    Your setup for SPI pins seems good to me.
    The M25P80 driver I use is essentially a clone of SST25VF016 driver with my changes. You may compare the files to see if any changes may be relevant.
     
    The HWP file has a number of changes related to the Resistive Touchpad and saving the calibration for the touchpad in M25P80. Some files that may be used to compare are attached. Unfortunately the hex file demonstrating GOL objects and touchpad is too large to be included.
     
    Regards,
      Mysil
     
    #5
    Mysil
    Super Member
    • Total Posts : 3326
    • Reward points : 0
    • Joined: 2012/07/01 04:19:50
    • Location: Norway
    • Status: offline
    Re:Using Mikromedia for PIC32 with Microchip Graphics Library 2013/02/09 13:13:06 (permalink)
    0
    Hi again,
    Have experimented with a fresh download of Microchip libraries v2012-10-15 to try to identify the reason for your problems.
    The "MainDemo.c" source file contain a number of device and board dependent settings and initializations in addition to those in "HardwareProfile" and "HWP_...".
    There is even an error in configuration settings for PIC32 where settings for PLL input divider and PLL output divider has been swapped! Does no one ever test these programs?
     
    The changes I have made in "MainDemo.c" for the GOLDemo PIC32 is attached. It should be used together with the "HWP_Mikro_PIC32_16PMP.h" posted yesterday. 
    Remember to set a sufficient "Heap" size. I forgot to do that.
     
    The program has also been built for PIC24FJ256GB110 on mikromedia for PIC24. The same "MainDemo.c" and "HWP_Mikro_PIC32_16PMP.h" may be used, just remove the settings in the "Human generated code" section, and let the settings in "HardwareProfile.h" take precedence.
     
    There is an error in the "Toggle Button" on the first GOL screen. I have not yet looked into the reason. Does anyone know anything about this?
     
    Have fun,
      Mysil
    #6
    ISCODE
    New Member
    • Total Posts : 4
    • Reward points : 0
    • Joined: 2013/02/05 16:13:22
    • Location: 0
    • Status: offline
    Re:Using Mikromedia for PIC32 with Microchip Graphics Library 2013/02/16 17:09:46 (permalink)
    0
    HELLO!!
     
    Thank you friend, the problem has been solved, there was something wrong in the configuration file HardwareProfile.h change this file for yours file uploaded, also had a problem with TickInit() function.
     
    Now the board works alright, Thank you so much!!
    #7
    Evgeny
    Senior Member
    • Total Posts : 138
    • Reward points : 0
    • Joined: 2003/11/07 12:39:19
    • Location: Toronto, Canada
    • Status: offline
    Re:Using Mikromedia for PIC32 with Microchip Graphics Library 2013/02/18 08:47:55 (permalink)
    0
    Hello Mysil,
    I tried to use your Hardware Profile and Main files, but got a long list of "undefined" messages and failed compillation:
     
    Objects - Object Layer\MainDemo.o: In function `main':
    C:/Users/CALavrentiev/Desktop/My_Handheld_VNA/Mikromedia/GOLDemo_mikromedia/MainDemo.c:565: undefined reference to `TouchGetMsg'
    Objects - Object Layer\MainDemo.o: In function `StartScreen':
    C:/Users/CALavrentiev/Desktop/My_Handheld_VNA/Mikromedia/GOLDemo_mikromedia/MainDemo.c:1331: undefined reference to `_color'
    C:/Users/CALavrentiev/Desktop/My_Handheld_VNA/Mikromedia/GOLDemo_mikromedia/MainDemo.c:1380: undefined reference to `_color'
     
    Could you please advice what I did wrong?
    Evgeny
    #8
    Mysil
    Super Member
    • Total Posts : 3326
    • Reward points : 0
    • Joined: 2012/07/01 04:19:50
    • Location: Norway
    • Status: offline
    Re:Using Mikromedia for PIC32 with Microchip Graphics Library 2013/02/20 14:16:43 (permalink)
    0
    Hi Evgeny!
     
    TouchGetMsg     is a function in TouchScreen.c and TouchScreen.h   files. They should be found in "Board Support Package", and need to be added to your project. 
    C:\Microchip Solutions v2012-10-15\Board Support Package\TouchScreen.c  and ...\TouchScreen.h
    C:\Microchip Solutions v2012-10-15\Board Support Package\TouchScreenResistive.c   and ...\TouchScreenResistive.h   will also be needed, and possibly others.
     
    _color     is a global variable that is defined by the display driver file HX8347.c and HX8347.h  and used by the general display driver interface: DisplayDriver.h 
    C:\Microchip Solutions v2012-10-15\Microchip\Graphics\Drivers\HX8347.c
    C:\Microchip Solutions v2012-10-15\Microchip\Include\Graphics\HX8347.c
    C:\Microchip Solutions v2012-10-15\Microchip\Include\Graphics\DisplayDriver.h
     
     
    The files I attached with previous posts have been used with Microchip Graphics Library v3.04.02 and v3.06.02 in Microchip Application Library examples in Microchip Solutions v2012-10-15. 
    And the Microchip MPLAB C32 toolchain.
     
    It may seem that you may be trying to compile the example using MikroElektronika compiler and libraries?
    Do you have microchip-application-libraries-v2012-10-15  and Microchip compiler and libraries installed?
     
    I have never tried to compile GOL examples with MikroElektronika compiler.
     
    Best regards,
       Mysil
     
    #9
    Evgeny
    Senior Member
    • Total Posts : 138
    • Reward points : 0
    • Joined: 2003/11/07 12:39:19
    • Location: Toronto, Canada
    • Status: offline
    Re:Using Mikromedia for PIC32 with Microchip Graphics Library 2013/02/20 21:13:49 (permalink)
    0
    Hello Mysil,
    Thanks for your help.  All errors gone except for undefined pCalDataRead/Write functions.
    Could you advice they are supposed to be defined?
     
    I am not using Mikro compiler, just tried to change color of error messages.
    Evgeny
    #10
    Mysil
    Super Member
    • Total Posts : 3326
    • Reward points : 0
    • Joined: 2012/07/01 04:19:50
    • Location: Norway
    • Status: offline
    Re:Using Mikromedia for PIC32 with Microchip Graphics Library 2013/02/21 03:45:47 (permalink)
    0
    Hi again Evgeny,
    Good, you are closer than I feared.
     
    The pCalDataRead and pCalDataWrite symbols are defined by macro definitions in HWP... file to be functions in SPI flash driver routines.
    You should add either M25P80.c and M25P80.h
    or SST25VF016.c and SST25VF016.h    to your project.
    C:\Microchip Solutions v2012-10-15\Board Support Package\M25P80.c 
    C:\Microchip Solutions v2012-10-15\Board Support Package\M25P80.h
     
    Hope you will get further with this.
       Mysil
    #11
    Mysil
    Super Member
    • Total Posts : 3326
    • Reward points : 0
    • Joined: 2012/07/01 04:19:50
    • Location: Norway
    • Status: offline
    Re:Using Mikromedia for PIC32 with Microchip Graphics Library 2013/02/21 12:38:22 (permalink)
    0
     
    Hi, Question for Evgeny:
     
    Are you trying to run this on MikroElektronika  MultiMediaBoard for PIC32MX4
    or on MikroElektronika   mikromedia for PIC32,
    or do you have access to both?
     
    At one time, I tried to integrate HWP_MIKRO_MMB_PIC32MX4_16PMP_320x240TFT.h   from ErnieM
    with my HWP_Mikro_PIC32_16PMP.h 
    but they are based on different versions of MAL, so there are lots of differences.
    I do not have the MIKRO_MMB hardware, so it has never been tested.
     
    Mysil
    #12
    Evgeny
    Senior Member
    • Total Posts : 138
    • Reward points : 0
    • Joined: 2003/11/07 12:39:19
    • Location: Toronto, Canada
    • Status: offline
    Re:Using Mikromedia for PIC32 with Microchip Graphics Library 2013/02/22 06:30:56 (permalink)
    0
    I have Mikro MMB board.
    It works fine with old Graphic Lib, but so far I did not manage to run it with latest MLA 3.06.02 and hoped your experience would help me

    it.
    Evgeny

    #13
    Mysil
    Super Member
    • Total Posts : 3326
    • Reward points : 0
    • Joined: 2012/07/01 04:19:50
    • Location: Norway
    • Status: offline
    Re:Using Mikromedia for PIC32 with Microchip Graphics Library 2013/02/23 08:09:58 (permalink)
    0
    Hi again
     
    Have tried to compare and integrate HWP_... file for Mikro MultiMediaBoard and my HWP_... file for the Mikromedia board. As I do not have the Mikro MMB, I hope you could try to build and test the attached project. 
    The test program is based on the Graphics\Primitive Layer\Primitives Layer Demo PIC32.    project.
     
    The attachment contain project files and source code that is modified from MAL v2012-10-15.
    It will refer to other files in the "Board Support" and "Microchip" directories.
    When unpacking the archive, the "\Primitive Layer Test"   directory should be placed in "\Graphics" directory at the same level as existing "Primitive Layer"    directory. 
    Subdirectory  "Primitive Layer Test\Configs" contain the "HWP_Mikro_PIC32_16PMP.h" file that I use for mikromedia for PIC32 and for mikromedia for PIC24F, and that has been modified to hopefully work with Mikro MMB.
    Subdirectory "Graphics" contain display driver "HX8347.c" with my modifications for transparent color in pictures, antialiased text and hopefully efficient clipping. 
    There is also a modified version of "Primitive.c" to make it work for display of partial images with RLE compression. Some timing routines are also present.
     
    If anyone else want to test the HX8347 driver, and tell what works or not, it would be helpful. 
    See descriptions in "HardwareProfile.h" and "GraphicsConfig.h"
     
    The "MainDemo.c" is a modification of Primitives Layer Demo with time measurements.
    Contents of mstime[] array is:
    mstime[0]    ClearDevice
    mstime[1]    Lines and Circles
    mstime[2]    Bevel shapes
    mstime[3]    Arc drawing
    mstime[4]    Squares and Blocks
    mstime[5]    Poly line
    mstime[6]    Text rendering
    mstime[7]    Rose pictures
    mstime[8]    Pictures with transparency
    mstime[9]    (Bitmap picture 320x240)
     
    Regards,
        Mysil
     
    #14
    Evgeny
    Senior Member
    • Total Posts : 138
    • Reward points : 0
    • Joined: 2003/11/07 12:39:19
    • Location: Toronto, Canada
    • Status: offline
    Re:Using Mikromedia for PIC32 with Microchip Graphics Library 2013/02/24 06:59:34 (permalink)
    0
    Hello Masil,
    Thanks for sharing your project. The Demo works fine with MikromediaMMB board!
    Could you advice how to integrate touchscreen functions into project.
    May be you could adjust Object Layer project for MMB?
    Evgeny
    #15
    Mysil
    Super Member
    • Total Posts : 3326
    • Reward points : 0
    • Joined: 2012/07/01 04:19:50
    • Location: Norway
    • Status: offline
    Re:Using Mikromedia for PIC32 with Microchip Graphics Library 2013/02/24 12:07:54 (permalink)
    0
    Good,
    Now we are getting somewhere.
    Yes, I will share a version of the Object Layer project, but you may also try to do that yourself.
     
    You may move or copy the "HX8347.c" display driver file to the "Object Layer" directory, or to: 
    "Microchip\Graphics\Drivers\HX8347.c", and then adjust the Object Layer project accordingly.
    the include file should be either in subdirectory "...\Object Layer\Graphics\HX8347.h" or
    "...\Microchip\Include\Graphics\HX8347.h
     
    Check the "HardwareProfile.h",  it should have " #define  MIKRO_BOARD "  for use with your board,
    make a comment of the " mikromedia_BOARD" definition. Make sure you look at the __PIC32__ section.
    You may put comment signs on all " #include Configs/... " you do not use.
     
    Copy "HWP_Mikro_PIC32_16PMP.h" either to the subdirectory "Object Layer\Configs\"
    or as I have started to prefer, to: "...\Board Support Package\Configs\HWP_Mikro_PIC32_16PMP.h"
     
    Use the "MainDemo.c" file I published in this thread some days ago, it is for the "Object Layer" program.
     
    in the file "GraphicsConfig.h", you may have to define:

     #define    USE_TRANSPARENT_COLOR
     #define    USE_CLIPPING_PUTIMAGE

     
    Look at the "Build Options" for the project, the tab: "Directories", select: "Show directories for:"  "Include Search Path",
    it should be something like this:

    .
    ..\..\Board Support Package
    ..\..\Microchip\Include

    or:

    .
    .\Graphics
    ..\..\Board Support Package
    ..\..\Microchip\Include

     
    When compiling, ignore warnings about: ..."TRIS_XPOS is deprecated  please use ResistiveTouchScreen...",
    the "HWP_Mikro_PIC32_16PMP.h" file contain macros for both old and new Touchpad driver.
    You may want to make a backup of existing projects that work before making changes.
     
    Regards,
       Mysil
    #16
    Mysil
    Super Member
    • Total Posts : 3326
    • Reward points : 0
    • Joined: 2012/07/01 04:19:50
    • Location: Norway
    • Status: offline
    Re:Using Mikromedia for PIC32 with Microchip Graphics Library 2013/02/28 08:32:12 (permalink)
    +2 (1)
    Hi again,
     
    Here is the Object Layer Demo program adapted to run on MikroElektronika mikromedia board for PIC32MX and PIC24F and hopefully also MikroElektronika MultiMedia Board for PIC32MX4.
    It has taken some time to tidy up and package the project within the 200 k limitation of the forum server.
     
    The attachment contain a hopefully improved Display driver for HX8347-D  display controller, and
    a "HWP_Mikro_PIC32_16PMP.h"   Hardware Profile configuration file that is intended to work also for Mikro MMB PIC32MX4 and mikromedia for PIC24F. Only Display, resistive TouchPad and SPI Flash Memory, as used by TouchPad calibration has been tested.
    Display of images stored in External memory has not been tried
     
    Two files from Graphics Library v3.06.02 has been corrected to help optimize display of Part of an Image, and RLE compressed Bitmap images. Bitmap images with Transparent color should work.
    Display of the 158x55 pixel RLE compressed image, stretched to 316x110 pixels on the introduction screen, takes 127 millisecond when rendered by Primitives library and simple driver using "PutPixel(x, y)" function. Using improved driver, the picture needs 10 millisecond to display .
    The same picture displayed in 4 parts use 15 ms.
     
    Display of a part of an image is performed by shifting the upper left corner of the picture to coordinates that may possibly be outside the screen, and then use clipping to show the wanted part of the picture only. This works also for RLE compressed bitmap image.
    To guide the interface between Primitives library layer and Display Driver functions, a new macro: USE_CLIPPING_PUTIMAGE   is used. See "GraphicsConfig.h" for description.
     
    Antialiased characters may be used. For use with Antialiased characters, Pixel color is read back from Frame Memory in the HX8347 display controller by  "color = GetPixel(x,y)". 
    The timing requirements for reading from the HX8347 controller is significantly different from writing. Read cycle time  is 450 ns vs. Write cycle time of 66 ns.  
    Read timing and Write timing is thus defined separately in "HWP_Micro..." configuration.
    The Wait-States settings of the ParallelMasterPort are changed when driver is switching between writing and reading. The PMP has a maximum of 23 wait states, thus the minimum Peripheral Bus cycle time is between 20 and 25 nanosecond. The maximum PB frequency is thus between 40 and 50 MHz. If the Peripheral Bus clock frequency is too high, the PB Clock Divider will be changed when the  driver is initialized.
     
    Display of images stored in External memory has not been tried
     
    Unpacking files from the zipfile will place files only in directory "\Object Layer Test\"  and subdirectories. It should be possible to build the program in this directory. Project will read many files from other directories in "Microchip Solutions v2012-10-15\" installation, so should be installed in "\Graphics\" directory at same level as the "\Object Layer\"  project, like this:
    "Microchip Solutions v2012-10-15\Graphics\Object Layer Test\..."
     
    For general usage, "Primitive.c" and "Picture.c" may be copied to "Microchip\Graphics\"  
    "HX8347.c"  to "\Microchip\Graphics\Drivers\"
    "HX8347.h"  to "\Microchip\Include\Graphics\"
    "TouchScreenResistive.c" belong in "\Board Support Package\".
    I prefer to maintain just 1 instance of the "HWP_Mikro_PIC32_16PMP.h" file, and keep it in:
    "Board Support Package\Configs\HWP_Mikro_PIC32_16PMP.h"
     
    Have fun,
    Mysil
    #17
    Evgeny
    Senior Member
    • Total Posts : 138
    • Reward points : 0
    • Joined: 2003/11/07 12:39:19
    • Location: Toronto, Canada
    • Status: offline
    Re:Using Mikromedia for PIC32 with Microchip Graphics Library 2013/03/04 03:54:51 (permalink)
    0
    Hello Mysil,
    Your project works! Thanks a lot. I will save me plenty of time.
    My display requires calibration since there is 5 mm offset between touch and response.
    Please advice how to calibrate.
    #18
    Mysil
    Super Member
    • Total Posts : 3326
    • Reward points : 0
    • Joined: 2012/07/01 04:19:50
    • Location: Norway
    • Status: offline
    Re:Using Mikromedia for PIC32 with Microchip Graphics Library 2013/03/04 15:28:05 (permalink)
    0
    Hi Evgeny,
    You get to recalibrate the touchpad by keeping a touch on the screen while the program is starting.
     
    Mysil
    #19
    Evgeny
    Senior Member
    • Total Posts : 138
    • Reward points : 0
    • Joined: 2003/11/07 12:39:19
    • Location: Toronto, Canada
    • Status: offline
    Re:Using Mikromedia for PIC32 with Microchip Graphics Library 2013/03/04 18:35:11 (permalink)
    0
    Perfect! Calibration works.
    You've done a great job Mysil!
    #20
    Page: 12 > Showing page 1 of 2
    Jump to:
    © 2019 APG vNext Commercial Version 4.5