Discussion in "Embedded GSM Development" started by    kirangowle    Nov 20, 2010.
Fri Jul 15 2011, 08:47 pm
#91
@ kirangowle
at24c04 has 8 bit address
whereas at24c256 has 16 bit address so that it is not working
Sat Jul 16 2011, 02:48 am
#92
@majoka, what's with that 16bit? no chance to interface to 8bit controller?

how about if we send 8bit then next is another 8bit to have a 16bit?
Sat Jul 16 2011, 08:10 am
#93
Thanks mojaka,

I changed the code like this now working.
unsigned char EEPROM_read(unsigned int addr)
{
	unsigned char dat;	

	I2C_start();            /* Start i2c bus */

	I2C_write(EEPROMS_ID);   /* Connect to EEPROM */
	I2C_write(addr&0xF0);	 /* Request RAM address (Hight byte) */
	I2C_write(addr&0x0F);	 /* Request RAM address (Low byte) */
	
	I2C_start();			/* Start i2c bus */

	I2C_write(EEPROMS_ID+1);/* Connect to EEPROM for Read */
	dat = I2C_read();		/* Receive data */

	I2C_noack();
	
	I2C_stop();				/* Stop i2c bus */

   return dat;			
}

void EEPROM_write(unsigned int addr, unsigned char val)
{
	I2C_start(); 

	I2C_write(EEPROMS_ID);   /* Connect to EEPROM */
	I2C_write(addr&0xF0);	 /* Request RAM address (Hight byte) */
	I2C_write(addr&0x0F);	 /* Request RAM address (Low byte) */

	I2C_write(val);			/* Write sec on RAM specified address */

	I2C_stop();           	/* Stop i2c bus */
}

@romel your concept i have applied here.


[ Edited Sat Jul 16 2011, 08:10 am ]
Sat Jul 16 2011, 10:54 am
#94
Is this IC having Paging concept.In below code i ll write 'A' at 63 loc and 'B' at 64th loc, then ill write 'F' at 128 loc so on.But when i read the 0th loc i am getting the data as 'F', 'G'.. But actually i should get unknown data at 0th loc.

EEPROM_write(0x003f,'A');	// 63 addr
LCD_delay(1);
EEPROM_write(0x0040,'B');	//64 addr
LCD_delay(1);
EEPROM_write(0x0041,'C');	//65addr
LCD_delay(1);
EEPROM_write(0x0042,'D');	//67 addr
LCD_delay(1);
EEPROM_write(0x007F,'E');	//127 addr
LCD_delay(1);
EEPROM_write(0x0080,'F');	// 128
LCD_delay(1);
EEPROM_write(0x0081,'G');	// 129
LCD_delay(1);
EEPROM_set(0x0082,'H');	//130
LCD_delay(1);
EEPROM_write(0x0083,'I');	
LCD_delay(1);

 LCD_command(0x80);
 l=0;
while(l<=0x0096)// 150bytes read
{
LCD_putc(EEPROM_get(l));
l++;
LCD_delay(2);
}
Mon Jul 18 2011, 08:36 pm
#95
Page concept is there with almost all eeproms and it comes to picture only when you're doing a page write sequence. if you writing one byte on one location and one on other.. there is no problem.
Tue Jul 19 2011, 07:29 am
#96
@Ajay, If i give continues strings to byte_write its writing(i have tested for 80 chars) If i do random write i.e . one at 25th loc and other at 68th loc like this its getting overwritten.Why is it soo.
Actually i want to store the incoming msgs into it, and retrieve back according to it.The msg data(msg, date/time, mob no.) would be around say 30-35 chars.
Shall i allocate 1 page for each msg or shall i keep a counter(starting and ending addr of each msg data).
I need suggestion from you people.
Fri Jul 22 2011, 10:27 pm
#97
I did not really understand what you mean by "its getting overwritten" if you give proper sub address, byte will not go to any wrong place. you must check your program. you might be doing something wrong there.

Its better to fix a chunk you want to read or write. e.g. you have a message of 30 chars but your buffer is 50char. so read or write 50 bytes so that it becomes easy to track how many messages you have written in eeprom. and it also maintains the consistency of your memory management logic. on safer side you can write first byte as length of message and then your buffer.
Wed Jan 16 2013, 07:33 pm
#98
Im working on a gsm based project. im using AT89C52. below is the detail of circuit
hyperterminal sends command to gsm modem(say AT+CMGR=1)
gsm modem generates a response(a long message)
I have written the following code to extract only the message part from this long code. after the extracted message i write it back to hyperterminal
here is my code
CODE:
#include<regx52.h>
unsigned char str,abc,j;
unsigned char msg1[100];

void init_serial() // Initialize serial port
{
abc=0;
TMOD=0x20; // Mode=2
TH1=0xfd; // 9600 baud
SCON=0x50; // Serial mode=1 ,8-Bit data,1 Stop bit ,1 Start bit , Receiving on
TR1=1; // Start timer
}

void transmit_data(unsigned char str) // Function to transmit data through serial port
{
SBUF=str; // Store data in sbuf
while(TI==0); // Wait till data transmit
TI=0;
}

void receive_data() interrupt 4 // Function to recieve data serialy from RS232 into microcontroller
{
msg1[abc]=SBUF; // Read sbuf
abc++; // increase buffer
RI=0;
}

void read_text(unsigned char msg[])
{
j=59 // i am manually moving the location to the starting char of recd msg.
while (msg[j]!= '\r')
{
transmit_data(msg[j]); // Transmit to HyperTerminal
j++;
}
}
}


void main()
{
init_serial(); // Initialize serial port
IE=0x90; //enable serial interrupt
read_text(msg1); //after msg1 is full, to extract the message function
while(1);
}

THE PROBLEM WITH ABOVE CODE IS KEIL IS GENERATING AN ERROR SAYING 'SYNTAX ERROR NEAR 'WHILE'
SOMEONE PLS HELP
Wed Jan 16 2013, 07:52 pm
#99
In void read_text() you have closed 3 braces remove one from it build will go through..
As logic is not proper it still wont work.

Try to identify where it would go wrong. Do step by step analysis.
Thu Jan 17 2013, 05:48 pm
the problem is one extra bracket

void read_text(unsigned char msg[])
{
j=59 // i am manually moving the location to the starting char of recd msg.
while (msg[j]!= '\r')
{
transmit_data(msg[j]); // Transmit to HyperTerminal
j++;
}
}
}



it should be like this

void read_text(unsigned char msg[])
{
j=59 // i am manually moving the location to the starting char of recd msg.
while (msg[j]!= '\r')
{
transmit_data(msg[j]); // Transmit to HyperTerminal
j++;
}
}

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

Bobbyerilar
Thu Mar 28 2024, 08:08 am
pb58
Thu Mar 28 2024, 05:54 am
Clarazkafup
Thu Mar 28 2024, 02:24 am
Walterkic
Thu Mar 28 2024, 01:19 am
Davidusawn
Wed Mar 27 2024, 08:30 pm
Richardsop
Tue Mar 26 2024, 10:33 pm
Stevencog
Tue Mar 26 2024, 04:26 pm
Bernardwarge
Tue Mar 26 2024, 11:15 am