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

Weird problem using external memory driver

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







Weird problem using external memory driver
PostPosted: Sun Mar 29, 2009 5:22 am     Reply with quote

hi,
I came across this problem and I hope that someone would help me to understand it.

Here is the problematic code:
Code:
#define PIC188F88722_EXT_MEM_START 0x20000L 
typedef struct
{
  uint32   start_addr;
  uint32   end_addr;
  uint8     num_block;
} my_test_ext_mem_stype;

my_test_ext_mem_stype my_test_ext_mem;

// This function is having problem
void test_mem_function (void)
{
  uint16  temp_read, temp_write, index;

  my_test_ext_mem.start_addr = PIC188F88722_EXT_MEM_START ;

  for (index = 0; index < 1000; index++)
  {
    temp_write = index + 33;
    write_external_memory(my_test_ext_mem.start_addr ,&temp_write,2);
    read_external_memory(my_test_ext_mem.start_addr ,&temp_read,2);
   
    if (temp_write != temp_read)
    {
      temp_read = temp_write;  <<<----- It will hit here alot
    }
  }
}


Also the same function, If I modify it like this, my test memory will be passed.
Code:

void test_mem_function (void)
{
  uint16  temp_read, temp_write, index;
  uint32  start_address;
  start_address = PIC188F88722_EXT_MEM_START ;

  for (index = 0; index < 1000; index++)
  {
    temp_write = index + 33;
    write_external_memory(start_address ,&temp_write,2);
    read_external_memory(start_address  ,&temp_read,2);
   
    if (temp_write != temp_read)
    {
      temp_read = temp_write;  <<<----- won't hit here.
    }
  }
}


or like this, still work
Code:
void test_mem_function (void)
{
  uint16  temp_read, temp_write, index;
 
  for (index = 0; index < 1000; index++)
  {
    temp_write = index + 33;
    write_external_memory(PIC188F88722_EXT_MEM_START ,&temp_write,2);
    read_external_memory(PIC188F88722_EXT_MEM_START ,&temp_read,2);
   
    if (temp_write != temp_read)
    {
      temp_read = temp_write;  <<<----- won't hit here.
    }
  }
}


or even this also works
Code:
void test_mem_function (void)
{
  uint16  temp_read, temp_write, index;

  my_test_ext_mem.start_addr = (PIC188F88722_EXT_MEM_START - 2) ;

  for (index = 0; index < 1000; index++)
  {
    temp_write = index + 33;
    write_external_memory(my_test_ext_mem.start_addr + 2 ,&temp_write,2);
    read_external_memory(my_test_ext_mem.start_addr + 2,&temp_read,2);
   
    if (temp_write != temp_read)
    {
      temp_read = temp_write;  <<<----- won't hit here. Good to go
    }
  }
}

Please help me to explain this kind of weird behavior.
Thank you
JimNewbie
Guest







PostPosted: Sun Mar 29, 2009 5:31 am     Reply with quote

btw, I was using CCS 4.087 and I just update the new version 4.090. Both have the same problem.

It is PIC 18F8722.
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