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 CCS Technical Support

24C256 help
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
ali6094



Joined: 31 Jan 2007
Posts: 18

View user's profile Send private message

24C256 help
PostPosted: Thu Mar 29, 2007 10:30 am     Reply with quote

i am using pic16F877A with 24c256

and has the following configuration

for 24c256 ic

PIN 1 to 4 ground
Pin 5 SDA to PIN_E2 of PIC
Pin 6 SCL to PIN_E0 of PIC
Pin 7 to ground
PIN 8 to +5V

No capacitors and resistors

used the following ammendment in 24C256

Code:


#ifndef EEPROM_SDA

#define EEPROM_SDA        PIN_E2
#define EEPROM_SDA_TRIS      TRISE2

#define EEPROM_SCL        PIN_E0
#define EEPROM_SCL_TRIS      TRISE0
#endif


only used the three routines in the main programme
i.e.
init_ext_eeprom()
write_ext_eeprom(a, d)
d = read_ext_eeprom(a)


where am i doing wrong ?
how can i check if my EEPROM is working fine?
Guest








PostPosted: Thu Mar 29, 2007 10:40 am     Reply with quote

you forgot the pull up resistors from SDA and SCL to VCC.... try 10k each
rwyoung



Joined: 12 Nov 2003
Posts: 563
Location: Lawrence, KS USA

View user's profile Send private message Send e-mail

Re: 24C256 help
PostPosted: Thu Mar 29, 2007 2:09 pm     Reply with quote

ali6094 wrote:
i am using pic16F877A with 24c256

and has the following configuration

for 24c256 ic

PIN 1 to 4 ground
Pin 5 SDA to PIN_E2 of PIC
Pin 6 SCL to PIN_E0 of PIC
Pin 7 to ground
PIN 8 to +5V

No capacitors and resistors


where am i doing wrong ?
how can i check if my EEPROM is working fine?


Pull up resistors are REQUIRED on the SDA and SCL pins. 2K to 10K is generally acceptable for a 5V system, depending on how fast you expect to run.

Also you really should have some bypass caps. 100nF and 10uF at the PIC and another 100nF at the eeprom. You might be able to use 10nF instead of 100nF depending on the quality of your supply.
_________________
Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month!
ali6094



Joined: 31 Jan 2007
Posts: 18

View user's profile Send private message

PostPosted: Fri Mar 30, 2007 11:01 am     Reply with quote

with pull u mean a resistor betwwen +5V and pin 5 and 6?

what u mean by capacitors at pic and eeprom, which PINS?.. mysupply is 5V pretty much fine and i am using capacitor with the regulator IC. which gives 5V
jecottrell



Joined: 16 Jan 2005
Posts: 559
Location: Tucson, AZ

View user's profile Send private message

PostPosted: Fri Mar 30, 2007 12:03 pm     Reply with quote

Yes.

You must have a ~4.7K resistor between SDA and 5.0V and

you must have a ~4.7K resistor between SCL and 5.0V.

(Without these I2C WILL NOT WORK.)

Also,

The EASIEST way to avoid problems is decouple the power supply at every chip. ALWAYS.... ALWAYS..... ALWAYS put a 0.1uF cap between 5.0V and ground as close to the power supply pin of every chip.

Good luck,

John
ali6094



Joined: 31 Jan 2007
Posts: 18

View user's profile Send private message

PostPosted: Sat Mar 31, 2007 7:26 am     Reply with quote

I did the resistors and the capacitor. Now I think that the read function is fine but I am only getting one constant line but it is not writing the data.

What to do next I don't know...
How can I clear the EEPROM and how can I test as if it is working fine?
Plz check my code if every thing is right as posted above.
jecottrell



Joined: 16 Jan 2005
Posts: 559
Location: Tucson, AZ

View user's profile Send private message

PostPosted: Sat Mar 31, 2007 8:01 am     Reply with quote

Quote:
i did the resistors and the capacitor


Should be capacitorS.... You need a 0.1uF at the EEPROM and at the PIC.

Post a short, but complete program that you have compiled and tested that suffers from the problems you describe. To test the EEPROM only about 20 lines of code should be necessary.

John
ali6094



Joined: 31 Jan 2007
Posts: 18

View user's profile Send private message

PostPosted: Sat Mar 31, 2007 8:17 am     Reply with quote

well i am using a graphic LCD and receiving input from a potentiometer and have to draw a graph on the LCD...

i used the internal EEPROM of PIC and every thing worked fine and i am getting fine

how ever i need more data to store...so i interfaced the 24c256... here is the code i am using

Code:

#include "PIC16F877A.h"
#fuses HS,NOWDT,NOPROTECT,NOLVP, NOPUT, NOBROWNOUT
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)

#include "t6963.c"
#include "24256.c"


unsigned int depth = 0;
unsigned int ie_value = 0;
unsigned int ie_value_old = 0;
unsigned int adc_value = 0;
unsigned int adc_value_old = 0;
unsigned int int_counter = 0;
unsigned int depth_counter = 0;
int1 data_end = 0;
float temp;
unsigned int i;

#int_timer1
isr_timer1()
{
   set_timer1( 0x88a5 );
   if( !TRIGGER && !data_end )
   {
      if( int_counter > 31 )
      {
         int_counter = 0;
         adc_value = read_adc();
      
         write_ext_eeprom( depth_counter, adc_value );//<-- if i use only write_eeprom(depth, counter it is working fine)
         depth_counter++;
         if( depth_counter > 254 ) { data_end = 1; }
      }
      else { int_counter++; }
      adc_value_old = adc_value;
   }
}

void main( void )
{
   set_tris_a( 0xff );
   set_tris_c( 0xbf );
   set_tris_e( 0xff );

   GDispInit();
   init_ext_eeprom();//<-- this i dont need to use in case of PIC`s eeprom
   FontSize = 8;
   GDispSetMode( XOR_MODE );
   GDispSetMode( GRAPHIC_ON );
     GDispClrGrh();

   setup_adc_ports( AN0 );
   setup_adc( ADC_CLOCK_INTERNAL );
   set_adc_channel( 0 );

   setup_timer_1( T1_INTERNAL );
   enable_interrupts( INT_TIMER1 );
   enable_interrupts( GLOBAL );

   while( 1 )
   {
      if( !TRIGGER && !data_end )
      {
         if( depth < depth_counter )
         {
            ie_value = read_ext_eeprom( depth ) / 1.3;//<-- for PIC`s eeprom i used read_eeprom
      
      
      }
   }
}


this code is working for internal eeprom bur not external i.e. 24C256 and the pins i defined in 24256.c as described earlier


Last edited by ali6094 on Sun Apr 01, 2007 12:31 pm; edited 1 time in total
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Mar 31, 2007 12:40 pm     Reply with quote

Quote:
#ifndef EEPROM_SDA

#define EEPROM_SDA PIN_E2
#define EEPROM_SDA_TRIS TRISE2

#define EEPROM_SCL PIN_E0
#define EEPROM_SCL_TRIS TRISE0
#endif

this code is working for internal eeprom bur not external i.e. 24C256 and
the pins i defined in 24256.c as described earlier

Where does this 24256.c driver come from ? You have #define
statements for the TRIS. Those statements are not in any CCS eeprom
driver that I know of. I know they're not in vs. 3.249. I installed vs.
4.030 and did a text search on all drivers, and they're not in there either.
I did a web search for "EEPROM_SDA_TRIS" and got no hits.

Conclusion: You have either written your own driver or have modified
the CCS driver.

You should use the CCS driver. It's in this folder:
c:\Program Files\Picc\Drivers\24256.c
Guest








PostPosted: Sat Mar 31, 2007 1:14 pm     Reply with quote

yes before the file was like this
Code:
#ifndef EEPROM_SDA

#define EEPROM_SDA PIN_E2

#define EEPROM_SCL PIN_E0
 
#endif

i modified it to like this
#ifndef EEPROM_SDA

#define EEPROM_SDA PIN_E2
#define EEPROM_SDA_TRIS TRISE2

#define EEPROM_SCL PIN_E0
#define EEPROM_SCL_TRIS TRISE0
#endif
so i can revert back with pinEO and E2 like

#ifndef EEPROM_SDA

#define EEPROM_SDA PIN_E2

#define EEPROM_SCL PIN_E0

#endif

But still no results ...
i think the read function is working as it is giving a constant out put but write function is not working...[/code]
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Mar 31, 2007 1:42 pm     Reply with quote

My advice is to make a simple test program that only tests the ability
to write and read from the 24256 eeprom.

Try the test program shown below. Use the CCS driver. Don't use
your driver.

It should display this on your terminal window:
Quote:
Start
55 aa


If it doesn't work, it means there is probably something wrong with
your hardware. For example, you may have forgotten to connect
pull-up resistors on the SDA and SCL lines.
Code:

#include <16F877A.H>
#fuses HS, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

#define EEPROM_SDA  PIN_E2
#define EEPROM_SCL  PIN_E0

#include <24256.c>

//=====================================
void main()
{
printf("Start\n\r");

init_ext_eeprom();

write_ext_eeprom(0, 0x55);
write_ext_eeprom(1, 0xAA);

printf("%x  ", read_ext_eeprom(0));
printf("%x", read_ext_eeprom(1));

while(1);
}
Guest








PostPosted: Sat Mar 31, 2007 2:24 pm     Reply with quote

the out pput i am receiving with this programme is

" Start
00 00"

this means we are not reading right and we dont know if we are writing ok or not....


Also i used one 4.7 K both at SCA and SCL lines .. used a 10 uf capacitor at pin8 of 24c256 ...with pic i am already using the capacitors...i dont know what is the problem ...
i checked resistance at different points but every thing seems to be fine....
ali6094



Joined: 31 Jan 2007
Posts: 18

View user's profile Send private message

PostPosted: Sat Mar 31, 2007 2:49 pm     Reply with quote

i think i am reading fine
but unable to write data on 24C256..
so what to do next...
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Mar 31, 2007 3:13 pm     Reply with quote

What is your compiler version ?
ali6094



Joined: 31 Jan 2007
Posts: 18

View user's profile Send private message

PostPosted: Sat Mar 31, 2007 3:35 pm     Reply with quote

its 3.224
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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