Author Topic: I2C Controller (PIC16F960) more detail needed  (Read 3144 times)

samiam208

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
    • View Profile
I2C Controller (PIC16F960) more detail needed
« on: June 10, 2014, 10:25:10 PM »
I am trying to use a Serial LCD Character Display with the PIC16F690 controller in the I2C mode. I am writing a bit-bang assembly code program.  I cannot find sufficient info to accomplish the I2C protocol for this controller.  What is the sequence I use to send ASCII characters to be displayed? Will this work?-- Start, Device address, ASCII Byte,……..more ASCII Bytes, Stop?  The “Table of Commands” does not show any Prefix or command for displaying characters and does not show anything for multi-character(byte) transfers.  The Data Sheet for the controller is just the generic PIC and does not help.  Are there any documents that detail the I2C interface?  You know the kind of detail that is shown for an I2C EEPROM or RTC.  The exact display I am trying to use is NHD-0216K3Z-NS(RGB)-FWB-V3.

Michael_L

  • Administrator
  • Hero Member
  • *****
  • Posts: 356
  • Karma: 33
    • View Profile
Re: I2C Controller (PIC16F960) more detail needed
« Reply #1 on: June 11, 2014, 09:42:28 AM »
The PIC controller datasheet we provide a link to in our spec is the actual datasheet for that PIC.  Have you looked at pages 184-186?  Also included in our datasheet is also a link to example code for our serial LCDs.  You may access this to help see how the interface works with our display.  In addition to that example code, you may also refer to the below Arduino code I have for this display:

Code: [Select]
//---------------------------------------------------------
/*
NHD_0216K3Z_mega.ino
Program for writing to Newhaven Display 2 x 16 (K3Z) Character LCD with PIC16F690 controller

(c)2014 Mike LaVine - Newhaven Display International, LLC.

        This program is free software; you can redistribute it and/or modify
        it under the terms of the GNU General Public License as published by
        the Free Software Foundation; either version 2 of the License, or
        (at your option) any later version.

        This program is distributed in the hope that it will be useful,
        but WITHOUT ANY WARRANTY; without even the implied warranty of
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        GNU General Public License for more details.
*/
//---------------------------------------------------------

#include <Wire.h>

int ASDA = 20;      // SDA signal connected to pin 20 (SDA) of Arduino Mega 2560
int ASCL = 21;      // SCL signal connected to pin 21 (SCL) of Arduino Mega 2560

unsigned char text1[]={"Newhaven Display"};
unsigned char text2[]={" International  "};

unsigned char tx_packet[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00);

const char slave2w = 0x28;   //0x50 shifted over 1 bit

void send_packet(unsigned char x)
{
  unsigned char ix;
  Wire.beginTransmission(slave2w);
  for(ix=0;ix<x;ix++)
  {
    Wire.write(tx_packet[ix]);
  }
  Wire.endTransmission();
}

void lcd_cursor(unsigned int x)
{
  tx_packet[0] = 0xFE;
  tx_packet[1] = 0x45;
  tx_packet[2] = x;
  send_packet(3);
}

void lcd_clear(void)
{
  tx_packet[0] = 0xFE;
  tx_packet[1] = 0x51;
  send_packet(2);
}

void setup()       //runs first when powered on
{
  pinMode(ASCL, OUTPUT);      //set Arduino I2C lines as outputs
  pinMode(ASDA, OUTPUT);      //
  digitalWrite(ASCL, LOW);    //
  digitalWrite(ASDA, LOW);    //
  delay(100);    //100ms delay
}

void loop()
{
  Wire.begin();             //initialize Arduino I2C
  TWBR = 152;               //change Arduino Mega 2560 I2C clock frequency from 100kHz to 50kHz
  lcd_clear();
 
  tx_packet[0] = 0xFE;
  tx_packet[1] = 0x52;
  tx_packet[2] = 40;        //contrast 1 - 50
  send_packet(3);
 
  tx_packet[1] = 0x53;     
  tx_packet[2] = 15;        //backlight 1 - 15
  send_packet(3);
 
  tx_packet[1] = 0x48;      //underline cursor off
  send_packet(2);
 
  tx_packet[1] = 0x46;      //cursor home
  send_packet(2);
 
  delay(250);
 
  while(1)
  {
  for(unsigned char i=0;i<16;i++)
  {
    tx_packet[i] = text1[i];
  }
  send_packet(16);
 
  lcd_cursor(0x40);
  delay(100);  //100ms delay
 
  for(unsigned char i=0;i<16;i++)
  {
    tx_packet[i] = text2[i];
  }
  send_packet(16);
  delay(1000);
  }
}


Any other detailed information regarding that PIC controller can be found in the datasheet for it, accessible by clicking the link to it in our spec.

samiam208

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
    • View Profile
Re: I2C Controller (PIC16F960) more detail needed
« Reply #2 on: June 18, 2014, 09:23:16 AM »
Thanks,
I got it now.
Samiam208

 

NHD‐3.5‐320240MF‐34 Controller Board

Started by mmlquinlanBoard Customer Projects

Replies: 0
Views: 1337
Last post November 08, 2016, 12:25:24 PM
by mmlquinlan
NHD‐5.0‐800480TF‐34 Controller Board Back Light (B/L Enable)

Started by MidknighTrainBoard TFTs

Replies: 11
Views: 1930
Last post September 14, 2016, 10:30:31 PM
by MidknighTrain
NHD-5.0-800480TF-ATXL#-T and NHD-5.0-800480TF-20 Controller Board No Touch?

Started by dfanslerBoard TFTs

Replies: 5
Views: 891
Last post May 26, 2017, 11:10:57 AM
by Saurabh_B
NHD-2.4-240320CF-CTXI#-FT (ST7789S controller) and STM32F4 FSMC LCD Interface

Started by deshayesBoard TFTs

Replies: 1
Views: 2669
Last post March 17, 2016, 06:25:18 PM
by fahad
NHDEV firmware to support NHD-2.4-240320CF-CTXI#-FT (ST7889S controller)

Started by deshayesBoard Evaluation Tools

Replies: 1
Views: 2624
Last post December 17, 2015, 09:52:29 AM
by Saurabh_B