Mình mới mua cái boad STM32F103VET6 mình thử lập trình TFT mãi mà không được. Mong có cao thủ nào làm được giúp với.
PHP Code:
sfr unsigned int CUSTOM_TFT_DATAPORT;
sbit DATA0_TFT_DATAPORT at GPIOD_ODR.B14;
sbit DATA1_TFT_DATAPORT at GPIOD_ODR.B15;
sbit DATA2_TFT_DATAPORT at GPIOD_ODR.B0;
sbit DATA3_TFT_DATAPORT at GPIOD_ODR.B1;
sbit DATA4_TFT_DATAPORT at GPIOE_ODR.B7;
sbit DATA5_TFT_DATAPORT at GPIOE_ODR.B8;
sbit DATA6_TFT_DATAPORT at GPIOE_ODR.B9;
sbit DATA7_TFT_DATAPORT at GPIOE_ODR.B10;
sbit DATA8_TFT_DATAPORT at GPIOE_ODR.B11;
sbit DATA9_TFT_DATAPORT at GPIOE_ODR.B12;
sbit DATA10_TFT_DATAPORT at GPIOE_ODR.B13;
sbit DATA11_TFT_DATAPORT at GPIOE_ODR.B14;
sbit DATA12_TFT_DATAPORT at GPIOE_ODR.B15;
sbit DATA13_TFT_DATAPORT at GPIOD_ODR.B8;
sbit DATA14_TFT_DATAPORT at GPIOD_ODR.B9;
sbit DATA15_TFT_DATAPORT at GPIOD_ODR.B10;
sfr unsigned int TFT_DATAPORT at CUSTOM_TFT_DATAPORT;
//unsigned int TFT_DataPort= {GPIOD_ODR.B14,GPIOD_ODR.B15,GPIOD_ODR.B0,GPIOD_ODR.B1,GPIOE_ODR.B7,GPIOE_ODR.B8,GPIOE_ODR.B9,GPIOE_ODR.B10,GPIOE_ODR.B11,GPIOE_ODR.B12,GPIOE_ODR.B13,GPIOE_ODR.B14,GPIOE_ODR.B15,GPIOD_ODR.B8,GPIOD_ODR.B9,GPIOD_ODR.B10};
/////////////////
sbit TFT_RST at GPIOE_ODR.B1;
sbit TFT_RS at GPIOD_ODR.B11;
sbit TFT_CS at GPIOD_ODR.B7;
sbit TFT_RD at GPIOD_ODR.B4;
sbit TFT_WR at GPIOD_ODR.B5;
sbit TFT_BLED at GPIOD_ODR.B13;
/////End Config TFT
//sbit TFT_BLED at GPIOA_ODR.B9;
//
void TFT_Set_Index_Custom(unsigned short index) {
unsigned int temp;
TFT_RS = 0;
// Write to port
temp = TFT_DataPort;
temp &= 0xFF00;
TFT_DataPort = index | temp;
// Strobe
TFT_WR = 0;
asm nop;
TFT_WR = 1;
}
void TFT_Write_Command_Custom(unsigned short cmd) {
unsigned int temp;
TFT_RS = 1;
// Write to port
temp = TFT_DataPort;
temp &= 0xFF00;
TFT_DataPort = cmd | temp;
// Strobe
TFT_WR = 0;
asm nop;
TFT_WR = 1;
}
void TFT_Write_Data_16bit_Custom(unsigned int _data) {
TFT_RS = 1;
// Write to 16-bit port
TFT_DataPort = _data;
// Strobe
TFT_WR = 0;
asm nop;
TFT_WR = 1;
}
//////////////////
void main() {
TFT_BLED = 1;
TFT_Init_ILI9340(240, 320);
TFT_Set_Active(&TFT_Set_Index_Custom, &TFT_Write_Command_Custom, &TFT_Write_Data_16bit_Custom);
TFT_Fill_Screen(CL_RED);
TFT_Dot(50, 50, CL_BLACK);
TFT_Write_Text("MENU MACHINE SETUP", 110, 100);
delay_ms(1000) ;
while(1)
{
}
}
Comment