Author Topic: NHD-4.3-480800EF-CTXP#-T only shows two lines  (Read 773 times)

pcproa

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
    • View Profile
NHD-4.3-480800EF-CTXP#-T only shows two lines
« on: November 30, 2016, 09:37:38 AM »
Iím having a problem with my NHD-4.3-480800EF-CTXP#-T. To begin with, I should note that I have never used this screen. I bought it 2 years ago and didnít get a chance to develop with it until last week before the weekend.
For some reason I can only get two horizontal lines at the top of the screen in portrait mode. Iím using an STM32F103VE with FSMC to control it.

At first I used NHD code shown here

http://www.newhavendisplay.com/NHD_forum/index.php/topic,119.0.html

but I modified it to just use the command sequence provided by NHD. I worked on it for days, configuring FSMC timing with no luck.
I then thought I would do away with the FSMC and toggle the pins exactly like the NHD example. In fact, my code is now nearly identical to the NHD example and it does the exact same thing, just being controlled by an ST MCU.

Also, sometimes on cold startup I will get weird patterns on the screen until the lines are drawn at the top of the screen. Then the patterns usually slowly fade away to black.

Iíve used a few LCD Controllers (6800/8080 products) in the past and havenít had nearly as much difficulty getting them going. Iím starting to think this screen might be faulty. Iíve gone over my wiring at least 5 times to verify it is all correct. There isnít much available information on this controller out there, the HX8369. The datasheet seems to reference a different resolution than whatís used in this screen. And the code example provided isnít entirely complete so Iím not sure if itís also missing important commands.

I can call different commands and get responses as suggested in the Datasheet such as 0xDB responding with 0x80. Or 0xF4 responding with 0x69. It also works with specific commands. I can toggle the power and sleep modes. It works as expected. I just can't get it to display anything worthwhile.

I am attaching pictures of both the lines as well as the random pattern, and I'm posting some of my code in case anyone would like to browse through it and see if they can spot any problems. Or if anyone has any suggestions on what I can try next to get this sorted out. Maybe how I can minimize the command set to only crucial basic commands to see how it responds?

Thank you in advance.

Code: [Select]
#include "main.h"
#include "stm32f1xx_hal.h"
#include "usb_device.h"

/* USER CODE BEGIN Includes */

/* USER CODE END Includes */

/* Private variables ---------------------------------------------------------*/
SPI_HandleTypeDef hspi1;
SPI_HandleTypeDef hspi2;
DMA_HandleTypeDef hdma_spi1_rx;

TIM_HandleTypeDef htim3;

SRAM_HandleTypeDef hsram1;

/* USER CODE BEGIN PV */
/* Private variables ---------------------------------------------------------*/

/* USER CODE END PV */

/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
void Error_Handler(void);
static void MX_GPIO_Init(void);
static void MX_DMA_Init(void);
static void MX_FSMC_Init(void);
static void MX_TIM3_Init(void);

void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim);
                               

/* USER CODE BEGIN PFP */
/* Private function prototypes -----------------------------------------------*/
#define LCD_REG      (*((volatile unsigned short *) 0x60000000))
#define LCD_RAM      (*((volatile unsigned short *) 0x60020000))
/* USER CODE END PFP */

/* USER CODE BEGIN 0 */
/* USER CODE END 0 */

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();

  /* Configure the system clock */
  SystemClock_Config();

  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_DMA_Init();
  MX_FSMC_Init();
  MX_USB_DEVICE_Init();
  MX_TIM3_Init();

  /* USER CODE BEGIN 2 */
GPIOE->ODR &= ~(1 << 1); // Bring LCD Reset Low
//GPIOB->ODR |= (1 << 0); // Turn on LCD Backlights
GPIOB->ODR |= (1 << 1); // Turn on USB


HAL_Delay(100);
GPIOE->ODR |= (1 << 1); // Bring LCD Reset High

HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_3);
TIM3->CCR3 = 95*65535/100; // 95% Duty Cycle - Default Duty Cycle

LCD_REG = 0xB9;     //Enter Extension Command
LCD_RAM = 0xFF;     //Followed by 3 extension parameters
LCD_RAM = 0x83;
LCD_RAM = 0x69;

LCD_REG = 0xB1;     //Set Power
LCD_RAM = 0x01;   
LCD_RAM = 0x00;   
LCD_RAM = 0x34;     
LCD_RAM = 0x06;   
LCD_RAM = 0x00;   
LCD_RAM = 0x0F;   
LCD_RAM = 0x0F;   
LCD_RAM = 0x2A;   
LCD_RAM = 0x32;   
LCD_RAM = 0x3F;   
LCD_RAM = 0x3F;   
LCD_RAM = 0x07;   
LCD_RAM = 0x23;   
LCD_RAM = 0x01;   
LCD_RAM = 0xE6;   
LCD_RAM = 0xE6;   
LCD_RAM = 0xE6;   
LCD_RAM = 0xE6;   
LCD_RAM = 0xE6;

LCD_REG = 0xB2;     //Set Display
LCD_RAM = 0x00;   
LCD_RAM = 0x20;   
LCD_RAM = 0x0A;   
LCD_RAM = 0x0A;   
LCD_RAM = 0x70;   
LCD_RAM = 0x00; 
LCD_RAM = 0xFF; 
LCD_RAM = 0x00;   
LCD_RAM = 0x00;   
LCD_RAM = 0x00; 
LCD_RAM = 0x00;   
LCD_RAM = 0x03;   
LCD_RAM = 0x03; 
LCD_RAM = 0x00; 
LCD_RAM = 0x01;

LCD_REG = 0xB4;             //Set display column inversion
LCD_RAM = 0x00;   
LCD_RAM = 0x18;   
LCD_RAM = 0x80;   
LCD_RAM = 0x10;   
LCD_RAM = 0x01;   

LCD_REG = 0xB6;     //Set VCOM
LCD_RAM = 0x2C;   
LCD_RAM = 0x2C;   

LCD_REG = 0xD5;             //set GIP
LCD_RAM = 0x00;   
LCD_RAM = 0x05;   
LCD_RAM = 0x03;   
LCD_RAM = 0x00;   
LCD_RAM = 0x01;   
LCD_RAM = 0x09;   
LCD_RAM = 0x10;   
LCD_RAM = 0x80;   
LCD_RAM = 0x37;   
LCD_RAM = 0x37;   
LCD_RAM = 0x20;   
LCD_RAM = 0x31;   
LCD_RAM = 0x46; 
LCD_RAM = 0x8A;   
LCD_RAM = 0x57;   
LCD_RAM = 0x9B;   
LCD_RAM = 0x20;   
LCD_RAM = 0x31;   
LCD_RAM = 0x46;   
LCD_RAM = 0x8A;   
LCD_RAM = 0x57;   
LCD_RAM = 0x9B;   
LCD_RAM = 0x07;   
LCD_RAM = 0x0F;   
LCD_RAM = 0x02;   
LCD_RAM = 0x00;

LCD_REG = 0xE0;   //Gamma
LCD_RAM = 0x00;       
LCD_RAM = 0x08;       
LCD_RAM = 0x0D;       
LCD_RAM = 0x2D;       
LCD_RAM = 0x34;   
LCD_RAM = 0x3F;       
LCD_RAM = 0x19;       
LCD_RAM = 0x38;       
LCD_RAM = 0x09;       
LCD_RAM = 0x0E;
LCD_RAM = 0x0E;       
LCD_RAM = 0x12;       
LCD_RAM = 0x14;       
LCD_RAM = 0x12;       
LCD_RAM = 0x14;
LCD_RAM = 0x13;
LCD_RAM = 0x19;       
LCD_RAM = 0x00;       
LCD_RAM = 0x08;       
LCD_RAM = 0x0D;       
LCD_RAM = 0x2D;
LCD_RAM = 0x34;       
LCD_RAM = 0x3F;       
LCD_RAM = 0x19;       
LCD_RAM = 0x38;       
LCD_RAM = 0x09;
LCD_RAM = 0x0E;
LCD_RAM = 0x0E;       
LCD_RAM = 0x12;       
LCD_RAM = 0x14;       
LCD_RAM = 0x12;       
LCD_RAM = 0x14;
LCD_RAM = 0x13;       
LCD_RAM = 0x19;   

LCD_REG = 0x3A;    //Interface pixel format
LCD_RAM = 0x77;    //3bytes per pixel

LCD_REG = 0x36;            //MADCTL
LCD_RAM = 0x80;

LCD_REG = 0x11;            //exit sleep mode
HAL_Delay(120);

LCD_REG = 0x29;    //Display ON
HAL_Delay(10);     

LCD_REG = 0x2A;
LCD_RAM = 0;
LCD_RAM = 0;
LCD_RAM = 0x01;
LCD_RAM = 0xDF;

LCD_REG = 0x2B;
LCD_RAM = 0;
LCD_RAM = 0;
LCD_RAM = 0x03;
LCD_RAM = 0x1F;

LCD_REG = 0x2C;
for(int j=0;j<800;j++)                     //fill display with red pixels
{
for(int k=0;k<240;k++)
{
LCD_RAM = 0xFF00;
LCD_RAM = 0x00FF;
LCD_RAM = 0x0000;
}
}

  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
  /* USER CODE END WHILE */

  /* USER CODE BEGIN 3 */

  }
  /* USER CODE END 3 */

}

/** System Clock Configuration
*/
void SystemClock_Config(void)
{

  RCC_OscInitTypeDef RCC_OscInitStruct;
  RCC_ClkInitTypeDef RCC_ClkInitStruct;
  RCC_PeriphCLKInitTypeDef PeriphClkInit;

    /**Initializes the CPU, AHB and APB busses clocks
    */
  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
  RCC_OscInitStruct.HSEState = RCC_HSE_ON;
  RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1;
  RCC_OscInitStruct.HSIState = RCC_HSI_ON;
  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
  RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
  RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9;
  if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
  {
    Error_Handler();
  }

    /**Initializes the CPU, AHB and APB busses 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_DIV2;
  RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;

  if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
  {
    Error_Handler();
  }

  PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB;
  PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_PLL_DIV1_5;
  if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
  {
    Error_Handler();
  }

    /**Configure the Systick interrupt time
    */
  HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);

    /**Configure the Systick
    */
  HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);

  /* SysTick_IRQn interrupt configuration */
  HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);
}

/* TIM3 init function */
static void MX_TIM3_Init(void)
{

  TIM_MasterConfigTypeDef sMasterConfig;
  TIM_OC_InitTypeDef sConfigOC;

  htim3.Instance = TIM3;
  htim3.Init.Prescaler = 0;
  htim3.Init.CounterMode = TIM_COUNTERMODE_UP;
  htim3.Init.Period = 65535;
  htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
  if (HAL_TIM_PWM_Init(&htim3) != HAL_OK)
  {
    Error_Handler();
  }

  sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
  sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
  if (HAL_TIMEx_MasterConfigSynchronization(&htim3, &sMasterConfig) != HAL_OK)
  {
    Error_Handler();
  }

  sConfigOC.OCMode = TIM_OCMODE_PWM1;
  sConfigOC.Pulse = 0;
  sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
  sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
  if (HAL_TIM_PWM_ConfigChannel(&htim3, &sConfigOC, TIM_CHANNEL_3) != HAL_OK)
  {
    Error_Handler();
  }

  HAL_TIM_MspPostInit(&htim3);

}

/**
  * Enable DMA controller clock
  */
static void MX_DMA_Init(void)
{
  /* DMA controller clock enable */
  __HAL_RCC_DMA1_CLK_ENABLE();

  /* DMA interrupt init */
  /* DMA1_Channel2_IRQn interrupt configuration */
  HAL_NVIC_SetPriority(DMA1_Channel2_IRQn, 0, 0);
  HAL_NVIC_EnableIRQ(DMA1_Channel2_IRQn);

}

/** Configure pins as
        * Analog
        * Input
        * Output
        * EVENT_OUT
        * EXTI
*/
static void MX_GPIO_Init(void)
{

  GPIO_InitTypeDef GPIO_InitStruct;

  /* GPIO Ports Clock Enable */
  __HAL_RCC_GPIOA_CLK_ENABLE();
  __HAL_RCC_GPIOB_CLK_ENABLE();
  __HAL_RCC_GPIOE_CLK_ENABLE();
  __HAL_RCC_GPIOD_CLK_ENABLE();
  __HAL_RCC_GPIOC_CLK_ENABLE();

  /*Configure GPIO pin Output Level */
  HAL_GPIO_WritePin(GPIOB, GPIO_PIN_1, GPIO_PIN_SET);

  /*Configure GPIO pin Output Level */
  HAL_GPIO_WritePin(GPIOB, GPIO_PIN_2|GPIO_PIN_12, GPIO_PIN_RESET);

  /*Configure GPIO pin Output Level */
  HAL_GPIO_WritePin(GPIOC, GPIO_PIN_8, GPIO_PIN_RESET);

  /*Configure GPIO pin Output Level */
  HAL_GPIO_WritePin(GPIOE, GPIO_PIN_1, GPIO_PIN_RESET);

  /*Configure GPIO pins : PB1 PB2 PB12 */
  GPIO_InitStruct.Pin = GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_12;
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

  /*Configure GPIO pin : PC8 */
  GPIO_InitStruct.Pin = GPIO_PIN_8;
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);

  /*Configure GPIO pin : PE1 */
  GPIO_InitStruct.Pin = GPIO_PIN_1;
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);

}

/* FSMC initialization function */
static void MX_FSMC_Init(void)
{
  FSMC_NORSRAM_TimingTypeDef Timing;

  /** Perform the SRAM1 memory initialization sequence
  */
  hsram1.Instance = FSMC_NORSRAM_DEVICE;
  hsram1.Extended = FSMC_NORSRAM_EXTENDED_DEVICE;
  /* hsram1.Init */
  hsram1.Init.NSBank = FSMC_NORSRAM_BANK1;
  hsram1.Init.DataAddressMux = FSMC_DATA_ADDRESS_MUX_DISABLE;
  hsram1.Init.MemoryType = FSMC_MEMORY_TYPE_SRAM;
  hsram1.Init.MemoryDataWidth = FSMC_NORSRAM_MEM_BUS_WIDTH_16;
  hsram1.Init.BurstAccessMode = FSMC_BURST_ACCESS_MODE_DISABLE;
  hsram1.Init.WaitSignalPolarity = FSMC_WAIT_SIGNAL_POLARITY_LOW;
  hsram1.Init.WrapMode = FSMC_WRAP_MODE_DISABLE;
  hsram1.Init.WaitSignalActive = FSMC_WAIT_TIMING_BEFORE_WS;
  hsram1.Init.WriteOperation = FSMC_WRITE_OPERATION_ENABLE;
  hsram1.Init.WaitSignal = FSMC_WAIT_SIGNAL_DISABLE;
  hsram1.Init.ExtendedMode = FSMC_EXTENDED_MODE_DISABLE;
  hsram1.Init.AsynchronousWait = FSMC_ASYNCHRONOUS_WAIT_DISABLE;
  hsram1.Init.WriteBurst = FSMC_WRITE_BURST_DISABLE;
  /* Timing */
  Timing.AddressSetupTime = 5;
  Timing.AddressHoldTime = 15;
  Timing.DataSetupTime = 20;
  Timing.BusTurnAroundDuration = 5;
  Timing.CLKDivision = 16;
  Timing.DataLatency = 17;
  Timing.AccessMode = FSMC_ACCESS_MODE_A;
  /* ExtTiming */

  if (HAL_SRAM_Init(&hsram1, &Timing, NULL) != HAL_OK)
  {
    Error_Handler();
  }

  /** Disconnect NADV
  */

  __HAL_AFIO_FSMCNADV_DISCONNECTED();

}

/* USER CODE BEGIN 4 */

/* USER CODE END 4 */

/**
  * @brief  This function is executed in case of error occurrence.
  * @param  None
  * @retval None
  */
void Error_Handler(void)
{
  /* USER CODE BEGIN Error_Handler */
  /* User can add his own implementation to report the HAL error return state */
  while(1)
  {
  }
  /* USER CODE END Error_Handler */
}

#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

 

NHD‐0420DZW‐AB5 Lines

Started by RickJBoard OLEDs

Replies: 1
Views: 2341
Last post January 09, 2015, 04:18:32 PM
by Michael_L
NHD-0420H1Z-FL-GBW-33V3 - 2 Lines Mode Problem

Started by gnyturanBoard Character LCDs

Replies: 6
Views: 3354
Last post October 29, 2015, 01:23:58 PM
by Saurabh_B
Lines on Brighter Part of Display

Started by us.guptaBoard TFTs

Replies: 0
Views: 730
Last post February 15, 2017, 05:41:16 AM
by us.gupta
Vertical colored lines

Started by erpsBoard TFTs

Replies: 7
Views: 4075
Last post January 23, 2015, 08:27:17 AM
by erps
NHD-0216K1Z-YBW: some lines are out

Started by WimG83Board Character LCDs

Replies: 3
Views: 2336
Last post August 10, 2015, 08:09:01 AM
by Michael_L