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

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
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
ali6094



Joined: 31 Jan 2007
Posts: 18

View user's profile Send private message

PostPosted: Sat Mar 31, 2007 4:48 pm     Reply with quote

Well thanx GOD i have changed the EEPROM and now it is working fine may be it burnt out .... thanx for all the help U guys it was really getting pain in [spam]

with regards
Ali Very Happy
santicomp
Guest







24256.c
PostPosted: Fri Oct 02, 2009 5:30 pm     Reply with quote

Hello I am simulating a 256 eeprom in proteus and the problem is when I include the driver 24256.c in my program it gives me me 23 error in the drivers.
Here is the driver and the error. I am using version 4.088.
Code:

c:\program files\picc\drivers\24256.c

and this is the error it is generating

’““‘ Error 100 "C:'¤Archivos de programa'··.P||ZC'•·.dri··rers'•·.2425B.e" Line 31 [5,49]: USE parameter value is out of range Not a number: P|N_B1
’““‘ Error 12 "C:'¤Archivos de programa'··.P||ZC'•·.dri··rers'•·.2425B.e" Line 3B[27,2B]: Undefined identifier P|N_BlZl
’““‘ Error 12 "C:'¤Archivos de programa'··.P||ZC'•·.dri··rers'•·.2425B.e" Line 39[27,2B]: Undefined identifier P|N_B1
’““‘ Error 12 "C:'¤Archivos de programa'··.P||ZC'•·.dri··rers'•·.2425B.e" Line 47[13,14]: Undefined identifier -- i2c_start
’““‘ Error 12 "C:'¤Archivos de programa'··.P||ZC'•·.dri··rers'•·.2425B.e" Line 4B[13,14]: Undefined identifier -- i2c_write
’““‘ Error 12 "C:'¤Archivos de programa'··.P||ZC'•·.dri··rers'•·.2425B.e" Line 49[13,14]: Undefined identifier -- i2c_write
’““‘ Error 12 "C:'¤Archivos de programa'··.P||ZC'•·.dri··rers'•·.2425B.e" Line 5|ZI[13,14]: Undefined identifier -- i2c_write
’““‘ Error 12 "C:'¤Archivos de programa'··.P||ZC'•·.dri··rers'•·.2425B.e" Line 51[13,14]: Undefined identifier -- i2c_write
’““‘ Error 12 "C:'¤Archivos de programa'··.P||ZC'•·.dri··rers'•·.2425B.e" Line 52[12,13]: Undefined identifier -- i2c_stop
’““‘ Error 12 "C:'¤Archivos de programa'··.P||ZC'•·.dri··rers'•·.2425B.e" Line 53[13,14]: Undefined identifier -- i2c_start
’““‘ Error 12 "C:'¤Archivos de programa'··.P||ZC'•·.dri··rers'•·.2425B.e" Line 54[2|Z|,21]: Undefined identifier -- i2c_write
’““‘ Error 12 "C:'¤Archivos de programa'··.P||ZC'•·.dri··rers'•·.2425B.e" Line 57[13,14]: Undefined identifier -- i2c_start
’““‘ Error 12 "C:'¤Archivos de programa'··.P||ZC'•·.dri··rers'•·.2425B.e" Line 5B[2|Z|,21]: Undefined identifier -- i2c_write
’““‘ Error 12 "C:'¤Archivos de programa'··.P||ZC'•·.dri··rers'•·.2425B.e" Line B|Zl[12,13]: Undefined identifier -- i2c_stop
’““‘ Error 12 "C:'¤Archivos de ro rama'··.P||ZC'•·.dri··rers'•·.2425B.e" Line BB 13,14 : Undefined identifier -- i2c start
Err»i»r1Q"[ "~.¤i:r»iiw.~‘¤i¤i de »r»i»»1rama"~F`\[ [ "~:drr‘~:~‘eri"~.Q4Q5E» ri" Lime ETH Ei 14] LimjeT¤r’¤e¤j rrjerwfier -- Qi write
’““‘ Error 12 "C:'¤Archivos de programa'··.P||ZC'•·.dri··rers'•·.2425B.e" Line BB[13,14]: Undefined identifier -- i2c_write
’““‘ Error 12 "C:'¤Archivos de programa'··.P||ZC'•·.dri··rers'•·.2425B.e" Line B9[13,14]: Undefined identifier -- i2c_write
’““‘ Error 12 "C:'¤Archivos de programa'··.P||ZC'•·.dri··rers'•·.2425B.e" Line 7|Zl[13,14]: Undefined identifier -- i2c_start
’““‘ Error 12 "C:'¤Archivos de programa'··.P||ZC'•·.dri··rers'•·.2425B.e" Line 71[13,14]: Undefined identifier -- i2c_write
’““‘ Error 12 "C:'¤Archivos de programa'··.P||ZC'•·.dri··rers'•·.2425B.e" Line 72[17,1B]: Undefined identifier -- i2c_read
’““‘ Error 12 "C:'¤Archivos de programa'··.P||ZC'•·.dri··rers'•·.2425B.e" Line 73[12,13]: Undefined identifier -- i2c_stop
’““‘ Error 1 2 "|cd.c" Line 1 B[1 U,1 1 ]: Undefined identifier -- i2c_start
23 Errors, U Warnings.

thanks

++++++++++++++++++
Code replaced by directory.
Reason: Forum rule #10
10. Don't post the CCS example code or drivers.
-- Forum Moderator
++++++++++++++++++
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Oct 03, 2009 2:33 pm     Reply with quote

Post a short, complete, compilable program that uses the 24256.c driver.
santicomp
Guest







error 24256
PostPosted: Sat Oct 03, 2009 4:13 pm     Reply with quote

hi this is the program i am using to test the driver

Code:
#include <16F690.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT
#use delay(clock = 4000000)
#use i2c(MASTER, scl=PIN_C3, sda=PIN_C4, SLOW=100000, FORCE_HW)

#include "flex_lcd.c"
#include "24256.c"
//==========================

void main()
{
int16 adc_value;
int8 d=f;
long a=ff;
float volts;
float pres;
lcd_init();
init_ext_eeprom();

setup_adc_ports(sAN0);
setup_adc(ADC_CLOCK_DIV_8);
set_adc_channel(0);
delay_us(20);

while(1)
  {
   adc_value = read_adc();
   delay_us(30);
   volts = (float)(adc_value /51.00);   
   printf(lcd_putc, "\fVolts= %3.2f", volts);
   lcd_gotoxy(1,2);
   pres=volts * 40;
   d = read_ext_eeprom(a);
   printf(lcd_putc, "Presion: %f",pres);
   write_ext_eeprom(a, d);
   delay_ms(500);
  }
}


and this the general driver the error is produced in the driver i dont know why

Code:

c:\program files\picc\drivers\24256.c


++++++++++++++++++
Code replaced by directory.
Reason: Forum rule #10
10. Don't post the CCS example code or drivers.
-- Forum Moderator
++++++++++++++++++
santicomp
Guest







error 24256
PostPosted: Sat Oct 03, 2009 5:40 pm     Reply with quote

i fixed the drive by adding

Code:
#use i2c(Master,Fast,sda=PIN_C0,scl=PIN_C1,force_hw)

but i still get an error 12 about the Define
Code:
#define EPROM_SDA PIN_B1
#define EPROM_SCL PIN_B0

is there another way to define pins what is it a bug thanks
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Oct 03, 2009 5:41 pm     Reply with quote

Quote:
#include <16F690.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT
#use delay(clock = 4000000)
#use i2c(MASTER, scl=PIN_C3, sda=PIN_C4, SLOW=100000, FORCE_HW)

The 24256.c driver already has a #use i2c statement in it. You don't
need to add another one, as shown above. Delete that line.


Quote:

#ifndef EEPROM_SDA

#define EEPROM_SDA PIN_B1
#define EEPROM_SCL PIN_B0

#endif

The 16F690 doesn't have pins B0 and B1. You can't use the default
pin settings in the 24256.c file, as shown above. You need to choose
some different pins.


Quote:

#include "flex_lcd.c"
#define EEPROM_SDA PIN_C1
#define EEPROM_SCL PIN_C0
#include "24256.c"

Look at the 16F690 pin diagram in the data sheet and choose some
other pins. Then enter them as two #define statements placed above
the #include line for the 24256.c driver, as shown above. In the
example above, I have set it to use pins C0 and C1.


Look at this diagram on page 8 in the data sheet in the Acrobat reader.
Quote:
PIC16F690 Pin Diagram (PDIP, SOIC, SSOP)

16F690 data sheet:
http://ww1.microchip.com/downloads/en/DeviceDoc/41262E.pdf
santicomp
Guest







eeprom error
PostPosted: Sat Oct 03, 2009 9:50 pm     Reply with quote

Thanks. Finally made it work. I forgot about the pins on the 16f690. It works perfect. I also used the 24lc512.c and it works perfect too. I am going to do a type of truth table for a project with relays. Thanks alot for your help.
santicomp
Guest







error 24256
PostPosted: Sun Oct 04, 2009 3:44 pm     Reply with quote

In ccs it does not give me error the code but in Proteus this code does not work. It give me a message "Attempt to read unimplemented memory location 0x091 ignored". Is it a bug maybe in Proteus or is my code wrong?
I am using the pullup in Proteus and define the ports correctly. It gives me error when it does i2c_start(); in the 24256.c driver. Thanks.
Code:

#include <16F690.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT
#use delay(clock = 4000000)

#include "flex_lcd.c"
//#use I2C(master, sda=PIN_A2, scl=PIN_A0);

#define EEPROM_SDA PIN_B4
#define EEPROM_SCL PIN_B6

#include "24512.c"
//#include "24256.c"
//==========================

void main()
{
int16 adc_value;
int16 d=0;
//float volts;
//float pres;
//float read;

lcd_init();
 set_tris_b(0b00000000);
 
init_ext_eeprom();

setup_adc_ports(sAN0);
setup_adc(ADC_CLOCK_DIV_8);
set_adc_channel(0);
delay_us(20);

//while(1)
//  {
   adc_value = read_adc();
   delay_us(30);
   write_ext_eeprom(0x0000, 0x30);
   delay_us(30);
   d=read_ext_eeprom(0x0000);
   printf(lcd_putc, "\Leido: %X",d);
   //printf(lcd_putc, "Presion: %f",pres);
   
   
//  }
}


24512.c
Code:

c:\program files\picc\drivers\24512.c


++++++++++++++++++
Code replaced by directory.
Reason: Forum rule #10
10. Don't post the CCS example code or drivers.
-- Forum Moderator
++++++++++++++++++
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Oct 04, 2009 4:20 pm     Reply with quote

Quote:

#use i2c(Master,Fast,sda=EEPROM_SDA,scl=EEPROM_SCL,force_hw)

I think the compiler has a bug in i2c hardware mode. Don't use FORCE_HW.
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