We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi all I have to add an In-Application Programming feature to my program. I'm using 89c51rc2 with no external memory and keil. I've read several threads about IAP but not found exactly the thing itself. At the moment, I - I have a 'boot' program, which looks if there is a new program on the high part of the flash (previously written there by the application or normal program), by means of an absolute addressable variable. If there is a new program, boot copies the program at the low part of the flash. - After that, it is supposed that boot must jump to the application program. But I guess I'm getting in trouble with interrupt vectors or some other conflict. I'd appreciate an example or a link. Thanks in advance
I'm using 89c51rc2 with no external memory and keil. that is insufficient info. the 89c51rc2 is made by several (at least 2) manufactureres and the IAP is different for all of them
Ok thanks for the reply. I'm using the 89c51rc2 by Atmel. To write to the code memory I use the APIs provided by Atmel. I think I'm done with the part of writting the new program that comes from the uart, but don't know how to handle interrupts or conflict between 'bootloader' and application program. Also don't know if I'm doing the jumps properly I'll try to resume what my project is expected to do: I think that a good memory map is the following: From 0x0000 to 0x01F3 --> 'bootloader' From 0x01F4 to 0x3FFF --> application program From 0x4000 to 0x41F3 --> Not used From 0x41F4 to 0x7FFF --> just the place to put the incoming program. 1- Assumming normal operation. The micro receives a new program to update himself via UART and writes it to an unused part of the flash, ie from 0x3FFF 2- When the new program has been copied, the program set an absolute addressable variable to 1 (kind of flag to know if there is new program available). 3- Jumps to bootloader (LJMP 0000H) Don't know if it works. 4- Then bootloader looks for the flag. If there is new program, then writes it to the low part of the code memory (from 0x01F4, after the bootloader) 5- When this is accomplished, bootloader makes a jump to the new application program (0x01F4). Thanks again.
what about power failure at ANY time during the above the interrupt vectors Erik
Well, I think that a power failure does not affect the process, because in that case, the program will start with the bootloader. The flag that indicates the existence of a new program is not set to 0 until the copying process form high to low part is done. So ... if there is a new program, start again the copying process else the program in low part is not corrupt and jump to it.
The flag that indicates the existence of a new program is not set to 0 until the copying process form high to low part is done. BUT what will you di with a power failure during interrupt vector redirection? Erik
mmm a power failure during interrupt vector redirection... the application program will miss the interrupt. It is not critical. There are only interrupts. The program would start again. But my problem at this point is -I think- how to redirect interrupts or the philosophy of my iap system itself or how to avoid any conflict between the bootloader and the application. Do i need a third program?? call it interrupt handler?? how would I write it in C. Thanks
just as a start why do you want IAP, why not ISP. No effort from you will be required. Erik
Well, the system must be remotely reprogrammed through its UART. I mean, no access but the serial interface. The micro that must be reprogrammed receives its new program with frames coming through this serial interface. ISP programming will be made only the first time, to load both bootloader and application.
why not use the "Atmel equivalent" someone made of my NoTouch for Philips P89C51Rx2 - OR switch to the Philips chip and use NoTouch. NoTouch requires just a few lines of code and makes ISP activation possible through any means such as Serial input of a code, keyboard key or whatever. No switches, no "voltage levels" just fire it up. I use Serial string activation, all my customer has to do, in order to update, is to run a .bat file. If you HAVE to use Atmel, search at 8052.com, the "Atmel equivalent" was posted there a while ago, for Philips it is all at the FlashMagic forum. Erik
no access but the serial interface. Reread your post, NoTouch does just that Erik
First, thanks for your interest Erik. Well I think what I'm doing is not exactly notouch, since the micro that must be reprogrammed must be reprogrammed by another micro, not from a PC.
Well I think what I'm doing is not exactly notouch, since the micro that must be reprogrammed must be reprogrammed by another micro, not from a PC. evidently you did not read NoTouch at http://www.esacademy.com it is VERY CLEAR from the document that it will work beautifully when "the micro that must be reprogrammed must be reprogrammed by another micro, not from a PC" Ok, if you have trouble finding it, here it is: http://www.8052.com/users/erikm/notouch.doc Of course, you will need to emulate FlashMagic in your micro that is to program the micro, but that is still less work and you gain that the micro you program is "pure" Erik
quoting the NoTouch document: This method may, of course, be used even if the program is not updated through a PC running a program such as FlashMagic, the data stream may be issued by any means as long as it conforms to the record format specifications in the data sheet.
I'll take a deeper look at it. Thanks a lot.