Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

RA8875 Controller

Status
Not open for further replies.

AtomSoft

Well-Known Member
Hey everyone i have this nice LCD and its working fine so far using the RA8875 controller. But im getting lost when trying to read the LCD data back.. for instance... i want to read all the pixels from

0,0 to 0,256

Into a buffer on my MCU, if anyone has any experience with this and doesnt mind helping out that would be great. Thanks :)

Doesnt matter what MCU you use as long as its not in ASM :) i can understand anything from BASIC, C, C++, XC, JAVA, PASCAL lol just about anything but dont need another ASM headache :)
 
I think I've got the same type of LCD panel, 5" 800x480, touch panel, etc., but mine's got the older SSD1963.
Assuming you're trying to read back the panel memory (eg. pixel data)?
Couldn't tell you anything really...never tried to do a readback of the panel.
 
Yeah i have the 7" and opted for the RA8875 controller and Capacitive touch screen... Its really cool and yeah what im trying to do is read the screen data back. I know its possible but heh its a mess right now. Im actually creating my own library from scratch now... This will allow me to go through all registers and see how the other code i have does what it does and will hopefully allow me to learn more... When done ill post it all online of course.

Thanks for chiming in tho. :)
 
Ok I get something but no good so far... Im trying to save the image (screenshot) to a file on a SD card... here is what i have so far... it makes a new file if old exist so i dont overwrite older ones. Any thoughts... (im saving it RAW and will make a program in C# to open and convert them to JPG and stuff)

It writes the correct amount of data as well... just that the data doesnt seem correct.
Code:
void saveImage(void)
{
    uint x,y,w,h;
    uint count;
    FRESULT res;
    char filename[13];
    UINT br, bw;         /* File read/write count */
    FRESULT fr;          /* FatFs return code */
    uint len;
    uint last;
  
    do
    {
        sprintf(filename, "image%d.dat\0",imageCount++);
        fr = f_open(&fil, filename, FA_OPEN_EXISTING);
        f_close(&fil);
        if(fr == FR_NO_FILE) break;
    } while(1);

    fr = f_open(&fil, filename, FA_CREATE_ALWAYS | FA_WRITE);

    //void LCD_ReadBuff(char *buff, uint len)
    x = 0;
    y = 42;
    w = 800;
    h = 439;

    //Set Source X
    Write_Dir(0x54,x);
    Write_Dir(0x55,(x>>8));

    //Set Source Y
    Write_Dir(0x56,y);
    Write_Dir(0x57,(y>>8));

    //Set Source Width
    Write_Dir(0x5C,w);
    Write_Dir(0x5D,(w>>8));

    //Set Source Height
    Write_Dir(0x5E,h);
    Write_Dir(0x5F,(h>>8));

    //SET OPERATION
    Write_Dir(0x51, 0x01);

    //Enable BTE
    Write_Dir(0x50,0x80);

    len = ((w*h)*2)/IMAGEBUFF_LEN;
    last = (((w*h)*2)%IMAGEBUFF_LEN);
    if(last > 0) len++;

    CS_LOW(LCD);//SCS = 0;
    SPI_Write(0x40);

    while(len--)
    {
        //Chk_Busy();
        if(len==1)
        {
            for(count = 0; count < last;count++)
                FILE_IN_BUFF[count] = SPI_Read();

            fr = f_write(&fil, FILE_IN_BUFF, last, &bw);            /* Write it to the destination file */
        } else {

            for(count = 0; count < IMAGEBUFF_LEN;count++)
                FILE_IN_BUFF[count] = SPI_Read();

            fr = f_write(&fil, FILE_IN_BUFF, IMAGEBUFF_LEN, &bw);            /* Write it to the destination file */
        }
      
        if (fr || bw < br) break; /* error or disk full */
    }

    CS_HIGH();//SCS = 1;
    f_close(&fil);

}
 
Might I suggest the ol' "off by one" error?
I dunno, shooting blanks, thinking off the back of my head...but seems like that's where I've been bitten when working with those LCDs.
 
One issue is the SPI is used for both LCD and SD Card so cant use it like that... im not sure if i can resume a BTE from where left off... but if i can i tried this... but no luck..

File size is all wrong.
Code:
void saveImage(void)
{
    uint x,y,w,h;
    uint count,count2;
    FRESULT res;
    char filename[13];
    UINT br, bw;         /* File read/write count */
    FRESULT fr;          /* FatFs return code */
    uint len;
    uint last;
   
    do
    {
        sprintf(filename, "image%d.dat\0",imageCount++);
        fr = f_open(&fil, filename, FA_OPEN_EXISTING);
        f_close(&fil);
        if(fr == FR_NO_FILE) break;
    } while(1);

    fr = f_open(&fil, filename, FA_CREATE_ALWAYS | FA_WRITE);

    //void LCD_ReadBuff(char *buff, uint len)
    x = 0;
    y = 42;
    w = 800;
    h = 439;

    //Set Source X
    Write_Dir(0x54,x);
    Write_Dir(0x55,(x>>8));

    //Set Source Y
    Write_Dir(0x56,y);
    Write_Dir(0x57,(y>>8));

    //Set Source Width
    Write_Dir(0x5C,w);
    Write_Dir(0x5D,(w>>8));

    //Set Source Height
    Write_Dir(0x5E,h);
    Write_Dir(0x5F,(h>>8));

    //SET OPERATION
    Write_Dir(0x51, 0x01);

    //Enable BTE
    Write_Dir(0x50,0x80);

    len = ((w*h)*2)/IMAGEBUFF_LEN;
    last = (((w*h)*2)%IMAGEBUFF_LEN);
    if(last > 0) len++;

    while(len--)
    {
        Chk_Busy();
        CS_LOW(LCD);//SCS = 0;
        SPI_Write(0x40);
       
        if(len==1)
        {
            count2 = last;
        } else {
            count2 = IMAGEBUFF_LEN;
        }

        for(count = 0; count < count2;count++)
            FILE_IN_BUFF[count] = SPI_Read();


        CS_HIGH();//SCS = 1;
       
        fr = f_write(&fil, FILE_IN_BUFF, count2, &bw);            /* Write it to the destination file */
       
        if (fr || bw < br) break; /* error or disk full */
    }

    f_close(&fil);

}
 
I dont know what im doing. It doesnt say anything about dummy bytes at all. (from what ive read so far) im not even sure im reading data back correctly. Perhaps a little breather from this would help.
 
Then load up half the screen with a pattern, read it back, and copy it byte for byte to the other half. At least then you'll know if you're reading right or not.
 
Found Something while cruising the net:
Code:
RetCode_t RA8875::getPixelStream(color_t * p, uint32_t count, loc_t x, loc_t y)
{
    color_t pixel;
  
    PERFORMANCE_RESET;
    //WriteCommand(0x45,0x00);    // read left->right, top->bottom
    WriteCommand(0x40,0x00);    // Graphics write mode
    SetGraphicsCursorRead(x, y);
    WriteCommand(0x02);
    select(true);
    spiwrite(0x40);         // Cmd: read data
    spiwrite(0x00);         // dummy read
    while (count--) {
        pixel  = spiread();
        pixel |= (spiread() << 8);
        *p++ = pixel;
    }
    select(false);
    REGISTERPERFORMANCE(PRF_READPIXELSTREAM);
    return noerror;
}

RetCode_t RA8875::SetGraphicsCursorRead(loc_t x, loc_t y)
{
    //WriteCommand(0x40, 0);  // Graphics mode
    //WriteCommand(0x45, 0);  // left->right, top->bottom
    WriteCommandW(0x4A, x);
    WriteCommandW(0x4C, y);
    return noerror;
}

will try later or tomorrow :)
 
Here it is :)
Code:
void saveImage(void)
{
    uint x,y,w,h;
    uint count,count2;
    FRESULT res;
    UINT br, bw;         /* File read/write count */
    FRESULT fr;          /* FatFs return code */
    uint len;
    uint last;
   
    do
    {
        sprintf(LastFile, "image%d.dat\0",imageCount++);
        fr = f_open(&fil, LastFile, FA_OPEN_EXISTING);
        f_close(&fil);
        if(fr == FR_NO_FILE) break;
    } while(1);

    fr = f_open(&fil, LastFile, FA_CREATE_ALWAYS | FA_WRITE);

    //void LCD_ReadBuff(char *buff, uint len)
    x = 0;
    y = 480-myH;
    w = myW;
    h = myH;

    WriteCommand(0x40,0x00);    // Graphics mode
    WriteCommand(0x45,0x00);    // Graphics mode - READ LEFT TO RIGHT then TOP TO BOTTOM
    SetGraphicsCursorRead(x, y);
    LCD_CmdWrite(0x02);


    len = ((w*h)*2)/IMAGEBUFF_LEN;
    last = (((w*h)*2)%IMAGEBUFF_LEN);
    if(last > 0) len++;

    while(len--)
    {

        if(len==1)
            count2 = last;
        else
            count2 = IMAGEBUFF_LEN;

        CS_LOW(LCD);
        SPI_Write(0x40);         // Cmd: read data

        for(count = 0; count < count2;count++)
        {
            FILE_IN_BUFF[count++] = SPI_Read();
            FILE_IN_BUFF[count++] = SPI_Read();
            FILE_IN_BUFF[count++] = SPI_Read();
            FILE_IN_BUFF[count] = SPI_Read();
        }
        CS_HIGH();
       
        fr = f_write(&fil, FILE_IN_BUFF, count2, &bw);            /* Write it to the destination file */
        if (fr) break; /* error or disk full */
    }

    f_close(&fil);

}

void OpenImage(void)
{
    uint x,y,w,h;
    uint count,count2;
    FRESULT res;
    UINT br, bw;         /* File read/write count */
    FRESULT fr;          /* FatFs return code */
    uint len;
    uint last;

    fr = f_open(&fil, LastFile, FA_OPEN_EXISTING | FA_READ);

    x = 0;
    y = 480-myH;
    w = myW;
    h = myH;

    WriteCommand(0x40,0x00);    // Graphics write mode
    SetGraphicsCursorWrite(x, y);
    LCD_CmdWrite(0x02);


    len = ((w*h)*2)/IMAGEBUFF_LEN;
    last = (((w*h)*2)%IMAGEBUFF_LEN);
    if(last > 0) len++;

    while(len--)
    {
        if(len==1)
            count2 = last;
        else
            count2 = IMAGEBUFF_LEN;

        fr = f_read(&fil, FILE_IN_BUFF, count2, &br);  /* Read a chunk of source file */
        if (fr != FR_OK) break;

        Chk_Busy();
        CS_LOW(LCD);

        SPI_Write(0x00);         // Cmd: write data

        for(count = 0; count < count2;count++)
            SPI_Write(FILE_IN_BUFF[count]);

        CS_HIGH();

        //if (br != count2) break; /* error or eof */

    }

    f_close(&fil);

}
 
Proof
 

Attachments

  • DONE.jpg
    DONE.jpg
    2.9 MB · Views: 299
Are you going to post the full driver when you're done Jason.... I know it's been a chore but You may inspire others to follow... BTW is that a pic32 USB bit whacker board you are using??

Yes I will Ian. Ill post this full project.

Its a fubarino mini. Pic32... but I use xc32 not that mpide crap. I hate it. . But I love this small pcb. Check out my blog for more info also.

I have a nice pic 18f47j53 pcb like that as well but I designed it myself.

I wish people would share more, would be a ton more smart people online lol
 
Oh ya? Well I use PicBasicPro for most of my PIC work! :eek: with a generous helping of straight assembly when I need speed/size.
I'm going to look into the Fubarino though. I've been using UBW32 boards for 'light' PIC32 work in the past.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top