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

Bug in write_program_memory?

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



Joined: 06 Oct 2003
Posts: 6
Location: Liverpool, UK

View user's profile Send private message

Bug in write_program_memory?
PostPosted: Mon Oct 06, 2003 2:06 pm     Reply with quote

I'm evaluating the CCS C compiler at the moment (v3.177d) with a 16F877. I had a problem using write_program_memory where it seemed to be taking too much time and causing some data corruption.

On looking at the assembler output, it seems that the carry bit is not cleared before the supplied byte count is rotated right to give the word count. It's a matter of chance whether the routine writes the correct number of locations or 128 extra ones.

Maybe this evaluation version of the compiler is older and this bug has been corrected, but I've seen a few mentions of problems with this routine here and wondered if this may be the cause.

A work around is to put

#asm
bcf 3,0
#endasm

before every use of the function.

Brian
Haplo



Joined: 06 Sep 2003
Posts: 659
Location: Sydney, Australia

View user's profile Send private message

PostPosted: Mon Oct 06, 2003 5:46 pm     Reply with quote

If you think this is a compiler error you should report to CCS Smile
brianj



Joined: 06 Oct 2003
Posts: 6
Location: Liverpool, UK

View user's profile Send private message

PostPosted: Tue Oct 07, 2003 6:38 am     Reply with quote

Will do - I just wanted to see if this was already known. How current is version 3.177d of the compiler?

Brian
Schmobol



Joined: 01 Mar 2004
Posts: 22
Location: Nice, France

View user's profile Send private message

Bug in write_program_memory? Is it still in CCS 3.206
PostPosted: Mon Jul 19, 2004 7:45 am     Reply with quote

Hi,

I've just read a message of a bug, present last year on CCS 3.177, that has similar symptoms as the one I'm experiencing whatever version up to the last one 3.206.

In fact, when using the write_program_memory() function with a 18F452 target, some extra locations get erased to FF.

the reported bug by brianj was "it seems that the carry bit is not cleared before the supplied byte count is rotated right to give the word count."

The definition of my Flash write routine (based on the byte factory boorloader)
Code:

void kind_write_program_eeprom (int32 address, int16 data)
{   
   int16   current_data;
   int16   ee_block[32];   
   int32   ee_block_address;      
   int   ee_block_index;         

   current_data = read_program_eeprom (address);   
   if (current_data != data) {                  
                                       
      ee_block_address = address & 0xFFFFFFC0;
      ee_block_index = (int)((address &  0x0000003F)>>1);
                                          
      read_program_memory (ee_block_address, ee_block, 64);   
      ee_block[ee_block_index] = data;
      write_program_memory (ee_block_address, ee_block, 64);
   }
}


And the processor get completly stuck (because of flash alteration) when I call
Code:

kind_write_program_eeprom(label_address(FLAG_CALIBRATION),0xFFFF);


For info
Code:

const int16 FLAG_CALIBRATION=0x55;


Any idea would be welcomed, I can't find a way to get out of this situation
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