The following warnings occurred:
Warning [2] Use of undefined constant CKEDITOR_PLUGINROOT - assumed 'CKEDITOR_PLUGINROOT' (this will throw an Error in a future version of PHP) - Line: 17 - File: inc/plugins/ckeditor.php PHP 7.4.9 (Linux)
File Line Function
/inc/plugins/ckeditor.php 17 errorHandler->error
/inc/class_plugins.php 38 require_once
/inc/init.php 233 pluginSystem->load
/global.php 18 require_once
/showthread.php 24 require_once




7.4" TCM with PIC32MZ
#1
Hello, 
I have MpicoSys 7.4" Solutions kit and I am attempting to drive the display with a PIC32MZ through SPI. I tested the display with the USB2TCM using the MpicoSys convert tool to convert the smiley face image (attached) which worked perfectly.
   

I've gotten to the point where I can send commands like refresh display and reset data pointer to the display and receive correct responses back. Now I am able to upload image data but it comes out distorted.
   

I tested by using the .h file that the MpicoSys convert tool generated from that smiley face. I've checked the waveform of the USB2TCM on my oscilloscope and tried to match it as best I can but the image doesn't seem to want to come out correctly. 

I'm sort of at a loss as to what the issue is because I've checked the minimum and maximum timing specs for the 7.4'' display and I believe I'm meeting the requirements. Are there any common issues that I should be looking out for?

Here are a couple pictures of the signals that I'm generating with the PIC32MZ
Yellow is /CS
Purple is MOSI
Blue is SCK
Green is MISO

   
   
   



Thanks in advance,
Ben.


Edit:
Another question, I was looking at the Developer's guide PDF for the TCM and I understand that the tool must interlace the image according to Pixel Data Format Type 4, so are the bytes in the .h organized correctly according to this? Because my program just takes the array and outputs it sequentially.

I was also wondering if anyone has created any graphics libraries for the display. Looking for something simple that can draw simple shapes and ideally also write text to the display.


Attached Files Thumbnail(s)
   
Reply
#2
Hi,

Our engineer will look into your issue tomorrow. I'll keep you posted.

Best regards,

Michal
Reply
#3
Dear Ben,

The .h files contain 16 bytes of header and, in case of 7.4" displays, 48000 bytes of data. The correct array in case of 7.4 displays should start with the following 16 bytes:
0x3A, 0x01, 0xE0, 0x03, 0x20, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00

If so far everything is correct, then you have to properly formulate the command. The maximum command size is 255 bytes, therefore images have to be sent in packets. A correct UploadImagedata packet between the host and the device should look like this:
0x20, 0x01, 0x00, Lc, Data
where Lc is packet size (max 0xFA) and Data is a chunk of the aforementioned array.

Do you send the image as described above? If not:
What is the exact product code of the TCM you are using? (e.g. TCM-P74-230_v1.1)
What response do you receive from the TCM?
Could you share your code?
Reply
#4
Quote:'Tomasz.Krajewski' pid='531' dateline='1461235751'
Dear Ben,

The .h files contain 16 bytes of header and, in case of 7.4" displays, 48000 bytes of data. The correct array in case of 7.4 displays should start with the following 16 bytes:
0x3A, 0x01, 0xE0, 0x03, 0x20, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00

If so far everything is correct, then you have to properly formulate the command. The maximum command size is 255 bytes, therefore images have to be sent in packets. A correct UploadImagedata packet between the host and the device should look like this:
0x20, 0x01, 0x00, Lc, Data
where Lc is packet size (max 0xFA) and Data is a chunk of the aforementioned array.

Do you send the image as described above? If not:
What is the exact product code of the TCM you are using? (e.g. TCM-P74-230_v1.1)
What response do you receive from the TCM?
Could you share your code?







Yeah I have it sending commands as you describe. I have an array for the 48016 byte image with the correct 16 byte header at the beginning. 
I send the UploadImageData command as you described. Lc is set to 100 initially to send 100 bytes at a time and then once there is less than 100 bytes left it is set to the number of bytes remaining. 

Here is what the UploadImageData packet looks like:
   

It sends the first three bytes (0x20, 0x01, 0x00) then after a delay of 115 us it sends Lc. Then the data bytes begin being sent one byte at a time with 115us delay between them.

Below you can see a closeup of the first 3 bytes being sent as well as the response I've received from the previous command. It appears to be 0x900090. 0x9000 is the 'Normal Processing' response so that seems like its not an issue. 


.bmp   IMG_0072.BMP (Size: 301.05 KB / Downloads: 91)

Here is the important bit of code below. Sorry it is a little messy, I was unaware of the timers that could be used on the PIC platform. 
Explanation bit:

appData.l_idle - is for counting a delay. It is relies on the clock so if(++appData.l_dle > 10) is just a delay. 10 doesn't mean anything specific it just gave the desired delay.
appData.txData - pointer to the memory that needs to be sent
appData.txDataSize - number of bytes to be sent
appData.state - the next state to be in following the one its in 
uidcmdsent - checking if the first three bytes (0x20, 0x01, 0x00) have been sent.

imageindex - is the index of the beginning of the packet of image data that needs to be sent. 0 <= imagindex <= 48016
uidindex - this starts at imageindex and increments up to < PACKETSIZE (0 to 99)

IMAGEFILESIZE - total number of image file data bytes to be sent (48016)
PACKETSIZE - size of packet to send with UploadImageData (Usually 100)

The code function is as follows:
  1. Send 0x20, 0x01, 0x00
  2. Delay
  3. Send Lc 
  4. Delay
  5. Send byte of image data
  6. Repeat 3 and 4 until Lc data bytes have been sent
  7. Delay
  8. Repeat 1 through 6 until 48016 bytes have been sent
  9. Longer delay 
 
Code:
case SPI_SEND_IMAGE:
        {
            
            busy = PLIB_PORTS_PinGet(PORTS_ID_0, PORT_CHANNEL_D, PORTS_BIT_POS_10); //Check if the TCM is busy
          
            if(!busy){
                if(++appData.l_idle > 10 || uidcmdsent){ //either short delay has occurred or first 3 bytes of UploadImageData has been sent

                    PLIB_PORTS_PinWrite( PORTS_ID_0, PORT_CHANNEL_G, PORTS_BIT_POS_7,0); // /TC_CS goes low
                    
                    if(!uidcmdsent){ //If the first 3 bytes have not been sent
                        
                        if(IMAGEFILESIZE - imageindex >= PACKETSIZE){
                            memset(UploadImageData+3, PACKETSIZE, 1);  //Set how many bytes of image data will be sent
                        }
                        else if((IMAGEFILESIZE - imageindex) == 0) { //If all of the bytes have already been sent
                            uidindex = 0;
                            uidcmdsent = false;
                            appData.l_idle = 0;
                            appData.state = SPI_IDLE;
                            break;

                        }
                        else{
                            memset(UploadImageData+3, IMAGEFILESIZE-imageindex, 1);
                        }

                        appData.txData = UploadImageData;
                        appData.txDatasize = 3;
                        SPI_SendCommand();
                        appData.l_idle = 0;
                        uidcmdsent = true;

                        uidindex = 0;

                    }
                    else if( imageindex < IMAGEFILESIZE) {
                        
                        if(appData.l_idle > 5){
                            if(IMAGEFILESIZE - imageindex >= PACKETSIZE ){
                                
                                memcpy(UploadImageData+4, imageptr+imageindex, PACKETSIZE); //Copy 100 bytes to the UploadImageDataArray
                                if(uidindex <= PACKETSIZE){

                                    appData.txDatasize = 1;
                                    appData.txData = UploadImageData+3+uidindex;
                                    appData.l_idle = 0;
                                    SPI_SendCommand();
                                    i++;                            
                                    uidindex++;
                                  
                                }
                                else{
                                    
                                   imageindex+= PACKETSIZE;
                              
                                   uidindex = 0;
                                   appData.l_idle = 0;
                                   uidcmdsent = false;


                                   appData.state = SPI_BUSY_DELAY;
                                                              
                                }
                            }
                            else{
                                
                                memcpy(UploadImageData+4, imageptr+imageindex, IMAGEFILESIZE - imageindex ); //Copy the remaining bytes of the image file to send
                                if(uidindex <= IMAGEFILESIZE-imageindex){
  
                                    appData.txDatasize = 1;
                                    appData.txData = UploadImageData+3+uidindex;
                                    SPI_SendCommand();
                                    i++;                            
                                    uidindex++;
                                    
                                    appData.l_idle = 0;

                                }
                                else{

                              
                                    //UploadImageData packet has been sent
                                    
                                    imageindex = 0;
                                    

                                    uidindex = 0;
                                    uidcmdsent = false;
                                    
                                    appData.state = SPI_IDLE2;
                                    appData.l_idle = 0;
                                    
                                    
                                    break;
                                }
                            

                            }
                        }

                    }
                    else{
                        
                        //UploadImageData packet has been sent
                        imageindex = 0;
                        uidindex = 0;
                        uidcmdsent = false;
                        
                        appData.state = SPI_IDLE2;
                        appData.l_idle = 0;
                        
                        
                        break;
                        
                    }
                  
                }
            }



            

            break;
        }
Reply
#5
Dear Ben!

The image that you are sending with your code is missing the first 100 or so bytes (including header). If you remove the first 100 bytes of your original smiley image and send it via USB2TCM, you will get similar results as you get with your code. That is how it was achieved in the similarily looking picture below.
[Image: 1fcc6bc1ebf322e71d2a8b5e02947eec.jpeg]
Reply


Forum Jump: