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

Please check my eeprom read program

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



Joined: 11 Feb 2005
Posts: 24

View user's profile Send private message

Please check my eeprom read program
PostPosted: Wed Oct 05, 2005 9:50 am     Reply with quote

Hello,
I have some proble with reading eeprom (24C04). Please check my codes as follow and make suggestion.
Code:

#include <16F877.h>
#fuses XT,NOWDT,NOPROTECT,NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)  // Jumpers: 8 to 11, 7 to 12

#include <2404.c>
#define size  255

void main() {
     int buf,i;
     long int add;

     init_ext_eeprom();
     add=0;
     i=0;

   delay_ms(250); delay_ms(250); delay_ms(250); delay_ms(250);
 while(1) {
    for(add=0; add<size; add++) {
        buf=read_ext_eeprom(add);   
        printf("\r\nReading from EEPROM... Address= %ld  Value= %x",add,buf);
        output_b(buf);
        Delay_ms(100);
    }
  }
}


The above code is not working. Any idea? But the below code is working and I really do not know why? Question Please check it out. The only difference is using "Delay_S(1);" function and four "delay_ms(250);" built-in function. Compiler is 3.227.

Code:

#include <16F877.h>
#fuses XT,NOWDT,NOPROTECT,NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)  // Jumpers: 8 to 11, 7 to 12

#include <2404.c>
#define size  255
void Delay_S(int delay) {
 int i1;
 for(i1=0; i1<delay; i1++){ delay_ms(250); delay_ms(250); delay_ms(250); delay_ms(250);}
}

void main() {
     int buf,i;
     long int add;

     init_ext_eeprom();
     add=0x00;
     i=0x00;


     Delay_S(1);

 while(1) {
        add=0x00;
    while(add<size) {
        buf=read_ext_eeprom(add);   // the memory and show it on leds,it shoaled be the same like the address
        printf("\r\nReading from EEPROM... Address= %ld  Value= %x",add,buf);
        output_b(buf);
        Delay_ms(100);
        add++;

   }

  }
}


Thanks,
Ako
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Oct 05, 2005 2:15 pm     Reply with quote

There's no reason for a delay to be required, normally.
My guess is that you have a very slow rise time on your power supply.
I assume your Vdd voltage is +5 volts.
Try adding the two fuse settings shown in bold, below:

#fuses XT,NOWDT,NOPROTECT, BROWNOUT, PUT, NOLVP

Those settings will make the startup be more reliable if the
problem is due to a slowly rising Vdd.
akokyaw



Joined: 11 Feb 2005
Posts: 24

View user's profile Send private message

eeprom read program
PostPosted: Wed Oct 05, 2005 6:36 pm     Reply with quote

Hi PCM Programmer,
Thank for reply. My circuit operation is to read the eeprom after power up, so I put a delay for settling time. But the problem is why the circuit is working with use of "Delay_S(1);" function instead of using four "delay_ms(250)" built-in function. This may be bug but I am not sure. Question
Anyway, it will be the best without delay, so I will try to change the fuse setting and post the result.

Thank a lot,
Ako
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