Author Topic: PIC24Fj64GA004 communicating with the NHD-C0220-BiZ-FSW-FBW-3V3  (Read 1963 times)

joeBellIII

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
    • View Profile
PIC24Fj64GA004 communicating with the NHD-C0220-BiZ-FSW-FBW-3V3
« on: February 19, 2015, 08:56:28 PM »
I am using the NHD-C0220-BiZ-FSW-FBW-3V3 2x20 Character I2C serial display. I am attempting to control this display using the PIC24FJ64GA004 MCU. From a similair article on your forum and the data sheet, I have derived a bit of code:
Code: [Select]
#include <i2c.h>
#include "I2C1.h"
#include "nhLCD.h"
#include "pinConfiguration.h"
//https://github.com/Workshopshed/LCD/blob/master/ST7036.cpp
//AND
//Marius thanks you http://www.eevblog.com/forum/beginners/newhaven-20x2-char-lcd-how-to-set-char-position/
/****************************************************
* Initialization For ST7036i *
*****************************************************/
#define SLAVE_ID                                  0x78
#define COMSEND                                  0x00    //commence send?
#define DATA_SEND                              0x40
#define FIRST_CONT_BYTE_MASK        0x80

void init_LCD()
{
    lcdReset = OFF;
    __delay_ms(100);
    lcdReset = ON;
    __delay_ms(100);

    StartI2C1();                                        //Send the Start Bit
    IdleI2C1();                                         //Wait to complete
    MasterWriteI2C1(SLAVE_ID);  //Slave Address
    IdleI2C1();                 //Wait to complete
    //__delay_ms(10);
    MasterWriteI2C1(COMSEND);   //Control Byte
    IdleI2C1();                 //Wait to complete
    //__delay_ms(10);
    MasterWriteI2C1(0x39);      //Control Byte
    IdleI2C1();                 //Wait to complete
    __delay_ms(1);
    MasterWriteI2C1(0x14);      //
    IdleI2C1();                 //Wait to complete
    //__delay_ms(10);
    MasterWriteI2C1(0x70);      //
    IdleI2C1();                 //Wait to complete
    //__delay_ms(10);
    MasterWriteI2C1(0x5E);      //
    IdleI2C1();                 //Wait to complete
    //__delay_ms(10);
    MasterWriteI2C1(0x6D);      //
    IdleI2C1();                 //Wait to complete
    //__delay_ms(10);
    MasterWriteI2C1(0x0C);      //
    IdleI2C1();                 //Wait to complete
    //__delay_ms(10);
    MasterWriteI2C1(0x01);      //
    IdleI2C1();                 //Wait to complete
    //__delay_ms(10);
    MasterWriteI2C1(0x06);
    IdleI2C1();                 //Wait to complete
    //__delay_ms(10);
    StopI2C1();                 //Send the Stop condition
    IdleI2C1();                 //Wait to complete
    __delay_ms(1);              //wait
}

/* Send string of ASCII data to LCD */
/*****************************************************/
void Show(uchar_t *text)
{
    int n;
    StartI2C1();                                        //Send the Start Bit
    IdleI2C1();                                         //Wait to complete

    MasterWriteI2C1(SLAVE_ID);
    IdleI2C1();                 //Wait to complete
    MasterWriteI2C1(COMSEND);
    IdleI2C1();                 //Wait to complete
    MasterWriteI2C1(DATA_SEND);
    IdleI2C1();                 //Wait to complete
    for(n=0;n<20;n++)               //20 characters per line
    {
        MasterWriteI2C1(*text);
        IdleI2C1();                 //Wait to complete
        ++text;
//        __delay_ms(10);
    }
    StopI2C1();                     //Send the Stop condition
    IdleI2C1();                     //Wait to complete
    __delay_ms(1);                  //wait
}
/*****************************************************/
/*****************************************************/
/*****************************************************/

I am calling the init_LCD() function in my main. I am using the recommended 1uF caps and 10k resistors for pull-ups as per schematic on data sheet.  I have used my Saleae logic analyzer to analyze the circuit. The result: with 10k pullups, I get garbage... With 2.2k resistors, I am seeing my entire bitstream from the init_LCD() function as I would expect to see. Problem is that I am not receiving the Acks back from the LCD hence no signs of life from the LCD.  I have bought several of these for a project I am working on. I have attempted with three units thus far, all have identical results.  Are the pins on the LCD numbered from left to right as viewed from the front of the display?  I'm at a loss, any suggestions?

joeBellIII

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
    • View Profile
Re: PIC24Fj64GA004 communicating with the NHD-C0220-BiZ-FSW-FBW-3V3
« Reply #1 on: February 19, 2015, 11:17:03 PM »
Found Problem with hardware. Please note that datasheet is deceiving and the pins are actually 8-1 when viewing the LCD from the front...