Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Ipsum

Pages: [1]
1
Graphic LCDs / Re: NHD-C160100DiZ-FSW-FBW w/PIC18F47J53
« on: December 03, 2014, 10:59:35 AM »
I modified my program so that the reset line is held low for 10ms and then brought high right before the initialization is written. It still doesn't seem to display anything, but I have a few questions.

What is nRD, RS, and nWR in this code segment you gave me? Are these lines to the LCD? I know chip select needs to be pulled low, but I don't know what lines those other bits would be.
Code: [Select]
GPIO_SetBits(GPIOC, nRD);
GPIO_SetBits(GPIOC, RS);
GPIO_SetBits(GPIOC, nWR);

Is there some kind of minimum communication clock rate? Am I ok running this at 10k Hz? Do I need to finish sending the init sequence in some number of seconds?

Thanks!

2
Graphic LCDs / NHD-C160100DiZ-FSW-FBW w/PIC18F47J53
« on: November 30, 2014, 09:29:51 PM »
Hi,

I normally don't make these posts but was having a bit of trouble driving this display and figured maybe someone could help. Basically, I am having trouble displaying anything at all on the LCD. I am using the initialization routine found in the datasheet for the NHD-C160100DiZ-FSW-FBW and trying to write the all pixels on instruction to turn the display black.

There is I2C communication since the LCD is pulling the line low in the ack clock pulse after every byte. I can also tell that the oscillator turns on. What I want to know is there some command that I am missing that will display anything at all on the LCD?
Code: [Select]
//LCD.c
#include <xc.h>
#define _XTAL_FREQ 8000000
#include "I2C_BB.h"
#define SLAVE_ADDRESS 0x7E
#define COM_SEND 0x00
#define DATA_SEND 0x40

void init_lcd(void)
{
    I2C_ST();
    I2C_OUT(SLAVE_ADDRESS);
    I2C_OUT(0x00);
    I2C_OUT(0x48); //partial display duty ratio
    I2C_OUT(0x64); // 1/100 duty
    I2C_OUT(0xA0); //ADC select
    I2C_OUT(0xC8); //SHL select
    I2C_OUT(0x44); //initial Com0 register
    I2C_OUT(0x00); //scan from Com0
    I2C_OUT(0xAB); //OSC on
    I2C_OUT(0x26); //
    I2C_OUT(0x81); //set electronic volume
    I2C_OUT(0x15); //vopcode=0x1C
    I2C_OUT(0x56); //set 1/11 bias
    I2C_OUT(0x64); //3x
    __delay_ms(50);
    __delay_ms(50);
    __delay_ms(50);
    __delay_ms(50);
    I2C_OUT(0x2C); //
    I2C_OUT(0x66); //5x
    __delay_ms(50);
    __delay_ms(50);
    __delay_ms(50);
    __delay_ms(50);
    I2C_OUT(0x2E); //
    __delay_ms(10);
    I2C_OUT(0x2F); //power control
    I2C_OUT(0xF3); //bias save circuit
    I2C_OUT(0x00); //
    I2C_OUT(0x96); //frc and pwm
    I2C_OUT(0x38); //external mode
    I2C_OUT(0x75); //
    I2C_OUT(0x97); //3frc, 45 pwm
    I2C_OUT(0x80); //start 16-level grayscale settings
    I2C_OUT(0x00); //
    I2C_OUT(0x81); //
    I2C_OUT(0x00); //
    I2C_OUT(0x82); //
    I2C_OUT(0x00); //
    I2C_OUT(0x83); //
    I2C_OUT(0x00); //
    I2C_OUT(0x84); //
    I2C_OUT(0x06); //
    I2C_OUT(0x85); //
    I2C_OUT(0x06); //
    I2C_OUT(0x86); //
    I2C_OUT(0x06); //
    I2C_OUT(0x87); //
    I2C_OUT(0x06); //
    I2C_OUT(0x88); //
    I2C_OUT(0x0B); //
    I2C_OUT(0x89); //
    I2C_OUT(0x0B); //
    I2C_OUT(0x8A); //
    I2C_OUT(0x0B); //
    I2C_OUT(0x8B); //
    I2C_OUT(0x0B); //
    I2C_OUT(0x8C); //
    I2C_OUT(0x10); //
    I2C_OUT(0x8D); //
    I2C_OUT(0x10); //
    I2C_OUT(0x8E); //
    I2C_OUT(0x10); //
    I2C_OUT(0x8F); //
    I2C_OUT(0x10); //
    I2C_OUT(0x90); //
    I2C_OUT(0x15); //
    I2C_OUT(0x91); //
    I2C_OUT(0x15); //
    I2C_OUT(0x92); //
    I2C_OUT(0x15); //
    I2C_OUT(0x93); //
    I2C_OUT(0x15); //
    I2C_OUT(0x94); //
    I2C_OUT(0x1A); //
    I2C_OUT(0x95); //
    I2C_OUT(0x1A); //
    I2C_OUT(0x96); //
    I2C_OUT(0x1A); //
    I2C_OUT(0x97); //
    I2C_OUT(0x1A); //
    I2C_OUT(0x98); //
    I2C_OUT(0x1E); //
    I2C_OUT(0x99); //
    I2C_OUT(0x1E); //
    I2C_OUT(0x9A); //
    I2C_OUT(0x1E); //
    I2C_OUT(0x9B); //
    I2C_OUT(0x1E); //
    I2C_OUT(0x9C); //
    I2C_OUT(0x23); //
    I2C_OUT(0x9D); //
    I2C_OUT(0x23); //
    I2C_OUT(0x9E); //
    I2C_OUT(0x23); //
    I2C_OUT(0x9F); //
    I2C_OUT(0x23); //
    I2C_OUT(0xA0); //
    I2C_OUT(0x27); //
    I2C_OUT(0xA1); //
    I2C_OUT(0x27); //
    I2C_OUT(0xA2); //
    I2C_OUT(0x27); //
    I2C_OUT(0xA3); //
    I2C_OUT(0x27); //
    I2C_OUT(0xA4); //
    I2C_OUT(0x2B); //[14]
    I2C_OUT(0xA5); //
    I2C_OUT(0x2B); //
    I2C_OUT(0xA6); //
    I2C_OUT(0x2B); //
    I2C_OUT(0xA7); //
    I2C_OUT(0x2B); //
    I2C_OUT(0xA8); //
    I2C_OUT(0x2F); //
    I2C_OUT(0xA9); //
    I2C_OUT(0x2F); //
    I2C_OUT(0xAA); //
    I2C_OUT(0x2F); //
    I2C_OUT(0xAB); //
    I2C_OUT(0x2F); //
    I2C_OUT(0xAC); //
    I2C_OUT(0x32); //
    I2C_OUT(0xAD); //
    I2C_OUT(0x32); //
    I2C_OUT(0xAE); //
    I2C_OUT(0x32); //
    I2C_OUT(0xAF); //
    I2C_OUT(0x32); //
    I2C_OUT(0xB0); //
    I2C_OUT(0x35); //
    I2C_OUT(0xB1); //
    I2C_OUT(0x35); //
    I2C_OUT(0xB2); //
    I2C_OUT(0x35); //
    I2C_OUT(0xB3); //
    I2C_OUT(0x35); //
    I2C_OUT(0xB4); //
    I2C_OUT(0x38); //
    I2C_OUT(0xB5); //
    I2C_OUT(0x38); //
    I2C_OUT(0xB6); //
    I2C_OUT(0x38); //
    I2C_OUT(0xB7); //
    I2C_OUT(0x38); //
    I2C_OUT(0xB8); //
    I2C_OUT(0x3A); //
    I2C_OUT(0xB9); //
    I2C_OUT(0x3A); //
    I2C_OUT(0xBA); //
    I2C_OUT(0x3A); //
    I2C_OUT(0xBB); //
    I2C_OUT(0x3A); //
    I2C_OUT(0xBC); //
    I2C_OUT(0x3C); //
    I2C_OUT(0xBD); //
    I2C_OUT(0x3C); //
    I2C_OUT(0xBE); //
    I2C_OUT(0x3C); //
    I2C_OUT(0xBF); //
    I2C_OUT(0x3C); //end grayscale settings
    I2C_OUT(0x38); //
    I2C_OUT(0x74); //
    I2C_OUT(0xAF); //display on
    I2C_OUT(0xA5); //DISPLAY ALL ON
    I2C_SP();
}
Code: [Select]
//I2C_BB.c
#include "I2C_BB.h"
#include <xc.h>
#include <delays.h>

#define DLAY 100
void I2C_ST(void) {
    delay(DLAY);
    SCL_HIGH();
    SDA_HIGH();
    delay(DLAY);
    SDA_LOW();
    SCL_LOW();
    delay(DLAY);
}

void I2C_SP(void) {
    delay(DLAY);
    SDA_LOW();
    SCL_LOW(); //n
    delay(DLAY);
    SCL_HIGH();
    SDA_HIGH();
    delay(DLAY);
}

char I2C_OUT(unsigned char data) {
    char bit_temp;
    delay(DLAY);
    for (bit_temp = 0; bit_temp < 8; bit_temp++) {
        if (data & 0x80)
            SDA_HIGH();
        else
            SDA_LOW();

        delay(DLAY);
        SCL_LOW();
        delay(DLAY);
        SCL_HIGH();
        delay(2*DLAY);
        data <<= 1;
        SCL_LOW();
        delay(DLAY);
    }
    SDA_HIGH();
    delay(2*DLAY);
    SCL_HIGH();
    delay(2*DLAY);
    SCL_LOW();

    while(SDA_IN){
        delay(DLAY);
        SCL_LOW();
        delay(DLAY);
        SCL_HIGH();
        delay(DLAY);
    }
    delay(DLAY);
    SCL_LOW();

    return 1;
}

unsigned char I2C_IN(char NACK) {
    char bit_temp;
    unsigned char data;

    SDA_HIGH();

    for (bit_temp = 0; bit_temp < 8; bit_temp++) {
        data <<= 1;

        SCL_HIGH();

        if (SDA_IN)
            data |= 1;

        SCL_LOW();
    }

    if (NACK == 1)
        SDA_LOW();
    else
        SDA_HIGH();

    SCL_HIGH();

    SCL_LOW();
    SDA_LOW();

    return data;
}

void delay(unsigned int time) {
    unsigned int t;
    for (t = 0; t < time; t++) {
        Nop();
    }
}

void delay2(unsigned int time) {
    unsigned int t;
    for (t = 0; t < time; t++) {
        __delay_ms(20);
    }
}
Code: [Select]
//I2C_BB.h
#ifndef _I2C_BB_H
#define _I2C_BB_H
#include <xc.h>

void Init_I2C(void);
unsigned char I2C_IN(char NACK);
char I2C_OUT(unsigned char data);
void I2C_SP(void);
void I2C_ST(void);

void delay(unsigned int time);
void delay2(unsigned int time);

#define SCL_HIGH() (SCL = 1)
#define SDA_HIGH() (SDA = 1)
#define SDA_LOW() (SDA = 0,SDA_IN=0)
#define SCL_LOW() (SCL = 0,SCL_IN=0)

#define SCL     TRISBbits.TRISB4
#define SDA     TRISBbits.TRISB5
#define SCL_IN  PORTBbits.RB4
#define SDA_IN  PORTBbits.RB5

#endif


Here is my setup (sorry about the really terrible wire coloring and layout red and black take turns plugging into power)

http://imgur.com/a/gLTKp


Any help is appreciated! Thanks!

Pages: [1]