View previous topic :: View next topic |
Author |
Message |
Nick Guest
|
what could cause a write_program_memory to fail? |
Posted: Sun Jun 26, 2005 3:28 am |
|
|
I am using loader.c and the write_program_memory function will work in the ex_load.c , but that specific function fails in my software. using a 16f876a
i working on adding a bootloader and i have traced the failure to that function, it will lock up
here are my debug statements
Code: |
if (line_type == 0) {
printf("storing data\n\r");
// Loops through all of the data and stores it in data
// The last 2 bytes are the check sum, hence buffidx-3
for (i = 9,dataidx=0; i < buffidx-3; i += 2)
data[dataidx++]=atoi_b16(&buffer[i]);
#if getenv("FLASH_ERASE_SIZE")>2
#if defined(__PCM__)
if ((addr!=next_addr)&&(addr&(getenv("FLASH_ERASE_SIZE")-1)!=0))
#else
if ((addr!=next_addr)&&(addr&(getenv("FLASH_ERASE_SIZE")/2-1)!=0))
#endif
erase_program_eeprom(addr);
next_addr = addr + 1;
#endif
printf("before write\n\r");
printf("addr = %ld , count = %u \n\r",addr,count);
write_program_memory(addr, data, count);
printf("after write\n\r");
}
else if (line_type == 4)
h_addr = make16(atoi_b16(&buffer[9]), atoi_b16(&buffer[11]));
}
|
here is my output
Code: |
storing data
before write
addr = 0 , count = 16
(lock up)
|
it works in the example, but doesnt when loader.c is use in my software... very confusing.
Anyone have any ideas?
Nick |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1634 Location: Perth, Australia
|
|
Posted: Sun Jun 26, 2005 6:32 am |
|
|
Have you specifically told the compiler you are using the 'A' version of the chip? The A and Non-A versions use different algotithms for writing to program memory.
You are overwriting the reset and interrupt vectors. Was that your intention? _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!! |
|
|
Nick Guest
|
|
Posted: Sun Jun 26, 2005 12:07 pm |
|
|
I tried 16f876a.h and 16f876.h and both of them lock up in the same place as i explain above, in the example given by ccs only 16f876.h works.. which is very odd since i have an A chip.
Any help would be greatly apperciated.
Nick |
|
|
Nick Guest
|
|
Posted: Sun Jun 26, 2005 12:24 pm |
|
|
looks like the problem has to do with interrupts. I guess disabled_interrupt takes a few cycles to complete?
Nick |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1634 Location: Perth, Australia
|
|
Posted: Sun Jun 26, 2005 6:40 pm |
|
|
Nick wrote: | looks like the problem has to do with interrupts. I guess disabled_interrupt takes a few cycles to complete?
Nick |
No disable interrupts is a singe cycle instruction. _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!! |
|
|
|