cancel
Showing results for 
Search instead for 
Did you mean: 

STM32f7G-DISCOVERY hardware failure during working on LCD

SeyyedMohammad
Senior III

I was working on some function to view ADC values on LCD, suddenly LCD gone wrong and noisy, I sensed board pwr pin_header is hot, also after reset the problem persisted, I've found the ULPI USB IC USB3320 became extremely hot after establishing 5v of board. Note that I was powering the board by usb cable through the USB port related to USB3320. I hope everything becomming ok by removing that bad IC, and I wonder why that happened?

UPdate after removing that the problem with LCD persist. Though I can debug the MCU and applications running but we have glitches on LCD, icluding flickering, pixelf freeze after being used and dead pixels.

6 REPLIES 6
KnarfB
Principal III

Think I have seen this too. You mean STM32F764G DISCO? The LCD looks speckled, if you check the frame buffer RAM or fill it with a solid pattern, you see bit errors. And, a chip gets hot (don't remember which one exactly).

Used HAL for code generation plus BSP_LCD for LCD. Have seen that the SRAM is initialized more that once with different settings.

Didn't find the root cause and was too lazy for fixing STM code.

What is your SW setup?

KnarfB

SeyyedMohammad
Senior III

Yes. I will add my code

Yes I will add my code, It has appended as answer, any answer will appreciated, thanks.

Note the starting adress of LTDC buffer is changing too fast.

SeyyedMohammad
Senior III

/* USER CODE BEGIN Header */

/**

 ******************************************************************************

 * @file      : main.c

 * @brief     : Main program body

 ******************************************************************************

 * @attention

 *

 * Copyright (c) 2022 STMicroelectronics.

 * All rights reserved.

 *

 * This software is licensed under terms that can be found in the LICENSE file

 * in the root directory of this software component.

 * If no LICENSE file comes with this software, it is provided AS-IS.

 *

 ******************************************************************************

 */

/* USER CODE END Header */

/* Includes ------------------------------------------------------------------*/

#include "main.h"

/* Private includes ----------------------------------------------------------*/

/* USER CODE BEGIN Includes */

/* USER CODE END Includes */

/* Private typedef -----------------------------------------------------------*/

/* USER CODE BEGIN PTD */

/* USER CODE END PTD */

/* Private define ------------------------------------------------------------*/

/* USER CODE BEGIN PD */

/* USER CODE END PD */

/* Private macro -------------------------------------------------------------*/

/* USER CODE BEGIN PM */

/* USER CODE END PM */

/* Private variables ---------------------------------------------------------*/

ADC_HandleTypeDef hadc3;

LTDC_HandleTypeDef hltdc;

SDRAM_HandleTypeDef hsdram1;

/* USER CODE BEGIN PV */

uint8_t downsamplecounter=0;

/* USER CODE END PV */

/* Private function prototypes -----------------------------------------------*/

void SystemClock_Config(void);

static void MX_GPIO_Init(void);

static void MX_ADC3_Init(void);

static void MX_FMC_Init(void);

static void MX_LTDC_Init(void);

/* USER CODE BEGIN PFP */

static void BSP_SDRAM_Initialization_Sequence(SDRAM_HandleTypeDef *hsdram, FMC_SDRAM_CommandTypeDef *Command);

static void PixelFill(uint32_t buf,uint16_t x,uint16_t y,uint8_t val);

static void dynGraph(uint16_t val, uint32_t b1sAddr,uint32_t b2sAddr,uint32_t max_val);

static void trggGraph(uint16_t val, uint32_t b1sAddr,uint32_t b2sAddr,uint32_t max_val);

static void Paint(uint8_t *buf);

static void Clear(uint32_t buf,uint8_t how);// how is multiple off lcd element size

/* USER CODE END PFP */

/* Private user code ---------------------------------------------------------*/

/* USER CODE BEGIN 0 */

/* USER CODE END 0 */

/**

 * @brief The application entry point.

 * @retval int

 */

int main(void)

{

 /* USER CODE BEGIN 1 */

 /* USER CODE END 1 */

 /* MCU Configuration--------------------------------------------------------*/

 /* Reset of all peripherals, Initializes the Flash interface and the Systick. */

 HAL_Init();

 /* USER CODE BEGIN Init */

 /* USER CODE END Init */

 /* Configure the system clock */

 SystemClock_Config();

 /* USER CODE BEGIN SysInit */

 /* USER CODE END SysInit */

 /* Initialize all configured peripherals */

 MX_GPIO_Init();

 MX_ADC3_Init();

 MX_FMC_Init();

 MX_LTDC_Init();

 /* USER CODE BEGIN 2 */

 Clear(window1,3);

//HAL_ADC_Start_IT(&hadc3);

 Paint(window1);

 /* USER CODE END 2 */

 /* Infinite loop */

 /* USER CODE BEGIN WHILE */

 while (1)

 {

  /* USER CODE END WHILE */

  /* USER CODE BEGIN 3 */

 }

 /* USER CODE END 3 */

}

/**

 * @brief System Clock Configuration

 * @retval None

 */

void SystemClock_Config(void)

{

 RCC_OscInitTypeDef RCC_OscInitStruct = {0};

 RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};

 /** Configure the main internal regulator output voltage

 */

 __HAL_RCC_PWR_CLK_ENABLE();

 __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE2);

 /** Initializes the RCC Oscillators according to the specified parameters

 * in the RCC_OscInitTypeDef structure.

 */

 RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;

 RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS;

 RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;

 RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;

 RCC_OscInitStruct.PLL.PLLM = 16;

 RCC_OscInitStruct.PLL.PLLN = 192;

 RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;

 RCC_OscInitStruct.PLL.PLLQ = 2;

 if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)

 {

  Error_Handler();

 }

 /** Initializes the CPU, AHB and APB buses clocks

 */

 RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK

               |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;

 RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;

 RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;

 RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;

 RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;

 if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4) != HAL_OK)

 {

  Error_Handler();

 }

}

/**

 * @brief ADC3 Initialization Function

 * @param None

 * @retval None

 */

static void MX_ADC3_Init(void)

{

 /* USER CODE BEGIN ADC3_Init 0 */

 /* USER CODE END ADC3_Init 0 */

 ADC_ChannelConfTypeDef sConfig = {0};

 /* USER CODE BEGIN ADC3_Init 1 */

 /* USER CODE END ADC3_Init 1 */

 /** Configure the global features of the ADC (Clock, Resolution, Data Alignment and number of conversion)

 */

 hadc3.Instance = ADC3;

 hadc3.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV8;

 hadc3.Init.Resolution = ADC_RESOLUTION_12B;

 hadc3.Init.ScanConvMode = ADC_SCAN_ENABLE;

 hadc3.Init.ContinuousConvMode = ENABLE;

 hadc3.Init.DiscontinuousConvMode = DISABLE;

 hadc3.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;

 hadc3.Init.ExternalTrigConv = ADC_SOFTWARE_START;

 hadc3.Init.DataAlign = ADC_DATAALIGN_RIGHT;

 hadc3.Init.NbrOfConversion = 2;

 hadc3.Init.DMAContinuousRequests = DISABLE;

 hadc3.Init.EOCSelection = ADC_EOC_SINGLE_CONV;

 if (HAL_ADC_Init(&hadc3) != HAL_OK)

 {

  Error_Handler();

 }

 /** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time.

 */

 sConfig.Channel = ADC_CHANNEL_0;

 sConfig.Rank = ADC_REGULAR_RANK_1;

 sConfig.SamplingTime = ADC_SAMPLETIME_480CYCLES;

 if (HAL_ADC_ConfigChannel(&hadc3, &sConfig) != HAL_OK)

 {

  Error_Handler();

 }

 /** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time.

 */

 sConfig.Channel = ADC_CHANNEL_8;

 sConfig.Rank = ADC_REGULAR_RANK_2;

 if (HAL_ADC_ConfigChannel(&hadc3, &sConfig) != HAL_OK)

 {

  Error_Handler();

 }

 /* USER CODE BEGIN ADC3_Init 2 */

 /* USER CODE END ADC3_Init 2 */

}

SeyyedMohammad
Senior III

static void trggGraph(uint16_t val, uint32_t b1sAddr,uint32_t b2sAddr,uint32_t max_val)

{

static uint8_t bufF=1;

static uint16_t newdatacolpos=1;

static uint16_t history[LCD_width]={0};

uint32_t bufstartaddress=0;

uint32_t othstartaddress=0;

if(bufF==1)

{

bufstartaddress=b1sAddr;

othstartaddress=b2sAddr;

}

else

{

bufstartaddress=b2sAddr;

othstartaddress=b1sAddr;

}

/*************Value normalization***********/

val=LCD_height*val/(max_val);

/*******************************************/

PixelFill(bufstartaddress,newdatacolpos,val,0xff);

PixelFill(othstartaddress,newdatacolpos,history[newdatacolpos-1],0x00);

history[newdatacolpos-1]=val;

newdatacolpos++;

if(newdatacolpos==481)//LCD_width+1

{

newdatacolpos=1;

if(bufF==1)

{

bufF=2;

}

else

{

bufF=1;

}

LTDC_Layer1->CFBAR=othstartaddress;//increment LCD buffer address

hltdc.Instance->SRCR = LTDC_SRCR_IMR;//Set the Immediate Reload type for LCD buffer

}

}

void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc)

{

if(downsamplecounter==2)

{

trggGraph(HAL_ADC_GetValue(hadc),window1,window2,4095);

downsamplecounter=0;

}

downsamplecounter++;

}

/* USER CODE END 4 */

/**

 * @brief This function is executed in case of error occurrence.

 * @retval None

 */

void Error_Handler(void)

{

 /* USER CODE BEGIN Error_Handler_Debug */

 /* User can add his own implementation to report the HAL error return state */

 __disable_irq();

 while (1)

 {

 }

 /* USER CODE END Error_Handler_Debug */

}

#ifdef USE_FULL_ASSERT

/**

 * @brief Reports the name of the source file and the source line number

 *     where the assert_param error has occurred.

 * @param file: pointer to the source file name

 * @param line: assert_param error line source number

 * @retval None

 */

void assert_failed(uint8_t *file, uint32_t line)

{

 /* USER CODE BEGIN 6 */

 /* User can add his own implementation to report the file name and line number,

   ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */

 /* USER CODE END 6 */

}

#endif /* USE_FULL_ASSERT */

though my codes going to run unstably but examples run perfectly on LCD, maybe my confuguration must be revisited since I've changed frequency from 216 to 150MHz.