who knows how to let LCD03 work with 18F2520?


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    May 2008
    Posts
    3

    Question who knows how to let LCD03 work with 18F2520?

    who knows how to let LCD03 work with 18F2520?

    I find the example of LCD03 with 16F877, but do not know how to Change it for 18f2520.
    Is there anyone who knows how to work with them.

    I tried to find PICbasic example, but did not find.

    Thanks very much if you can help.

  2. #2
    Join Date
    May 2008
    Posts
    3


    Did you find this post helpful? Yes | No

    Default Code For 16f877

    Quote Originally Posted by Janine View Post
    who knows how to let LCD03 work with 18F2520?

    I find the example of LCD03 with 16F877, but do not know how to Change it for 18f2520.
    Is there anyone who knows how to work with them.

    I tried to find PICbasic example, but did not find.

    Thanks very much if you can help.
    ------------------------I FORGET THE CODE----------
    ///////////////////////////////////////////////////////////////////////
    //
    // PIC16F877 - LCD03 example
    // Written using HITECH PIC16 compiler
    //
    // This code is Freeware - Use it for any purpose you like.
    //
    ///////////////////////////////////////////////////////////////////////


    #include <pic.h>
    #include <stdio.h>

    __CONFIG(0x3b32);

    void clrscn(void); // prototypes
    void cursor(char pos);
    void print(char *p);
    void setup(void);

    char s[21]; // buffer used to hold text to print

    void main(void)
    {
    setup(); // sets up the PIC16F877 I2C port
    clrscn(); // clears the LCD03 disply
    cursor(26); // sets cursor to center the text on 2nd row of LCD03
    sprintf(s,"Hello World"); // Traditional welcome text, printed into our buffer
    print(s); // send it to the LCD03

    while(1); // just stops
    }


    void clrscn(void)
    {
    SEN = 1; // send start bit
    while(SEN); // and wait for it to clear

    SSPIF = 0;
    SSPBUF = 0xc6; // LCD02 I2C address
    while(!SSPIF); // wait for interrupt
    SSPIF = 0; // then clear it.

    SSPBUF = 0; // address of register to write to
    while(!SSPIF); //
    SSPIF = 0; //

    SSPBUF = 12; // clear screen
    while(!SSPIF); //
    SSPIF = 0; //

    SSPBUF = 4; // cursor off
    while(!SSPIF); //
    SSPIF = 0; //

    PEN = 1; // send stop bit
    while(PEN); //
    }


    void cursor(char pos)
    {
    SEN = 1; // send start bit
    while(SEN); // and wait for it to clear

    SSPIF = 0;
    SSPBUF = 0xc6; // LCD02 I2C address
    while(!SSPIF); // wait for interrupt
    SSPIF = 0; // then clear it.

    SSPBUF = 0; // address of register to write to
    while(!SSPIF); //
    SSPIF = 0; //

    SSPBUF = 2; // set cursor
    while(!SSPIF); //
    SSPIF = 0; //
    SSPBUF = pos; //
    while(!SSPIF); //
    SSPIF = 0; //

    PEN = 1; // send stop bit
    while(PEN); //
    }


    void print(char *p)
    {
    SEN = 1; // send start bit
    while(SEN); // and wait for it to clear

    SSPIF = 0;
    SSPBUF = 0xc6; // LCD02 I2C address
    while(!SSPIF); // wait for interrupt
    SSPIF = 0; // then clear it.

    SSPBUF = 0; // address of register to write to
    while(!SSPIF); //
    SSPIF = 0; //

    while(*p) {
    SSPBUF = *p++; // write the data
    while(!SSPIF); //
    SSPIF = 0; //
    }

    PEN = 1; // send stop bit
    while(PEN); //
    }


    void setup(void)
    {
    unsigned long x;

    TRISC = 0xff;
    PORTC = 0xff;

    SSPSTAT = 0x80;
    SSPCON = 0x38;
    SSPCON2 = 0x00;
    SSPADD = 10; // SCL = 91khz with 4Mhz Osc

    for(x=0; x<60000; x++); // wait for LCD03 to initialise

    }

  3. #3
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Talking Adress error !!!

    Hi, Janine

    did you notice it's a PicBASIC Forum here .... ???

    NOT a "C "Forum

    sorry and have a nice Afternoon ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  4. #4
    Join Date
    May 2008
    Posts
    3


    Did you find this post helpful? Yes | No

    Default I am just wondering if there are some one know how to change c code to picbasic

    I am just wondering if there are some one know how to change c code to picbasic.

    Or if some one can help me to write PICBASIC code for LCD03

    I also use BASIC.

Similar Threads

  1. PortA Doesn't Work
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 11
    Last Post: - 8th September 2015, 18:41
  2. How to set ICD-2 clone to work with PBP?
    By G-R-C in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 20th October 2006, 02:50
  3. with 40 MHZ osc serin2 not work
    By Pedro Santos in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 13th August 2006, 22:56
  4. blink.bas help cant make any 18f's work
    By Bonxy in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 13th December 2004, 21:28
  5. Pin RA4 doesn't work
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 0
    Last Post: - 15th July 2004, 12:03

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts