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

24lc32a Ext EEPROM

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



Joined: 25 Mar 2007
Posts: 6
Location: South, Korea

View user's profile Send private message Visit poster's website

24lc32a Ext EEPROM
PostPosted: Tue Apr 03, 2007 10:33 am     Reply with quote

Hello .
I am learnning '24LC32A' that is external EEPROM.
However, something is wrong!
Used 2432.c driver and taking 10k ohm Pull-up both SDL, SCA pin.
Please show me relation sample.
Thanks many.


Compailer Version : 4.023
DEVICE : PIC16F877A

code
///header file

#include <16F877A.h>
#device adc=8

#FUSES NOWDT //No Watch Dog Timer
#FUSES XT //Crystal osc <= 4mhz
#FUSES PUT //Power Up Timer
#FUSES NOPROTECT //Code not protected from reading
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD //No EE protection
#FUSES NOWRT //Program memory not write protected

#use delay(clock=4000000)


///source code
#include "bb.h"
#include <LCD.C>
#include <2432.c>

void port_init(){
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_psp(PSP_DISABLED);
setup_spi(FALSE);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);

set_tris_d(0x0f);
}

void write_eeprom_data(long int address, char *string){
while(*string){
write_ext_eeprom(address,*string);
string++;
address++;
}
}

char *read_data="0123456789ABCDEF";
void read_eeprom_data(long int address, char len){
char i=0;

while(len){
read_data[i]=read_ext_eeprom(address);
i++;
len--;
}
read_data[i]=0;
}

void lcd_puts(char *ptr){
char len=0;

while(*ptr){
lcd_putc(*ptr++);
len++;
if(len>15) lcd_gotoxy(1,2);
}
}

void main(){
long int address=0x00;
char *ee_char="Hello World!";

port_init();
lcd_init();
init_ext_eeprom();

lcd_gotoxy(1,1);
lcd_puts(read_data);

while(TRUE){
write_eeprom_data(address,ee_char);
lcd_gotoxy(1,2);
read_eeprom_data(address,16);
lcd_puts(read_data);
}
}
_________________
Yeongmo Yang


Last edited by yym05 on Tue Apr 03, 2007 8:16 pm; edited 5 times in total
jecottrell



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

View user's profile Send private message

PostPosted: Tue Apr 03, 2007 11:13 am     Reply with quote

Yeongmo,

What are A0-A2 connected to on the EEPROM?

They are the address pins. I think if you are using the example code they should be connected to Vss (gnd).

John
yym05



Joined: 25 Mar 2007
Posts: 6
Location: South, Korea

View user's profile Send private message Visit poster's website

It’s already connected.
PostPosted: Tue Apr 03, 2007 5:40 pm     Reply with quote


It’s already connected.
John. Thanks.
but... As you can see the image, it was connected.
_________________
Yeongmo Yang


Last edited by yym05 on Tue Apr 03, 2007 7:43 pm; edited 1 time in total
jecottrell



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

View user's profile Send private message

PostPosted: Tue Apr 03, 2007 5:47 pm     Reply with quote

OK.

Post your code and someone should be able to offer some suggestions.

John
yym05



Joined: 25 Mar 2007
Posts: 6
Location: South, Korea

View user's profile Send private message Visit poster's website

CODE
PostPosted: Tue Apr 03, 2007 6:16 pm     Reply with quote

OK
_________________
Yeongmo Yang


Last edited by yym05 on Tue Apr 03, 2007 7:32 pm; edited 2 times in total
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Apr 03, 2007 6:34 pm     Reply with quote

1. Post the PIC that you're using.

2. Post your compiler version.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Apr 03, 2007 9:00 pm     Reply with quote

The problem is in vs. 4.023 of the compiler.

In vs. 4.021, they changed the operation of the compiler, as follows:
Quote:
4.021 The & unary operator by default no longer returns a generic (int8 *)

But they didn't change all the example and driver files to reflect this
change.

Here is the hi() function from the 2432.c file:
Quote:
#define hi(x) (*(&x+1))

With the new operation of the compiler, this statement will not fetch
the high byte of a 16-bit number.


To fix the problem, you need to modify the hi() macro to this:
Code:
#define hi(x)  (*((int8 *)&x+1))

This casts the address pointer to be a byte pointer. That's what you need.
yym05



Joined: 25 Mar 2007
Posts: 6
Location: South, Korea

View user's profile Send private message Visit poster's website

Is activated.
PostPosted: Wed Apr 04, 2007 12:30 am     Reply with quote

Smile Thanks many.
_________________
Yeongmo Yang
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