CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

16F684 and EEprom

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Christian
Guest







16F684 and EEprom
PostPosted: Sun Nov 03, 2002 2:03 am     Reply with quote

Hi!

I'm a newbie, and I really have troubble writing and reading
to/from the EEPROM using c compiler, and 16f684.

Anybody who can help?

Anything is usefull to me!!!

Christian
___________________________
This message was ported from CCS's old forum
Original Post ID: 8443
Christian
Guest







I ment 16F628
PostPosted: Sun Nov 03, 2002 2:11 am     Reply with quote

:=Hi!
:=
:=I'm a newbie, and I really have troubble writing and reading
:=to/from the EEPROM using c compiler, and 16f628.
:=
:=Anybody who can help?
:=
:=Anything is usefull to me!!!
:=
:=Christian
___________________________
This message was ported from CCS's old forum
Original Post ID: 8445
johnpcunningham
Guest







Re: I ment 16F628
PostPosted: Sun Nov 03, 2002 10:33 am     Reply with quote

Simple to use the built in functions on this one. The general format is:

write_eeprom( address, value );
read_eeprom( address, value );

Here is a code example:

void main{
char i,j,k;

write_eeprom(0x00, 0x11); //write hex 0x11 to location 0
write_eeprom(0x01, 0x22); //write hex 0x22 to location 1
write_eeprom(0x02, 0x33); //write hex 0x33 to location 2

i = read_eeprom(0x00); //i = 0x11
j = read_eeprom(0x01); //j = 0x22
k = read_eeprom(0x02); //k = 0x33

while(1){};
}
___________________________
This message was ported from CCS's old forum
Original Post ID: 8455
Christian
Guest







Re: I ment 16F628
PostPosted: Sun Nov 03, 2002 12:50 pm     Reply with quote

Thanks.

Do u know how to print this on the LCD-display?



:=Simple to use the built in functions on this one. The general format is:
:=
:=write_eeprom( address, value );
:=read_eeprom( address, value );
:=
:=Here is a code example:
:=
:=void main{
:=char i,j,k;
:=
:=write_eeprom(0x00, 0x11); //write hex 0x11 to location 0
:=write_eeprom(0x01, 0x22); //write hex 0x22 to location 1
:=write_eeprom(0x02, 0x33); //write hex 0x33 to location 2
:=
:=i = read_eeprom(0x00); //i = 0x11
:=j = read_eeprom(0x01); //j = 0x22
:=k = read_eeprom(0x02); //k = 0x33
:=
:=while(1){};
:=}
___________________________
This message was ported from CCS's old forum
Original Post ID: 8460
johnpcunningham
Guest







Re: I ment 16F628
PostPosted: Sun Nov 03, 2002 12:56 pm     Reply with quote

Your question is vauge. Whcih LCD? What controller is being used; Hitachi, Toshiba, other?

JC
___________________________
This message was ported from CCS's old forum
Original Post ID: 8461
Christian
Guest







Re: I ment 16F628
PostPosted: Sun Nov 03, 2002 1:23 pm     Reply with quote

Sorry,

I can't seem to find anything on the LCD-display, but: dmc16207
what do u mean controller? pic16F628? Bluebird?

:=Your question is vauge. Whcih LCD? What controller is being used; Hitachi, Toshiba, other?
:=
:=JC
___________________________
This message was ported from CCS's old forum
Original Post ID: 8465
Christian Bech
Guest







Re: I ment 16F628
PostPosted: Sun Nov 03, 2002 2:25 pm     Reply with quote

Hi.
16X2 hitachi, is what I got. can u help?
Thx


:=Your question is vauge. Whcih LCD? What controller is being used; Hitachi, Toshiba, other?
:=
:=JC
___________________________
This message was ported from CCS's old forum
Original Post ID: 8466
johnpcunningham
Guest







Re: I ment 16F628
PostPosted: Mon Nov 04, 2002 12:06 pm     Reply with quote

<font face="Courier New" size=-1>OK, the DMC16207 LCD you are using is made by Optrex. The controller that it uses is an Hitachi HD44780. The technical spec can be downloaded here:

<a href="http://www.optrex.com/SiteImages/PartList/SPEC/16207cae.pdf" TARGET="_blank"> <a href="http://www.optrex.com/SiteImages/PartList/SPEC/16207cae.pdf" TARGET="_blank"> <a href="http://www.optrex.com/SiteImages/PartList/SPEC/16207cae.pdf" TARGET="_blank"> <a href="http://www.optrex.com/SiteImages/PartList/SPEC/16207cae.pdf" TARGET="_blank"> <a href="http://www.optrex.com/SiteImages/PartList/SPEC/16207cae.pdf" TARGET="_blank">http://www.optrex.com/SiteImages/PartList/SPEC/16207cae.pdf</a></a></a></a></a>

To program your software you should download this:

<a href="http://www.optrex.com/pdfs/Dmcman_full.pdf" TARGET="_blank"> <a href="http://www.optrex.com/pdfs/Dmcman_full.pdf" TARGET="_blank"> <a href="http://www.optrex.com/pdfs/Dmcman_full.pdf" TARGET="_blank"> <a href="http://www.optrex.com/pdfs/Dmcman_full.pdf" TARGET="_blank"> <a href="http://www.optrex.com/pdfs/Dmcman_full.pdf" TARGET="_blank">http://www.optrex.com/pdfs/Dmcman_full.pdf</a></a></a></a></a>

///////////////////////////////////////////////////////////////
Generally, you read and write data to the LCD. You use an 8 bit port, and 3 other pins RS, E, and RW to control the data flow. The 3 pins are used to strobe in the data and to tell the Hitcahi controller if it is a command or data.

I'm sure you will ahve a lot of questions. Here are some funciton calls that I have used to interface to this module to get you started:

<PRE>
#ifndef __DMC_H
/* LCD COMMANDS */

/*clears the display & address */
#define clear_display 0x01

/*sets the curser to the home position*/
#define cursor_home 0x02

/*sets the curser to the home position*/
#define entry_mode 0x06

/*decrements the cursor after writing data */
#define write_dec 0x05

/*increments the cursor after writing data*/
#define write_inc 0x06

/*display off, cursor off and no blink*/
#define display_off 0x08

/*display on, cursor off and no blink*/
#define display_on 0x0c

/*display on, cursor on and no blink*/
#define cursor_on 0x0E

/*display on, cursor on and blink*/
#define blink_on 0x0F

/*8 bit interface and $ of lines on LCD */
#define function 0x38

/* really 0x00 but bit 6 is always a 1 */
#define cg_ram_base 0x40


/* really 0x00 but bit 7 is always a 1 */
#define dd_ram 0x80

/////////////////////////////////////////////
/*base address of each of the 4 lines */
#define lcd_line1 0x80 /* bit 7 is always set, i.e. $80 = $00*/
#define lcd_line2 0xC0 /* $C0 = $40 */
#define lcd_line3 0x94 /* $C0 = $14 */
#define lcd_line4 0xD4 /* $C0 = $54 */

/////////////////////////////////////////////
#define tree_text 0x00 /* ascii 00 */
#define degree_text 0x01 /* ascii 01 */
#endif
////////////////////////////////
const char line_1[] ="WRITING LOCATION: ";
const char line_2[] ="WRITE VALUE IS: ";
const char line_3[] ="READING LOCATION: ";
const char line_4[] ="READ VALUE IS: ";
/////////////////////////////////////////////
const char tree[8] ={0x04,0x0e,0x0e,0x1f,0x1f,0x04,0x04,0x04};
const char degree[8] ={0x1c,0x14,0x01c,0x00,0x00,0x00,0x00,0x00};
/////////////////////////////////////////////
//DMC 20481 CONNECTIONS//
#define LCD_RS PIN_E0
#define LCD_RW PIN_E1
#define LCD_E PIN_E2
#define DATA_PORT PORTD
////////////////////////////////////////////
/************DMC 20481 LCD connections****************

pin1 Vss
pin2 Vcc (5 volts)
pin3 Vee (connect through a 1K pot to ground to control contrast)
pin4 RS (strobe data, use 4.7K pullup)
pin5 RW (read/writeuse 4.7K pull-down)
pin6 E (enable datause 4.7K pullup)
pin7 D0
pin8 D1
pin9 D2
pin10 D3
pin11 D4
pin12 D5
pin13 D6
pin14 D7
pin15 A (LED ANODE - tie to Vcc)
pin16 K (LED CATHODE - connect through a 1K pot to
ground to control backlighting)
//////////////////////////////////////////////////////////////

/********************************************************/
/* FUNCTIONS LISTED BELOW */
/********************************************************/

void write_data(char text)
{
OUTPUT_HIGH(LCD_RS); /* RS pin set high for data */
delay_us(100); /* delay 100us*/
PORTD=text; /* Put data on 8 bit port*/
delay_us(100); /* delay 100us */
OUTPUT_LOW(LCD_E); /* E pin brought low*/
delay_us(100); /* delay 100us */
OUTPUT_HIGH(LCD_E); /* E pin brought high*/
delay_us(1); /* delay 1000us */
}
/********************************************************/

/********************************************************/
void write_command(char command)
{
OUTPUT_LOW(LCD_RS); /* RS pin set low for command*/
delay_us(100); /* delay 100us*/
PORTD=command; /* Put data on 8 bit port*/
delay_us(100); /* delay 100us*/
OUTPUT_LOW(LCD_E); /* E pin brought low*/
delay_us(1000); /* delay 100us*/
OUTPUT_HIGH(LCD_E); /* E pin brought high*/
Delay_us(100); /* delay 100us*/
}
/********************************************************/

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

/* write a line */
void scroll_line1()
{
char i=0;
char j=19;
char k=0;
while (j != 0){
write_command(lcd_line1 + j); /* set pointer on LCD to line 1*/
delay_ms(100);
k++;
while( i != k){
write_data(line_1[i++]);
}
i=0;
j--;
}
}

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

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

/* write a line */
void scroll_line2()
{
char i=0;
char j=19;
char k=0;
while (j != 0){
write_command(lcd_line2 + j); /* set pointer on LCD to line 1*/
delay_ms(100);
k++;
while( i != k){
write_data(line_2[i++]);
}
i=0;
j--;
}
}

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

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

/* write a line */
void write_line1()
{
char i=0;
/* set pointer on LCD to line 1*/
write_command(lcd_line1);

/* Now write the string to LCDs line 1 */
while (line_1[i]!=0x00)
{write_data(line_1[i++]);}
}
/*******************************************************/

/***********************************************************************/
void write_line2()
{
char i=0;
/* set pointer on LCD to line 1*/
write_command(lcd_line2);

/* Now write the string to LCDs line 1 */
while (line_2[i]!=0x00)
{write_data(line_2[i++]);}
}
/***********************************************************************/

/***********************************************************************/
void write_line3()
{
char i=0;
write_command(lcd_line3); /* set pointer on LCD to line 1*/
while (line_3[i]!=0x00) /* Now write the string to LCDs line 1 */
{write_data(line_3[i++]);}
}
/***********************************************************************/

/***********************************************************************/
void write_line4()
{
char i=0;
write_command(lcd_line4); /* set pointer on LCD to line 1*/
while (line_4[i]!=0x00) /* Now write the string to LCDs line 1 */
{write_data(line_4[i++]);}
}
/***********************************************************************/

/***********************************************************************/
/* write Christmas tree data into LCD memory at base of CG RAM location*/
void write_cgr_tree()
{
char i =0;
write_command(cg_ram_base); /* send command ($40) to set CGR RAM at 0x00 */
while (i<8) /* Now write the 8 data bytes to LCDs CGR address 0x00*/
{write_data(tree[i++]);}
}
/***********************************************************************/

/***********************************************************************/
/* write degree symbol data into LCD memory at base of CG RAM location*/
void write_cgr_degree()
{
char i =0;
write_command(cg_ram_base + 8); /* send command ($40) + offset to set CGR RAM at 0x01 */
while (i<8) /* Now write the 8 data bytes to LCDs CGR address 0x01*/
{write_data(degree[i++]);}
}
/***********************************************************************/

/***********************************************************************/
void init_lcd(void)
{
//SET UP THE PORTS I_O //
TRISA = 0x00;
PORTA = 0xFF;
TRISB = 0x00;
PORTB = 0xFF;

TRISD = 0x00;
PORTD = 0xFF;
TRISE = 0x00;
PORTE = 0x05; //MUST BE A "101" ON STARTUP

/* set up 4/8 bit interface and No. of lines */
delay_ms(150);
write_command(function);
delay_ms(150);

/* Clear display */
write_command(clear_display);
delay_ms(150);

/* Set cursor at line 1, column 0 */
write_command(cursor_home);
delay_ms(150);

/* Display on, cursor not on */
write_command(display_on);
delay_us(100);

/* increment address after data writes */
write_command(entry_mode);
delay_us(100);
}

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

void lcd_screen_bootup(void)
{
char i =0;
scroll_line1(); /* write to line 1 */
delay_ms(1000);
scroll_line2(); /* write to line 1 */
delay_ms(1000);

/* Blink Screen once a second */
while (i!=5)
{
write_command(display_off); /* turn off screen */
delay_ms(250);
write_command(display_on); /* turn screen back on */
delay_ms(250);
i++;
}

}

/***********************************************************************/
/* write a line */
void blink_lcd()
{
write_command(display_off); /* turn off screen */
delay_ms(200);
write_command(display_on); /* turn screen back on */
delay_ms(800);
}

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


</font>
___________________________
This message was ported from CCS's old forum
Original Post ID: 8494
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group