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

Code to store tables in code memory

 
Post new topic   Reply to topic    CCS Forum Index -> Code Library
View previous topic :: View next topic  
Author Message
future



Joined: 14 May 2004
Posts: 330

View user's profile Send private message

Code to store tables in code memory
PostPosted: Sat Sep 25, 2004 8:20 pm     Reply with quote

I have this code that works fine with the internal eeprom, but I am limited to 256bytes. Once called it will store the entire struct into eeprom.

I am looking for a way to store this data (a struct) in flash memory.

Thank you.

Code:
#int_eeprom
void eeprom_isr(void) {
    //;==============================;//
    /*;  wr - write eeprom complete  ;*/
    //;==============================;//
        if(eecnt<sizeof(cfg)) {
            eeadr=eecnt;
            eedata=*(&cfg+eecnt);
            bit_clear(eecon1,eepgd);  // point to data memory
            bit_set(eecon1,wren);     // enable writes
            eecon2=0x55;              // write 55h
            eecon2=0xAA;              // write AAh
            bit_set(eecon1,wr);       // set wr to begin write
                eecnt++;              // increment index pointer
            } else {
               eecnt=0;
               disable_interrupts(int_eeprom);
        }
}
pirev



Joined: 19 Mar 2005
Posts: 13
Location: Bulgaria

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

PostPosted: Fri Jun 24, 2005 5:48 pm     Reply with quote

Code:


// For PIC16F8xx

#bit _C=STATUS.0
#bit GIE=INTCON.7

#bit RD=EECON1.0
#bit WR=EECON1.1
#bit WREN=EECON1.2
#bit EEPGD=EECON1.7

#define _NOP() #asm nop #endasm

void WrPrgMem( int16 dst, int16 data )   {
   // Load destination address
   EEADR = (char)dst;
   EEADRH = 0x1F & ( dst >> 8 );
   // Load data to be programmed
   EEDATA = (char)data;
   EEDATH = data>>8;
   EEPGD = 1;      // Point to program memory location
   WREN = 1;      // Enable write to program memory
   if( GIE )
      _C = 1;
   GIE = 0;      // Disable interrupt
   EECON2 = 0x55; EECON2 = 0xAA;
   WR = 1;         // Start write operation
   _NOP(); _NOP();
   if( _C )
      GIE = 1;   // Enable interrupt
   while( WR );
   WREN = 0;
}

long RdPrgMem( long src )   {
   EEADR = (char)src;
   EEADRH = 0x1F & ( src >> 8 );
   EEPGD = 1;      // Point to program memory location
   RD = 1;
   _NOP(); _NOP();
   return (((long)EEDATH)<<8)|EEDATA;
}
}
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> Code Library 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