Picproje Elektronik Sitesi

MİKRODENETLEYİCİLER => ARM => Konuyu başlatan: respected - 01 Şubat 2014, 15:53:51

Başlık: RA8875 TFT Ekran ( Kullanan var mı?)
Gönderen: respected - 01 Şubat 2014, 15:53:51
http://www.buydisplay.com/default/tft-5-inch-lcd-display-module-w-controller-board-serial-i2c-ra8875.html (http://www.buydisplay.com/default/tft-5-inch-lcd-display-module-w-controller-board-serial-i2c-ra8875.html)

Merhaba arkadaşlar bu linkteki LCD den kullanan varmı? Hem seri hemde paralel haberleştiği yazılmış. Kullanan var ise seri haberleşmede resim gösterilebiliyor mu? Teşekkürler
Başlık: Ynt: RA8875 TFT Ekran ( Kullanan var mı?)
Gönderen: leblebitozu - 01 Şubat 2014, 22:51:47
Chip'in içinde bir grafik kütüphanesi gömülü değil, ne gönderirsen onu basar. Seri ya da paralel farketmiyor.
Başlık: Ynt: RA8875 TFT Ekran ( Kullanan var mı?)
Gönderen: respected - 01 Şubat 2014, 22:55:47
Bir tane aldım. Bırakın bir şey göndermeyi backlight ı bile yakamadım. Donanımsal olarak kontrol ediliyor.

main.c
#include "stm32f4xx.h"
#include "RA8875.h"
#include "delay.h"
//#include "Picture.h"
//#include <stdlib.h>
//#include <math.h>


GPIO_InitTypeDef GPIO_InitStructure;

int main(void)
{

SysTick_Config(SystemCoreClock/1000);
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12|GPIO_Pin_13|GPIO_Pin_15;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ;
  GPIO_Init(GPIOD, &GPIO_InitStructure);



Lcd_Init();


delay_ms(200);

Text_Background_Color1(0x48DC);

while(1)
{
Text_Background_Color1(0xB8DC);

GPIO_SetBits(GPIOD,GPIO_Pin_12);
delay_ms(500);
GPIO_ResetBits(GPIOD,GPIO_Pin_12);
delay_ms(500);
}



}


//RA8875.c File

#include "stm32f4xx.h"
#include "RA8875.h"

void LCD_GPIO_Init(void)
{

GPIO_InitTypeDef  GPIO_InitStructure;
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE);

GPIO_InitStructure.GPIO_Pin = LCD_CS| LCD_SCL| LCD_SDI;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ;
  GPIO_Init(LCD_PORT, &GPIO_InitStructure);

GPIO_InitStructure.GPIO_Pin = LCD_SDO;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ;
  GPIO_Init(LCD_PORT, &GPIO_InitStructure);
     
}


void Delay1ms(uint8_t i)
{unsigned char j;
while(i--)
  for(j=0;j<125;j++);
}


void Delay10ms(uint8_t i)
{ while(i--)
Delay1ms(10);
}

void Delay100ms(uint8_t i)
{ while(i--)
Delay1ms(100);
}

void SPI_inst(void)
{
LCD_SDI_SET;
LCD_CS_SET;
LCD_SCL_SET;
// LCD_SDO_SET;

}



void Lcd_Write(u8 Index)
{
   u8 i=0;
   LCD_CS_CLR;
//   LCD_RS_CLR;
    for(i=8;i>0;i--)
   {
      if(Index&0x80)
LCD_SDI_SET
      else
LCD_SDI_CLR;
LCD_SCL_CLR;     
LCD_SCL_SET;
Index<<=1;
   }
   LCD_CS_SET;
}

void LCD_CmdWrite(u8 cmd)
{
LCD_SCL_SET;
LCD_SDI_SET;
LCD_CS_CLR;
Delay1ms(2);//SPI_Delay();
Lcd_Write(0x80);
Lcd_Write(cmd);
LCD_CS_SET;
Delay1ms(2);//SPI_Delay();
}

//////////////SPI Write data or  parameter
void LCD_DataWrite(u8 Data)
{
LCD_SCL_SET;
LCD_SDI_SET;
LCD_CS_CLR;
Lcd_Write(0x00);
Lcd_Write(Data);
Delay1ms(2);//SPI_Delay();
LCD_CS_SET;
}




void Write_Dir(u8 Index,u8 Data)
{
LCD_CmdWrite(Index);
    LCD_DataWrite(Data);
}

//*********4W_SPI_Read()
u8 SPI4_Read(void)
{
   u8 dat;
   u8 t = 8;
LCD_SDO_SET;//SDO = 1;
do
{
LCD_SCL_CLR;  //SCLK = 0;
        //SPI_Delay();
dat <<= 1;
if ( LCD_SDO ) dat++;
LCD_SCL_SET;//SCLK = 1;
        //SPI_Delay();
} while ( --t != 0 );
return dat;
}

///////////////Read data or  parameter
u8 LCD_DataRead(void)
{
u8 Data;
LCD_SCL_SET;
LCD_SDO_SET;
LCD_CS_CLR;
Lcd_Write(0x40); 
Data = SPI4_Read();
//SPI_Delay();
LCD_CS_SET;
return Data;
}

///////////SPI Read  status
u8 LCD_StatusRead(void)
{
u8 Data;
LCD_SCL_SET;
LCD_SDO_SET;
LCD_CS_CLR;
//SPI_Delay();
Lcd_Write(0xc0);
Data = SPI4_Read();
//SPI_Delay();
LCD_CS_SET;
return Data;
}

void Chk_Busy(void)
{
u8 temp;
do
{
temp=LCD_StatusRead();
}while((temp&0x80)==0x80);    
}

void PLL_ini(void)
{
    LCD_CmdWrite(0x88);     
    LCD_DataWrite(0x0C);
    Delay1ms(1);     
    LCD_CmdWrite(0x89);       
    LCD_DataWrite(0x02); 
    Delay1ms(1);
}

void Active_Window(uint16_t XL,uint16_t XR ,uint16_t YT ,uint16_t YB)
{
unsigned char temp;
    //setting active window X
temp=XL;   
    LCD_CmdWrite(0x30);//HSAW0
LCD_DataWrite(temp);
temp=XL>>8;   
    LCD_CmdWrite(0x31);//HSAW1    
LCD_DataWrite(temp);

temp=XR;   
    LCD_CmdWrite(0x34);//HEAW0
LCD_DataWrite(temp);
temp=XR>>8;   
    LCD_CmdWrite(0x35);//HEAW1    
LCD_DataWrite(temp);

    //setting active window Y
temp=YT;   
    LCD_CmdWrite(0x32);//VSAW0
LCD_DataWrite(temp);
temp=YT>>8;   
    LCD_CmdWrite(0x33);//VSAW1    
LCD_DataWrite(temp);

temp=YB;   
    LCD_CmdWrite(0x36);//VEAW0
LCD_DataWrite(temp);
temp=YB>>8;   
    LCD_CmdWrite(0x37);//VEAW1    
LCD_DataWrite(temp);
}


void Lcd_Init(void)
{
  LCD_GPIO_Init();
SPI_inst();
PLL_ini();
LCD_CmdWrite(0x10); //SYSR   bit[4:3] color  bit[2:1]=  MPU interface
LCD_DataWrite(0x0C);   //            65K

LCD_CmdWrite(0x04);    //PCLK
LCD_DataWrite(0x82);   //
Delay1ms(1);

//Horizontal set
LCD_CmdWrite(0x14); //HDWR//Horizontal Display Width Setting Bit[6:0]                     
LCD_DataWrite(0x63);//Horizontal display width(pixels) = (HDWR + 1)*8                     
LCD_CmdWrite(0x15);//Horizontal Non-Display Period Fine Tuning Option Register (HNDFTR)   
LCD_DataWrite(0x00);//Horizontal Non-Display Period Fine Tuning(HNDFT) [3:0]               
LCD_CmdWrite(0x16); //HNDR//Horizontal Non-Display Period Bit[4:0]                         
LCD_DataWrite(0x03);//Horizontal Non-Display Period (pixels) = (HNDR + 1)*8               
LCD_CmdWrite(0x17); //HSTR//HSYNC Start Position[4:0]                                     
LCD_DataWrite(0x03);//HSYNC Start Position(PCLK) = (HSTR + 1)*8                           
LCD_CmdWrite(0x18); //HPWR//HSYNC Polarity ,The period width of HSYNC.                     
LCD_DataWrite(0x0B);//HSYNC Width [4:0]   HSYNC Pulse width(PCLK) = (HPWR + 1)*8   
//Vertical set                             
LCD_CmdWrite(0x19); //VDHR0 //Vertical Display Height Bit [7:0]                           
LCD_DataWrite(0xdf);//Vertical pixels = VDHR + 1                                           
LCD_CmdWrite(0x1a); //VDHR1 //Vertical Display Height Bit [8]                             
LCD_DataWrite(0x01);//Vertical pixels = VDHR + 1                                           
LCD_CmdWrite(0x1b); //VNDR0 //Vertical Non-Display Period Bit [7:0]                       
LCD_DataWrite(0x20);//Vertical Non-Display area = (VNDR + 1)                               
LCD_CmdWrite(0x1c); //VNDR1 //Vertical Non-Display Period Bit [8]                         
LCD_DataWrite(0x00);//Vertical Non-Display area = (VNDR + 1)                               
LCD_CmdWrite(0x1d); //VSTR0 //VSYNC Start Position[7:0]                                   
LCD_DataWrite(0x16);//VSYNC Start Position(PCLK) = (VSTR + 1)                             
LCD_CmdWrite(0x1e); //VSTR1 //VSYNC Start Position[8]                                     
LCD_DataWrite(0x00);//VSYNC Start Position(PCLK) = (VSTR + 1)                             
LCD_CmdWrite(0x1f); //VPWR //VSYNC Polarity ,VSYNC Pulse Width[6:0]                       
LCD_DataWrite(0x01);//VSYNC Pulse Width(PCLK) = (VPWR + 1)   
   

Active_Window(0,799,0,479);

LCD_CmdWrite(0x8a);//PWM setting
LCD_DataWrite(0x80);
LCD_CmdWrite(0x8a);//PWM setting
LCD_DataWrite(0x81);//open PWM
LCD_CmdWrite(0x8b);//Backlight brightness setting
LCD_DataWrite(0xf0);//Brightness parameter 0xff-0x00
Write_Dir(0X01,0X80);//display on
}


///////////////Background color settings
void Text_Background_Color1(uint16_t b_color)
{

LCD_CmdWrite(0x60);//BGCR0
LCD_DataWrite((unsigned char)(b_color>>11));

LCD_CmdWrite(0x61);//BGCR0
LCD_DataWrite((unsigned char)(b_color>>5));

LCD_CmdWrite(0x62);//BGCR0
LCD_DataWrite((unsigned char)(b_color));
}



// RA8875.h File
#include "stm32f4xx.h"

#define color_brown   0x40c0
#define color_black   0x0000
#define color_white   0xffff
#define color_red     0xf800
#define color_green   0x07e0
#define color_blue    0x001f
#define color_yellow  color_red|color_green
#define color_cyan    color_green|color_blue
#define color_purple  color_red|color_blue
// Pin Configuration

#define LCD_PORT      GPIOB
#define LCD_SDO        GPIO_Pin_12
#define LCD_CS        GPIO_Pin_10
#define LCD_SCL        GPIO_Pin_13
#define LCD_SDI        GPIO_Pin_15


//Pinlerin SET olarak ayarlanmas1 icindir.
#define LCD_SDI_SET  GPIO_SetBits(LCD_PORT, LCD_SDI);
#define LCD_CS_SET  GPIO_SetBits(LCD_PORT, LCD_CS);
#define LCD_SCL_SET  GPIO_SetBits(LCD_PORT, LCD_SCL); 
//#define LCD_SDO_SET  GPIO_SetBits(LCD_PORT, LCD_SDO);   


#define LCD_SDI_CLR  GPIO_ResetBits(LCD_PORT, LCD_SDI);
#define LCD_CS_CLR  GPIO_ResetBits(LCD_PORT, LCD_CS);
#define LCD_SCL_CLR  GPIO_ResetBits(LCD_PORT, LCD_SCL); 
//#define LCD_SDO_CLR  GPIO_ResetBits(LCD_PORT, LCD_SDO); 



void Active_Window(uint16_t XL,uint16_t XR ,uint16_t YT ,uint16_t YB);
void Text_Background_Color1(uint16_t b_color);
void Delay1ms(uint8_t i);
void Delay10ms(uint8_t i);
void Delay100ms(uint8_t i);
void LCD_GPIO_Init(void);
void Lcd_Init(void);
void SPI_inst(void);
void PLL_ini(void);
void Lcd_Write(u8 Index);
void LCD_CmdWrite(u8 cmd);
void LCD_DataWrite(u8 Data);
void Write_Dir(u8 Index,u8 Data);
u8 LCD_DataRead(void);
u8 SPI4_Read(void);
u8 LCD_StatusRead(void);
void Chk_Busy(void);



Başlık: Ynt: RA8875 TFT Ekran ( Kullanan var mı?)
Gönderen: respected - 02 Şubat 2014, 23:19:37
void Lcd_Write(u8 Index)
{
   u8 i=0;

    for(i=8;i>0;i--)
   {
      if(Index&0x80)
                LCD_SDI_SET
      else
                LCD_SDI_CLR;
                LCD_SCL_CLR;     
                LCD_SCL_SET;
                Index<<=1;
   }

}


Bu şekilde düzenleyince haberleşebildim.