View previous topic :: View next topic |
Author |
Message |
brianj
Joined: 06 Oct 2003 Posts: 6 Location: Liverpool, UK
|
Bug in write_program_memory? |
Posted: Mon Oct 06, 2003 2:06 pm |
|
|
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
|
|
Posted: Mon Oct 06, 2003 5:46 pm |
|
|
If you think this is a compiler error you should report to CCS |
|
|
brianj
Joined: 06 Oct 2003 Posts: 6 Location: Liverpool, UK
|
|
Posted: Tue Oct 07, 2003 6:38 am |
|
|
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
|
Bug in write_program_memory? Is it still in CCS 3.206 |
Posted: Mon Jul 19, 2004 7:45 am |
|
|
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 |
|
|
|