2020-11-12 10:36 AM
I want to display something on the LCD, it doesn't work. I don't know what the problem is?
I created a project here in the IDE-Cube directly for this kit = set by default.
For example, I want to display BAR0.
According to LCD_Connection it is: LCDSEG11 to COM3
I think with this command I will change LCD_RAM_COM3 bit 11 to tru
HAL_LCD_Write(&hlcd, LCD_RAM_REGISTER3 , 0xFFFFFFFF, 0x400);
But after uploading, I look at the LCD register ... RAM_COM3 ... bit11 - but nothing is set
I don't know why it doesn't work? Thank you all :smiling_face_with_smiling_eyes:
2020-11-12 04:06 PM
Which clock do you have selected for LCD, in RCC_CSR.RTCSEL? Is that clock enabled and running?
JW
2020-11-12 09:28 PM
Unfortunately, I don't know exactly where the LCD clock is set. RAM_COM should be set anyway, but it won't set me.
Here is the RCC and LCD ini code:
void SystemClock_Config(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
/** Configure the main internal regulator output voltage
*/
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
/** Initializes the RCC Oscillators according to the specified parameters
* in the RCC_OscInitTypeDef structure.
*/
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI|RCC_OSCILLATORTYPE_LSE;
RCC_OscInitStruct.LSEState = RCC_LSE_ON;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL6;
RCC_OscInitStruct.PLL.PLLDIV = RCC_PLL_DIV3;
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_DIV1;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK)
{
Error_Handler();
}
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_LCD;
PeriphClkInit.LCDClockSelection = RCC_RTCCLKSOURCE_LSE;
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
{
Error_Handler();
}
}
static void MX_LCD_Init(void)
{
hlcd.Instance = LCD;
hlcd.Init.Prescaler = LCD_PRESCALER_1;
hlcd.Init.Divider = LCD_DIVIDER_16;
hlcd.Init.Duty = LCD_DUTY_1_4;
hlcd.Init.Bias = LCD_BIAS_1_4;
hlcd.Init.VoltageSource = LCD_VOLTAGESOURCE_INTERNAL;
hlcd.Init.Contrast = LCD_CONTRASTLEVEL_0;
hlcd.Init.DeadTime = LCD_DEADTIME_0;
hlcd.Init.PulseOnDuration = LCD_PULSEONDURATION_0;
hlcd.Init.MuxSegment = LCD_MUXSEGMENT_DISABLE;
hlcd.Init.BlinkMode = LCD_BLINKMODE_OFF;
hlcd.Init.BlinkFrequency = LCD_BLINKFREQUENCY_DIV8;
if (HAL_LCD_Init(&hlcd) != HAL_OK)
{
Error_Handler();
}
}
2020-11-12 11:29 PM
I don't use Cube/HAL.
It appears that you are trying to run LSE and use that as LCD clock.
Do you have an LSE crystal installed? Can you verify it is running, e.g. by enabling RTC and observing is it's running?
JW