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

what could cause a write_program_memory to fail?

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







what could cause a write_program_memory to fail?
PostPosted: Sun Jun 26, 2005 3:28 am     Reply with quote

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

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Sun Jun 26, 2005 6:32 am     Reply with quote

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







PostPosted: Sun Jun 26, 2005 12:07 pm     Reply with quote

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







PostPosted: Sun Jun 26, 2005 12:24 pm     Reply with quote

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

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Sun Jun 26, 2005 6:40 pm     Reply with quote

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!!
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