Author Topic: NHD-C12864A1Z-FSW-FBW-HTT pixel problem  (Read 229 times)

Christophe_

  • Newbie
  • *
  • Posts: 1
  • Karma: 0
    • View Profile
NHD-C12864A1Z-FSW-FBW-HTT pixel problem
« on: September 13, 2018, 05:39:12 AM »
Hello,

I am working with NHD-C12864A1Z-FSW-FBW-HTT (ST7565r) and pic 18F46k20 (I tried at 1 MHz, 8 and 64 MHz) and I have a problem with pixels which are on instead to be off. They appear just after initilization and when I send command - text to the screen.

Please find the code (it's just a test...)
I think is due to noise and I don't know how I can remove it.

I thank you in advance for your help.


Code: [Select]


#include <pic18f46k20.h>
#include "Configuration_Header_File.h"
#include "SPI_Header_File.h"
#include "ST7565_Font.h"
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <xc.h>
#define _XTAL_FREQ 1000000


#define ST7565R_CMD_DISPLAY_ON                     0xAF
#define ST7565R_CMD_DISPLAY_OFF                    0xAE
#define ST7565R_CMD_START_LINE_SET(line)           (0x40 | (line))
#define ST7565R_CMD_PAGE_ADDRESS_SET(page)         (0xB0 | (page))
#define ST7565R_CMD_COLUMN_ADDRESS_SET_MSB(column) (0x10 | (column))
#define ST7565R_CMD_COLUMN_ADDRESS_SET_LSB(column) (0x00 | (column))
#define ST7565R_CMD_ADC_NORMAL                     0xA0
#define ST7565R_CMD_ADC_REVERSE                    0xA1
#define ST7565R_CMD_DISPLAY_NORMAL                 0xA6
#define ST7565R_CMD_DISPLAY_REVERSE                0xA7
#define ST7565R_CMD_DISPLAY_ALL_POINTS_OFF         0xA4
#define ST7565R_CMD_DISPLAY_ALL_POINTS_ON          0xA5
#define ST7565R_CMD_LCD_BIAS_1_DIV_5_DUTY33        0xA1
#define ST7565R_CMD_LCD_BIAS_1_DIV_6_DUTY33        0xA2
#define ST7565R_CMD_NORMAL_SCAN_DIRECTION          0xC0
#define ST7565R_CMD_REVERSE_SCAN_DIRECTION         0xC8
#define ST7565R_CMD_VOLTAGE_RESISTOR_RATIO_0       0x20
#define ST7565R_CMD_VOLTAGE_RESISTOR_RATIO_1       0x21
#define ST7565R_CMD_VOLTAGE_RESISTOR_RATIO_2       0x22
#define ST7565R_CMD_VOLTAGE_RESISTOR_RATIO_3       0x23
#define ST7565R_CMD_VOLTAGE_RESISTOR_RATIO_4       0x24
#define ST7565R_CMD_VOLTAGE_RESISTOR_RATIO_5       0x25
#define ST7565R_CMD_VOLTAGE_RESISTOR_RATIO_6       0x26
#define ST7565R_CMD_VOLTAGE_RESISTOR_RATIO_7       0x27
#define ST7565R_CMD_POWER_CTRL_ALL_ON              0x2F
#define ST7565R_CMD_SLEEP_MODE                     0xAC
#define ST7565R_CMD_NORMAL_MODE                    0xAD
#define ST7565R_CMD_RESET                          0xE2
#define ST7565R_CMD_NOP                            0xE3
#define ST7565R_CMD_ELECTRONIC_VOLUME_MODE_SET     0x81
#define ST7565R_CMD_ELECTRONIC_VOLUME(volume)      (0x3F & (~volume))
#define ST7565R_CMD_BOOSTER_RATIO_SET              0xF8
#define ST7565R_CMD_BOOSTER_RATIO_2X_3X_4X         0x00
#define ST7565R_CMD_BOOSTER_RATIO_5X               0x01
#define ST7565R_CMD_BOOSTER_RATIO_6X               0x03
#define ST7565R_CMD_STATUS_READ                    0x00
#define ST7565R_CMD_END                            0xEE
#define ST7565R_CMD_READ_MODIFY_WRITE              0xE0

void Init();
void SendCommand(char);
void SendData(char);
void SendString(char *);
void MSdelay(unsigned int);
void st7565_Clear();
void PositionXY(char);
void glcd_set_contrast(uint8_t val);
void st7565r_set_page_address(unsigned char address);
void st7565r_set_column_address(unsigned char address);



#define RES     LATBbits.LATB1  // RS : Commande.  A2
#define DC      LATBbits.LATB2  // R/W : Write. LATB0



void main()
{
    //OSCCON = 0X72;              /* set internal oscillator frequency, 8 MHz*/
   
    //used when 8MHz
    //    OSCCON = 0b01100000;
    //    PLLEN = 0;                     // turn off the PLL
   
    // 1MHz
    OSCCON = 0b00110000;
    PLLEN = 0; 
    TRISD = 0;                  /* set PORT as output port*/
    SPI_Init_Master();          /* initialize SPI master*/
   
    __delay_ms(100);
    Init();               /* initialize ST7565R display */
    st7565_Clear();              /* clear ST7565R display */
 

    PositionXY(0);      /* set X and Y position for printing */
    SendCommand(0xAE);
    SendString("M");
    SendCommand(0xAF);
    //SendCommand(0x80);
    while(1);
}
void SendCommand(char cmd)
{
    DC = 0;         /* Data/Command pin, D/C=1 - Data, D/C = 0 - Command*/
    CS = 0;         /* enable chip */
    SPI_Write(cmd); /* write command to the ST7565R   */
    //__delay_ms(2);
    CS = 1;         /* disable chip */
}
void SendData(char dat)
{   
    char i;
    DC = 1;         /* Data/Command pin, D/C=1 - Data, D/C = 0 - Command*/
    CS = 0;         /* enable chip */
    for(i=0;i<5;i++)
    {
        SPI_Write(font[(dat) - (0x20)][i]); /* write data to the ST7565R   */
    }
    __delay_ms(2);
    CS = 1;         /* disable chip */
}

void SendString(char *data)
{
    char i;
    while((*data)!=0)
    {   
        SendData(*data);
        data++;
    }
   
}

void glcd_set_contrast(uint8_t val)
{
/* Can set a 6-bit value (0 to 63)  */

/* Must send this command byte before setting the contrast */
SendCommand(0x81);

/* Set the contrat value ("electronic volumne register") */
if (val > 63) {
SendCommand(63);
} else {
SendCommand(val);
}
return;
}

void PositionXY(char Y)
{
    //SendCommand(0x80 | X);    /* set X position */
    SendCommand(0x40 | Y);    /* set Y position */ 
}

void Init()
{
    /*apply 100 ms reset(low to high) pulse */
    RES = 1;
    __delay_ms(50);   
    RES = 0;                    /* enable reset */
    //MSdelay(100);
    __delay_ms(600);
    RES = 1;                    /* disable reset */
    __delay_ms(20);

    SendCommand(ST7565R_CMD_LCD_BIAS_1_DIV_6_DUTY33); //1/9 bias
    SendCommand(ST7565R_CMD_ADC_NORMAL); //RAM->SEG output = normal (A0)
    SendCommand(ST7565R_CMD_REVERSE_SCAN_DIRECTION); //COM scan direction = normal: C8
    SendCommand(0x40);
    SendCommand(0x2C);
    __delay_ms(300);
    SendCommand(0x2E);
    __delay_ms(300);
    SendCommand(ST7565R_CMD_VOLTAGE_RESISTOR_RATIO_6);
    SendCommand(ST7565R_CMD_POWER_CTRL_ALL_ON); //power control set

    SendCommand(ST7565R_CMD_BOOSTER_RATIO_SET);
    SendCommand(ST7565R_CMD_BOOSTER_RATIO_2X_3X_4X);
   
    SendCommand(0xAF);
    glcd_set_contrast(20);



    SendCommand(0xB0);

   
}

void st7565_Clear()

    int byteAddress = 0;
    char page = 0b10110000;
    st7565r_set_page_address(page);          // call st7565r_set_page_address(unsigned char address) here !!
    st7565r_set_column_address(0);
    int donebitmapSize = 0;
    //=================================================
    while(donebitmapSize < 494)
    {
        for(int column = 0; column < 122; column++)
        {
            SendCommand(0x00) ;
            donebitmapSize++;
        }
    //=================================================
    page = page + 0b00000001;
    SendCommand(page);
    st7565r_set_column_address(0);
   
    }
   
}

  void st7565r_set_page_address(unsigned char address)
  {
      SendCommand(ST7565R_CMD_PAGE_ADDRESS_SET(address));
  }
 
  void st7565r_set_column_address(unsigned char address)
  { 
     address &= 0x7F;   // anded with (01111111)
     SendCommand(ST7565R_CMD_COLUMN_ADDRESS_SET_MSB(address >> 4));
     SendCommand(ST7565R_CMD_COLUMN_ADDRESS_SET_LSB(address & 0x0F));
  }

/*********************************Delay Function********************************/
void MSdelay(unsigned int val)
{
     unsigned int i,j;
        for(i=0;i<=val;i++)
            for(j=0;j<81;j++);      /*This count Provide delay of 1 ms for 8MHz Frequency */
 }







Christophe

Ted_M

  • Administrator
  • Jr. Member
  • *****
  • Posts: 54
  • Karma: 3
    • View Profile
Re: NHD-C12864A1Z-FSW-FBW-HTT pixel problem
« Reply #1 on: September 19, 2018, 09:32:00 AM »
This topic was supported through email and was resolved by clearing buffer memory.

 

NHD‐3.5‐320240MF‐ATXL#‐CTP‐1 Problem with standby mode

Started by guenterBoard TFTs

Replies: 0
Views: 4423
Last post June 16, 2016, 12:14:36 PM
by guenter
NHD‐2.4‐240320SF‐CTXL#‐FTN1 touch-screen problem

Started by hbcelebiBoard TFTs

Replies: 5
Views: 7931
Last post December 10, 2014, 11:19:05 AM
by Michael_L
Working on NHD‐2.4‐240320SF‐CTXL#‐FTN1, have problem in initialization

Started by sli25Board TFTs

Replies: 6
Views: 7181
Last post June 04, 2015, 09:52:25 PM
by sli25
Problem in bringing up NHD‐2.4‐240320SF‐CTXL#‐FTN1 on Renesas RL78/G14

Started by sli25Board TFTs

Replies: 3
Views: 5855
Last post May 28, 2015, 02:59:03 PM
by Michael_L
problem with NHD‐2.23‐12832UCB3

Started by luisvalsecaBoard OLEDs

Replies: 1
Views: 3170
Last post January 24, 2017, 02:52:53 PM
by Saurabh_B