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

Problem with 24lc08

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








Problem with 24lc08
PostPosted: Wed May 13, 2009 8:15 am     Reply with quote

There is next code:
Code:

#include <16F688.h>
#fuses xt,NOWDT,NOPROTECT,NOMCLR     
#include <stdio.h> 
#use delay(clock=4096000)
#use RS232(baud=9600,xmit=PIN_C4,rcv=PIN_C5)                                                   
#include <\driver\2408.c>
#zero_ram
//###########################################################################                                                     
int8 litera;                                       
int16 lenght;                                                                                                           
//###########################################################################                                                                                         
#int_rda                                         
void Interrupt_RS232(void)                                   
{                                                                     
int8 value;                                                         
int16 addr;                                       
//*************************                                       
   value=getc();                     
   if(value!='\n'){                                   
      write_ext_eeprom(addr,value); 
      addr++;
   }                                                                       
   else{                                                                                                  
      lenght=addr;                                   
      addr=0;                                   
   }                         
                                                         
}                                                         
//###########################################################################                                                                                       
void main()                                                                                                           
{   
//*************************                     
enable_interrupts(int_rda);   
enable_interrupts(GLOBAL);                                   
//*************************                                         
  init_ext_eeprom();   
                                            
  while(true)       
   { 
   .......     
    my code
    .......       
   }                                                             
                                                                 
}                                                                                                                     

Hyper Terminal sends abcdefghij string.
I can store to 24lc08 only first 4 byte - abcd.
What's wrong?
Help me, please.

Use
CCS 4.084,
Proteus
ECACE



Joined: 24 Jul 2006
Posts: 94

View user's profile Send private message

PostPosted: Wed May 13, 2009 11:23 am     Reply with quote

Can we see the code you use for reading it back?

Also, do you mead that HT sends a series of chars, not a string?
_________________
A HW Engineer 'trying' to do SW !!! Run!!!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed May 13, 2009 12:22 pm     Reply with quote

It takes 5 ms per byte to write to the eeprom. At 9600 baud, you can
receive one character in about 1 ms. You will miss incoming characters
if you write each one inside the #int_rda routine. (Apparently Proteus
doesn't simulate this behavior exactly. It appears to use a shorter time
than 5 ms for the eeprom write).

Wait until you get the complete message from the PC. Use the Ex_Sisr.c
example file to setup a circular buffer. In your main(), create a loop to
check if characters are in the buffer by calling bkhbit(). If chars are
available, get them by calling bgetc(). Put them in another array.
When you get the '\n' character, then you know you have received the
complete message. Now you can write the array to eeprom.
(If it's a very large message, you could use Page Mode for the eeprom
to decrease the writing time). But hopefully, you will not receive another
message while you are writing to eeprom. If so, all or part of it will be
lost.

Also, add the ERRORS parameter to the #use rs232() statement. If you
do miss characters due to them coming in while an eeprom write is in
progress, the ERRORS parameter will prevent the UART from locking up.
Guest








PostPosted: Thu May 14, 2009 2:14 am     Reply with quote

Thank you.
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