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

25LC256 and PIC4525

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



Joined: 07 Jun 2006
Posts: 47

View user's profile Send private message

25LC256 and PIC4525
PostPosted: Mon Sep 11, 2006 11:14 am     Reply with quote

EDIT: Thanks for catching that PCM_Programmer. I wish that was disabled by defalt hehe

This might be a bit off-topic, well unless it really is a programming
error Very Happy

I have the following code working with no problems on a 25LC640, 32K serial EEPROM. When I try communicating to a 25LC256 256K serial EEPROM the WEL bit never gets set. I have checked all of the voltages and have confirmed that the CS line is correct. The 25LC640 gets the correct WEL status bit set on the first try. After a few thousand tries the 25LC256 never sets the bit. The status register always reead zzero. So I know that code protect is not set. I have WP set high so all bytes should be writeable.

The only differences I see between these chips is that the pages size is 64 bytes on the 25LC256 vs 32 bytes on the 25LC640. Also the 25LC256 over all is faster in responses.

So I'm thinking that if it is working with the 25LC640 then there should be no problems with the 25LC256.

I have posted on the Microchip forums also but not getting any responses.

Does anyone have any experience with this chip or have any suggestions.

Thank you.


The PIN_C7 is the one where this chip is being selected.
Code:

void Poll_EE_WEL(int1 external)   //Wait for Write Enable Latch
{
   int16 tries;
   int8 st;
   do
   {
      if(!external)
         output_low(PIN_C2);   //Internal EEPROM CS
      else
         output_low(PIN_C7);   //Eternal EEPROM CS
      spi_write(RDSR);
      st = spi_read(0);
      output_high(PIN_C2);
      output_high(PIN_C7);

      //LCD_SetCursor(0,14,NORMAL);
      //printf(LCD_putc,"STATUS: %u,  %lu", st,tries++);

   } while((st & 0x02)==0);
}

void Poll_EE(int1 external)   //Wait for Write to finish
{
   int8 st;
   do
   {
      if(!external)
         output_low(PIN_C2);   //Internal EEPROM CS
      else
         output_low(PIN_C7);   //Eternal EEPROM CS
      spi_write(RDSR);
      st = spi_read(0);
      output_high(PIN_C2);
      output_high(PIN_C7);
   } while(st & 0x01);
}

void LoadStepFromEE(int8 program, int8 step, int1 external)
{
   int16 address;
   int8 lsb, msb, i;

   output_high(PIN_C2);
   output_high(PIN_C7);
   Poll_EE(external);
   address = (int16)program * MAX_STEPS * STEP_SIZE;
   address += (int16)(step - 1) * STEP_SIZE;
   lsb = address & 0xFF;
   msb = address >> 8;
   
   if(!external)
      output_low(PIN_C2);      //Internal EEPROM CS
   else
      output_low(PIN_C7);      //External EEPROM CS
   spi_write(READ_SPI);
   spi_write(msb);
   spi_write(lsb);
   
   for(i=0; i<24; i++)
      StepPtr[i] = spi_read(0);
   output_high(PIN_C2);
   output_high(PIN_C7);
   _stepModified = 0;
}
int1 SaveStepToEE(int8 program, int8 step, int1 external)
{
   int16 address;
   int8 lsb, msb, i;
   int1 fail;

   output_high(PIN_C2);
   output_high(PIN_C7);
   Poll_EE(external);   //Wait for WIP to clear
   address = (int16)program* MAX_STEPS * STEP_SIZE;
   address += (int16)(step-1) * STEP_SIZE;
   lsb = address & 0xFF;
   msb = address >> 8;
   
   if(!external)
      output_low(PIN_C2);
   else
      output_low(PIN_C7);
   spi_write(WREN);
   output_high(PIN_C2);
   output_high(PIN_C7);
   NOP
------->>>   Poll_EE_WEL(external);                                      //Hangs here

   if(!external)
      output_low(PIN_C2);
   else
      output_low(PIN_C7);
   spi_write(WRITE_SPI);
   spi_write(msb);
   spi_write(lsb);


   for(i=0; i<24; i++)
      spi_write(StepPtr[i]);
   output_high(PIN_C2);
   output_high(PIN_C7);

   //Verify the data was written if we are transferring to external memory
   if(external) {
      StepPtrSave = StepPtr;
      StepPtr = &StepVerify;
      LoadStepFromEE(program, step, external);   //Load the step just saved into the StepVerify structure;
      StepPtr = StepPtrSave;            //Restore the old pointer
   
      fail = FALSE;
      for(i=0; i<24; i++)
         if(StepPtr[i] != VerifyStepPtr[i])
            fail = TRUE;
         if(fail) {
            LCD_SetCursor(0,12,NORMAL);
            printf(LCD_putc, "TRANSFER FAILED       ");
            return FALSE;
         }
         else {
            _stepModified = 0;
         }
   }
   return TRUE;
}


Last edited by epideath on Mon Sep 11, 2006 12:08 pm; edited 1 time in total
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Sep 11, 2006 11:26 am     Reply with quote

Some of your code did not post correctly.

Please edit your post and delete the code. Then re-post it, except
this time select the checkbox below the posting that says:
Code:
  X   Disable HTML in this post
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Sep 11, 2006 11:50 pm     Reply with quote

Can you post a test program that calls these functions ?
Show the #include PIC statement, #fuses, #use delay(), etc.
Show the #define statements for all constants.
Show your setup_spi() statement.
Post everything necessary so that it can be pasted into an MPLAB
project and it will compile with no errors.

Also post your compiler version.
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