Author Topic: Initializing NHD-3.5-320240MF-ATXL#-1 using SSD1963 controller  (Read 2163 times)

bont9041

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
    • View Profile
Hey All,

I'm having a very difficult time initializing my display using the 1963 controller. I have looked at their example code and I just can't get it work. I was wondering if you have example code that works for initialization could you possibly send me that. Cheers!

bont9041

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
    • View Profile
Re: Initializing NHD-3.5-320240MF-ATXL#-1 using SSD1963 controller
« Reply #1 on: May 06, 2016, 10:07:13 AM »
Here's my code for reference:
#include "stm32f4xx.h"                  // Device header
#include "ssd1963.h"

#define HighBits(x) ((x>>8) & 0xFF)
#define LowBits(x)  ((x)    & 0xFF)

void LCD_Write_Data(unsigned char data);
void LCD_Write_Command(unsigned char command);
void init_LCD_outputs(void);
void LCD_init(void);
void delay_ms(unsigned int ms);


int main(void)
{
   init_LCD_outputs();
   delay_ms(10);
   LCD_init();
   
   while(1){}

}//main

/////////////////////
//   LCD METHODS   //
/////////////////////
void LCD_Write_Data(unsigned char data)
{
   GPIOD->ODR = data;//setting data
   
   GPIOE->ODR |= (0x0000002);//RS set to 1
   
   GPIOE->ODR &= ~(0x0000010);//Setting CS to 0
   GPIOE->ODR &= ~(0x0000004);//Setting WR to 0
   
   __asm("nop");//wait a clock cycle
   
   GPIOE->ODR |= (0x0000010);//Setting CS to 1
   GPIOE->ODR |= (0x0000004);//Setting WR to 1
}//LCD_Write_Data

void LCD_Write_Command(unsigned char command)
{
   GPIOD->ODR = command;//setting data
   
   GPIOE->ODR &= ~(0x0000002);//RS set to 0
   
   GPIOE->ODR &= ~(0x0000010);//Setting CS to 0
   GPIOE->ODR &= ~(0x0000004);//Setting WR to 0
   

   __asm("nop");//wait a clock cycle
   
   GPIOE->ODR |= (0x0000010);//Setting CS to 1
   GPIOE->ODR |= (0x0000004);//Setting WR to 1
}//LCD_Write_Command

__INLINE void LCD_Write_Reg_Command(unsigned char reg, unsigned char value)
{
   LCD_Write_Command(reg);
   delay_ms(1);
   LCD_Write_Data(value);
}//LCD_Write_Reg_Command

void TFT_35M_delay(int time)
{
  int i,j;
  for(i=0;i<(time^1000);i++){
     for(j=0;j<(time^1000);j++){;}}
}

void LCD_init(void)
{
   
   int i,j;
   GPIOE->ODR &= ~(0x0000010);//clear CS
   GPIOE->ODR &= ~(0x0000008);//clear RD
   
   GPIOE->ODR &= ~(0x0000020);//clear reset bit (reset)
   delay_ms(5);
   TFT_35M_delay(10);
   GPIOE->ODR |= (0x0000020);//set reset bit
   
   delay_ms(100);
   TFT_35M_delay(10);
   LCD_Write_Command(0x01);     //Software Reset
   delay_ms(10);
   TFT_35M_delay(10);
   LCD_Write_Command(0x03);     //Software Reset
   delay_ms(10);
   
   LCD_Write_Command(0xe2);         //setting PLL freq
   LCD_Write_Data(0x1d);      
   LCD_Write_Data(0x02);      
   LCD_Write_Data(0x04);   
   
   delay_ms(10);
   LCD_Write_Reg_Command(0xe0,0x01);    //START PLL
   delay_ms(10);
   LCD_Write_Reg_Command(0xe0,0x03);    //LOCK PLL 

   //TFT_35M_delay(10);
   //LCD_Write_Command(0x01);     //Software Reset do you need this?
   //delay(120);

///*
   //24 bit interface?
   LCD_Write_Command(0xb0);   //SET LCD MODE  SET TFT 18Bits MODE   
   LCD_Write_Data(0x28);         //SET TFT MODE & hsync+Vsync+DEN MODE
   LCD_Write_Data(0x80);         //SET TFT MODE & hsync+Vsync+DEN MODE
   LCD_Write_Data(0x01);         //SET horizontal size=320-1 HightByte
   LCD_Write_Data(0x3f);         //SET horizontal size=320-1 LowByte
   LCD_Write_Data(0x00);         //SET vertical size=240-1 HightByte
   LCD_Write_Data(0xef);         //SET vertical size=240-1 LowByte
   LCD_Write_Data(0x00);         //SET even/odd line RGB seq.=RGB

//*/

   //check this i think its a 24 bit interface
   
   //LCD_Write_Reg_Command(0xf0,0x00);   //SET pixel data I/F format=8bit
   LCD_Write_Reg_Command(0xf0,0x05);     //SET pixel data I/F format=24bit
   
   LCD_Write_Reg_Command(0x3a,0x70);   // set pixel format to 24bit
   //LCD_Write_Reg_Command(0x3a,0x00);   // SET R G B format = 6 6 6
   
   LCD_Write_Command(0xe6);         //SET PCLK freq=4.94MHz  ; pixel clock frequency
   LCD_Write_Data(0x01);      
   LCD_Write_Data(0x05);      
   LCD_Write_Data(0xB8);   
   
///*
   
   LCD_Write_Command(0xb4);      //SET HBP,
   LCD_Write_Data(0x01);         //SET HSYNC Total=440
   LCD_Write_Data(0xb8);
   
   LCD_Write_Data(0x00);         //SET HBP 68
   LCD_Write_Data(0x46);   
   
   LCD_Write_Data(0x0f);         //SET VBP 16=15+1
   
   LCD_Write_Data(0x00);         //SET Hsync pulse start position
   LCD_Write_Data(0x00);   
   LCD_Write_Data(0x00);         //SET Hsync pulse subpixel start position
//*/
///*
   LCD_Write_Command(0xb6);       //SET VBP,
   LCD_Write_Data(0x01);         //SET Vsync total
   LCD_Write_Data(0x48);
   LCD_Write_Data(0x00);         //SET VBP=19
   LCD_Write_Data(0x0b);      
   LCD_Write_Data(0x07);         //SET Vsync pulse 8=7+1
   LCD_Write_Data(0x00);         //SET Vsync pulse start position
   LCD_Write_Data(0x00);
//*/

   LCD_Write_Command(0x21);
   LCD_Write_Command(0x29);      //SET display on
   delay(10);



/*   

   //Trying to write to the screen
   LCD_Write_Command(0x2a);      //SET column address
   LCD_Write_Data(0x00);           //SET start column address=0
   LCD_Write_Data(0x00);
   LCD_Write_Data(0x01);           //SET end column address=319
   LCD_Write_Data(0x3f);
   
   LCD_Write_Command(0x2b);      //SET page address
   LCD_Write_Data(0x00);           //SET start page address=0
   LCD_Write_Data(0x00);
   LCD_Write_Data(0x00);           //SET end page address=239
   LCD_Write_Data(0xef);
   
   
//*/   

/*

   LCD_Write_Command(0x2c);
   for(i=0;i<320*240;i++)         //fill screen with blue pixels
   {
         //sending color (redish) to all pixels
         LCD_Write_Data(0xFF);
         LCD_Write_Data(0x00);
         LCD_Write_Data(0xaa);            
   }
   
//*/


while(1){}   
   
   
   
}//LCD_init


/////////////////////
///  Other Stuff  ///
/////////////////////
void init_LCD_outputs(void)
{
   RCC->AHB1ENR |= RCC_AHB1ENR_GPIOEEN | RCC_AHB1ENR_GPIODEN;
   GPIOE->MODER |= 0x00000555;//PE0-PE5 as outputs
   GPIOD->MODER |= 0x55555555;//PD0-PD7 as outputs
   
   GPIOE->ODR |= 0x0000003F;
}

void delay_ms(unsigned int ms)
{
   if(ms==0){return;}
   RCC->APB1ENR |= RCC_APB1ENR_TIM2EN;

   TIM2->PSC = 15999;  //prescalar to divide 16MHz clock to 1KHz
   TIM2->ARR = ms-1;     //set clock to count to how many ms you want delayed
   TIM2->CNT = 0;      //start count at 0
   TIM2->CR1|= TIM_CR1_CEN;//enable counting

   while(TIM2->SR==0);//WHEN COUNTER IS DONE THE TIM6_SR REG UIF FLAG IS SET
   TIM6->SR=0; //CLEAR uIF FLAG
}//delay_ms

//=============================================================================
// Fill area of specified color
//=============================================================================
void SSD1963_FillArea(unsigned int sx, unsigned int ex, unsigned int sy, unsigned int ey, int color)
{
int i;
SSD1963_SetArea(sx, ex, sy, ey);
SSD1963_WriteCommand(SSD1963_WRITE_MEMORY_START);
for(i = 0; i < ((ex-sx+1)*(ey-sy+1)); i++)
   {
   SSD1963_WriteData(color);
   }
}

Saurabh_B

  • Administrator
  • Hero Member
  • *****
  • Posts: 360
  • Karma: 10
    • View Profile
Re: Initializing NHD-3.5-320240MF-ATXL#-1 using SSD1963 controller
« Reply #2 on: May 06, 2016, 04:35:16 PM »
This was solved Via email.

The problem was due to toggling the CS line before the Write Line.

 

NHD‐4.3‐480272EF‐ATXL#‐CTP | FAN5333 | BBB | Nothing on the Display

Started by Alias_AliasBoard TFTs

Replies: 1
Views: 3535
Last post September 25, 2015, 03:09:24 PM
by Paul_B
NHD-5.0-800480TF-ATXL#-CTP why don't typical timing values work?

Started by jkelleherBoard TFTs

Replies: 2
Views: 2768
Last post August 31, 2015, 05:08:45 AM
by jmag999
NHD-5.0-800480TF-ATXL#-CTP electrical noise interfering with touch

Started by Les.GrantBoard TFTs

Replies: 3
Views: 2373
Last post July 07, 2016, 02:56:01 PM
by Paul_B
help! NHD-4.3-480272EF-ATXL#-T touch panel rotates 90 degrees

Started by knightsunBoard TFTs

Replies: 3
Views: 1310
Last post September 26, 2016, 11:58:01 PM
by knightsun
NHD-5.0-800480TF-ATXL linux driver code

Started by carlovalBoard TFTs

Replies: 1
Views: 2318
Last post March 27, 2015, 08:20:26 AM
by Paul_B