Jump to content
Sign in to follow this  
MrBean74

Newbie Questions, Working with PIC16F84A figureing

Recommended Posts

Hello all,

 

I am new to programming for PIC microcontrollers.  I have been programming using the OOPIC chip, but wanted to create more projects.

 

Example

 

Downloaded an compiled the LCD example from the c2c website.  But now don't know how to connect the LCD to the pic to test the program.

 

Have looked at the datasheet for the 16F84A chip, but having a hard time understanding how to cross referance the program code to the correct pins for wiring.

 

Thanks for any support.

 

Newbie, Joseph Thorman

Share this post


Link to post
Share on other sites

Hi !!

 

First, I suggest look in: http://home.iae.nl/users/pouweha/lcd/lcd.shtml

is a good site with a PIC example.

 

Then for 4 bit data interfase you need wiring

 

PIC16F84            HD44780

PORTB.0             RS - Pin 4

PORTB.1             E   - Pin 6

 

PORTA.0             D0 - Pin 7

PORTA.1             D1 - Pin 8

PORTA.2             D3 - Pin 9

PORTA.3             D4 - Pin 10

 

Look in http://home.iae.nl/users/pouweha/lcd/lcd.shtml

how connect control resistor contraste

 

And then be patient, because these codes need some

tunning.

 

I hope that help

Bye

Daniel

Share this post


Link to post
Share on other sites

Daniel,

 

How did you know what pins to use?

 

I am looking at the code can seem to understand

how you got the those pins.

 

I have tried to connect the LCD to the pins you

suggested and I can not get the example LCD

program to work.

 

Do you have a example that is tunned correctly

I can use?

 

Thanks, Joseph

Share this post


Link to post
Share on other sites

Joseph

 

If we talk about this:

 

// Ports naming

#define LCD            porta

#define CONTROL     portb

 

// PINs naming

#define LCD_E        1

#define LCD_RS      0

 

// Some usefull macroses

#define LCD_E_U      set_bit(CONTROL,LCD_E)

#define LCD_E_D      clear_bit(CONTROL,LCD_E)

#define LCD_RS_U    set_bit(CONTROL,LCD_RS)

#define LCD_RS_D    clear_bit(CONTROL,LCD_RS)

#define SetPos(line,pos) LCD_cmd(0x80 + line*0x40 + pos)

#define byte    unsigned char

 

// Use nested macroses

#define write_data  LCD_RS_U; LCD_E_U; LCD_E_D;

#define write_cmd   LCD_RS_D; LCD_E_U; LCD_E_D;

 

when you will call i.e.

 

/*********************************************

*  LCD_cmd - Write ASCII character to LCD peripheral  *

*      configured as a 4 bit interface                *

*********************************************/

void LCD_char(byte data)

{

   LCD = (data & 0xF0) | (LCD & 0x0F);         /* Write HI nibble word to LCD */

   write_data;

   LCD = ((data << 4) & 0xF0) | (LCD & 0x0F);  /* Write LO nibble word to LCD */

   write_data;

   delay_us(160);

}

 

if fact LCD = PORTA ( dataport )

then

(LCD & 0x0F)

mask 4 high bit of PORTA

then use

PORTA.0, PORTA.1, PORTA.2 and PORTA.3

for data lines

 

when use

   write_data;

call

LCD_RS_U

   set_bit(CONTROL,LCD_RS)

        set_bit(PORTB, 0)

             use PORTB.0 as RS

LCD_E_U

    set_bit(CONTROL,LCD_E)

        set_bit(PORTB,1)

             use PORTB.1 as E

LCD_E_D

     clear_bit(CONTROL,LCD_E)

        clear_bit(PORTB,1)

             use PORTB.1 as E

 

I haven´t used this code, and thiese lines aren´t easy for my

 

LCD = (data & 0xF0) | (LCD & 0x0F);  /* Write HI

 

LCD = ((data << 4) & 0xF0) | (LCD & 0x0F);  /* Write LO

 

Would you try with

 

LCD = ((data >> 4) | (LCD & 0xF0);  /* Write HI

 

LCD = (data  & 0x0F) | (LCD & 0xF0);  /* Write LO

 

or more easy use

 

#define LCD            portb

and use

PORTB.4, PORTB.5, PORTB.6 and PORTB.7

for data lines

 

Finally I supose that the best solutios is the last

maybe is a mistake in source code.

 

I Hope help

Daniel

Share this post


Link to post
Share on other sites

I forget it

 

I have some example, I find it and send.

But I remember my head hurst when was

working with, finally works fine.

 

Bye

Daniel

Share this post


Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...