stm32f429 SRAM + ext SRAM + TFT 16bit with DMA

diger67
Mon Jan 16, 2017 1:59 am
Good day. I try to implement the idea for the removal of information on the TFT screen is pre-recorded in the external memory, and then write it in the TFT using DMA. That’s what has happened to make.

https://youtu.be/2yn_j_dLoy4
https://youtu.be/wYmzSF-hkl0
https://youtu.be/OnpP7y9HBw4
https://youtu.be/nulBXs08cjs
https://youtu.be/G_QIx3eDdDc
https://youtu.be/oycXAoZCJm4


diger67
Thu Jan 19, 2017 8:37 am
This solution allows you to prepare a copy of the display area in the external memory and display screen one dump. It also allows you to realize the function of the virtual layers. With sufficient external memory can store several preformed screen screenshots and print them on demand.

stevestrong
Thu Jan 19, 2017 7:53 pm
Without browsing through the videos, could please describe what kind of TFT do you use? Spi or parallel?

diger67
Thu Jan 19, 2017 11:43 pm
Used TFT connected in parallel 16-bit bus. Probably it is possible to SPI and use. I did not think long about this question.

stevestrong
Fri Jan 20, 2017 9:19 am
So you actually use 16 bit bus for data and another 8 bit for control signals, right? I think you need two different DMAs for this.

How do you synchronize the two DMAs? Triggered by the same counter?


RogerClark
Fri Jan 20, 2017 9:57 am
stevestrong wrote:So you actually use 16 bit bus for data and another 8 bit for control signals, right? I think you need two different DMAs for this.

How do you synchronize the two DMAs? Triggered by the same counter?


Pito
Fri Jan 20, 2017 11:51 am
A tft display with 16bit data shall be connected via FSMC. FSMC is the interface for a 16bit tft..
And it will be memory mapped. Then you can use DMA.
There are examples somewhere, afaik.
Search “stm32 FSMC TFT display” on the web..

diger67
Fri Jan 20, 2017 7:05 pm
stevestrong wrote:So you actually use 16 bit bus for data and another 8 bit for control signals, right? I think you need two different DMAs for this.

How do you synchronize the two DMAs? Triggered by the same counter?


diger67
Tue Jan 24, 2017 2:17 pm
Replacing the external memory has given result. The image is output stably without distortion. Came stm32f446, will be connected by 25Qxxx on QSPI and transfer to all arrays of constants. The next step in the transient stm32f746.

stevestrong
Tue Jan 24, 2017 4:21 pm
I think this is the setup (taken from STM32 QVGA TFT-LCD drive implementation, AN3241, chapter 2):
QVGA TFT-LCD signal interfacing with STM32F10xx FSMC

The TFT-LCD synchronization signals VSYNC and HSYNC are managed through STM32 GPIOs.
The FSMC memory interface Write-enable signal is used in inverted configuration as a DCLK (pixel clock) for the TFT,
and the FSMC chip-select signal acts as a TFT-enable signal.
When data is transferred to the FSMC bus, the chip-select is first asserted low to enable the TFT-LCD.
Then the write-enable signal is asserted low to allow 16-bit data transfer to the TFT RGB line on its low level which results in a single pixel display:
■ TFT-Enable: FSMC chip select (pin PG12)
■ VSYNC: GPIO - pin PA8
■ HSYNC: GPIO - pin PC6
■ DCLK: FSMC WE in inverted mode - pin PD5
■ Data Bus: FSMC[D0:D15] ■ SPI1: used for LCD configuration


diger67
Tue Jan 24, 2017 9:51 pm
In this document you emulation describes an example LTDC. I solve the problem of using a TFT controller. Besides, all I do is true for the above example.

diger67
Mon Jan 30, 2017 2:44 pm
The project continues to develop on the basis of stm32f429. Writing a function to display the sprite on any background (virtual Layer). Now to deal with the QSPI and record it using information STLink. After that I will carry it on stm32f446. It will also write a function to work with the 29 series of NOR for storing sprites and character generator stm32f429.

https://youtu.be/8xuIp0JbNwQ


diger67
Sat Feb 04, 2017 3:24 am
Problem with failures when outputting the image removed. It was a bad connector contact RD signal. But this led to a positive result, the code has been optimized so that these failures have little effect on the program.

diger67
Mon Feb 13, 2017 8:46 pm
Disregard of TFT and consider working with xpt2046.

https://youtu.be/oAnAdO2NUCQ


diger67
Sun Feb 26, 2017 7:22 pm
Continuation of work, we connect all of the material into a single project. Start with a small, very simple, button.

https://vk.com/away.php?to=https%3A%2F% … 656325_526


rexnanet
Mon Feb 27, 2017 10:17 am
If you could talk in english on the videos that would be great :)
Russian is not my specialty ;)
But thanks for the sharing!

stevestrong
Mon Feb 27, 2017 10:32 am
rexnanet wrote:If you could talk in english on the videos that would be great :)
Russian is not my specialty ;)
But thanks for the sharing!

diger67
Tue Mar 07, 2017 6:28 pm
Create three new interactive elements. Textbox, checkbox, text. And their work with a touchscreen.
https://youtu.be/U4Ci-gbDWQM

stevestrong
Tue Mar 07, 2017 8:49 pm
Unfortunately, it is no value for non-russian speaking community…

diger67
Fri Mar 10, 2017 1:30 pm
stevestrong wrote:Unfortunately, it is no value for non-russian speaking community…

diger67
Sun Mar 12, 2017 10:25 am
The problem with the stabilization of the read readings when touching the touchscreen was decided. Below, you can see how this is done.
void Sort (uint16_t *mas)
{
uint8_t i,j;
uint16_t k;
for(i=1;i<10;i++)
for(j=0;j<9;j++)
if(mas[i]>mas[j])
{
k=mas[i];
mas[i]=mas[j];
mas[j]=k;
}
}

//-------------------------------------------------------------------------------
bool IsTouch(void)
{
if(HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_8) == RESET)
return true;
return false;
}

//-------------------------------------------------------------------------------
bool Get_Touch_xy(__IO uint16_t *x_kor, __IO uint16_t *y_kor)
{
__IO uint16_t touch_x = 0;
__IO uint16_t touch_y = 0;
uint16_t touch_X[10]={0}, touch_Y[10]={0}, touch_avg;
uint8_t i, flag;

flag = IsTouch();
//press = IsTouch_XY();
if(flag) //Есть касание //There is a touch
{
for(i=0;i<10;i++) //Считываем десять измерений x и y в точке касания //Read ten dimensions x and y at the point of tangency
{
touch_X[i] = Get_Touch(chx);
touch_Y[i] = Get_Touch(chy);
}

Sort(touch_X); //Сортируем измерения по нарастающей //We sort the measurements by increasing
Sort(touch_Y);

touch_avg=0; //Расчитываем среднее арифметическое измерений отбросив два наименьших и два наибольших
for(i=2;i<6;i++) //We calculate the average of the arithmetic measurements by discarding the two smallest and two largest
touch_avg+=touch_X[i];
touch_x=touch_avg/4;

touch_avg=0;
for(i=2;i<6;i++)
touch_avg+=touch_Y[i];
touch_y=touch_avg/4;

touch_x -= Xmin;
touch_x = 240 - touch_x/((Xmax-Xmin)/240);
touch_y -= Ymin;
touch_y = 320 - touch_y/((Ymax-Ymin)/320);

if(touch_x > 240)
touch_x = 240;
if(touch_y > 320)
touch_y = 320;

init_XPT2046();

// *x_kor = touch_x;
// *y_kor = touch_y;
*y_kor = touch_x;
*x_kor = touch_y;
}
return flag;
}


diger67
Tue Mar 14, 2017 2:40 pm
In this video, we’ll look at creating a slider element and its work in practice. Also consider the changes made to the function of reading the coordinates that increase the stability of the read value. Well and on a small bonus, we will consider functions for work with a hardware image shift using the capabilities of the ili9341 controller.

https://youtu.be/CGoGelFqEys


diger67
Sun Mar 19, 2017 6:45 am
Connected the energy independent memory 24c16, now you can save the calibration values and variables without fear of power failure. Well, here’s a simple calibration of the touchscreen. The accuracy is 2-4 pixels. I had enough.

void touchSetCoef(int16_t _ax, int16_t _bx, int16_t _ay, int16_t _by, bool colibrate)
{
I2CBuff[0] = _ax>>8; //hight byte
I2CBuff[1] = _ax; //low byte
I2CBuff[2] = _bx>>8;
I2CBuff[3] = _bx;
I2CBuff[4] = _ay>>8;
I2CBuff[5] = _ay;
I2CBuff[6] = _by>>8;
I2CBuff[7] = _by;
I2CBuff[8] = colibrate;
I2cWriteBuffer(hi2c1, EEPROM_HW_ADDRESS, 0, 8);
}

//------------------------------------------------------------------------------
void touchGetCoef(int16_t *_ax, int16_t *_bx, int16_t *_ay, int16_t *_by)
{
I2cReadBuffer(hi2c1, EEPROM_HW_ADDRESS, 0, 8);
*_ax = I2CBuff[0]<<8; //hight byte
*_ax |= I2CBuff[1]; //low byte
*_bx = I2CBuff[2]<<8;
*_bx |= I2CBuff[3];
*_ay = I2CBuff[4]<<8;
*_ay |= I2CBuff[5];
*_by = I2CBuff[6]<<8;
*_by |= I2CBuff[7];
}

//------------------------------------------------------------------------------
void TouchColibrate(void)
{
uint16_t x, y;

static Text_TypeDef text0;
static Text_TypeDef text1;

// if(!ReadStatusCalibrate())
// return;
init_text(&text0, 50, 100, BLACK, CYAN, 2, 2, MANUAL);
init_text(&text1, 50, 120, BLACK, CYAN, 2, 2, MANUAL);
sprintf(text0.text1, "%s", "Калибровка");

ram_bg_to_screen(SCREEN_BASE_ADDR_1);
tft_text(&text0, &text0.textvar);
drawLine (10, 10+25, 10+50, 10+25, BLACK);
drawLine (10+25, 10, 10+25, 10+50, BLACK);
DrawCircle(35, 35, 4, BLACK);
SetCursor(50, 120);
sprintf(text1.text1, "%s", "Нажимайте ");
tft_text(&text1, &text1.textvar);
tft();

while (1)
{
// ждать нажатия
while (!IsTouch());
Get_Touch_xy (&x, &y, false);
if (x < 4090 && y < 4090)
{
xPos[0] = x;
yPos[0] = y;
break;
} // if
} // while
sprintf(text1.text1, "%s", "Отпускайте");
tft_text(&text1, &text1.textvar);
tft();

while (IsTouch());
ram_bg_to_screen(SCREEN_BASE_ADDR_1);
tft_text(&text0, &text0.textvar);
drawLine (LCD_PIXEL_WIDTH-10-50, 10+25, LCD_PIXEL_WIDTH-10-50+50, 10+25, BLACK);
drawLine (LCD_PIXEL_WIDTH-10-25, 10, LCD_PIXEL_WIDTH-10-25, 10+50, BLACK);
DrawCircle(285, 35, 4, BLACK);
sprintf(text1.text1, "%s", "Нажимайте ");
tft_text(&text1, &text1.textvar);
tft();
while (1)
{
// ждать нажатия
while (!IsTouch());
Get_Touch_xy (&x, &y, false);
if (x < 4090 && y < 4090)
{
xPos[1] = x;
yPos[1] = y;
break;
} // if
} // while
sprintf(text1.text1, "%s", "Отпускайте");
tft_text(&text1, &text1.textvar);
tft();

while (IsTouch());
ram_bg_to_screen(SCREEN_BASE_ADDR_1);
tft_text(&text0, &text0.textvar);
drawLine (10, LCD_PIXEL_HEIGHT-10-25, 10+50, LCD_PIXEL_HEIGHT-10-25, BLACK); // hor
drawLine (10+25, LCD_PIXEL_HEIGHT-10-50, 10+25, LCD_PIXEL_HEIGHT-10-50+50, BLACK); // vert
DrawCircle(35, 205, 4, BLACK);
sprintf(text1.text1, "%s", "Нажимайте ");
tft_text(&text1, &text1.textvar);
tft();
while (1)
{
// ждать нажатия
while (!IsTouch());
Get_Touch_xy (&x, &y, false);
if (x < 4090 && y < 4090)
{
xPos[2] = x;
yPos[2] = y;
break;
} // if
} // while
sprintf(text1.text1, "%s", "Отпускайте");
tft_text(&text1, &text1.textvar);
tft();

while (IsTouch());
ram_bg_to_screen(SCREEN_BASE_ADDR_1);
tft_text(&text0, &text0.textvar);
drawLine (LCD_PIXEL_WIDTH-10-50, LCD_PIXEL_HEIGHT-10-25, LCD_PIXEL_WIDTH-10-50+50, LCD_PIXEL_HEIGHT-10-25, BLACK); // hor
drawLine (LCD_PIXEL_WIDTH-10-25, LCD_PIXEL_HEIGHT-10-50, LCD_PIXEL_WIDTH-10-25, LCD_PIXEL_HEIGHT-10-50+50, BLACK); // vert
DrawCircle(285, 205, 4, BLACK);
sprintf(text1.text1, "%s", "Нажимайте ");
tft_text(&text1, &text1.textvar);
tft();
while (1)
{
// ждать нажатия
while (!IsTouch());
Get_Touch_xy (&x, &y, false);
if (x < 4090 && y < 4090)
{
xPos[3] = x;
yPos[3] = y;
break;
} // if
} // while
sprintf(text1.text1, "%s", "Отпускайте");
tft_text(&text1, &text1.textvar);
tft();

while (IsTouch());
sprintf(text1.text1, "%s", " ");
tft_text(&text1, &text1.textvar);
tft();

// Расчёт коэффициентов
if(xPos[0]>xPos[3])
{
swap(xPos[0],xPos[3]);
}
axc[0] = (xPos[3] - xPos[0])/(xCenter[3] - xCenter[0]);
bxc[0] = xCenter[0] - xPos[0]/axc[0];
if(yPos[0]>yPos[3])
{
swap(yPos[0],yPos[3]);
}
ayc[0] = (yPos[3] - yPos[0])/(yCenter[3] - yCenter[0]);
byc[0] = yCenter[0] - yPos[0]/ayc[0];

touchSetCoef (axc[0], bxc[0], ayc[0], byc[0], true);

ram_bg_to_screen(SCREEN_BASE_ADDR_1);
text0.y0 = 110;
text0.text_poz = CENTER;
touchGetCoef(&ax, &bx, &ay, &by);
sprintf(text0.text1, "%s", "Калибровка завершена");
tft_text(&text0, &text0.textvar);
tft();
HAL_Delay(2000);
}


diger67
Sun Mar 19, 2017 5:05 pm
Work with the touchscreen can be considered complete, there may be an optimization. Now when you first turn on after downloading the firmware, the system immediately enters the calibration mode. Then records all the data and flag “calibration, is made in its eeprom. It remains to provide a forced transition to this mode in the settings options. And this variant of the section code work was did.

diger67
Sun Mar 26, 2017 4:18 pm
Calibrating the touchscreen and saving data in its eeprom 24L16

https://youtu.be/5Kthe-pgFUQ


Leave a Reply

Your email address will not be published. Required fields are marked *