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,
I need help. I'm using the IAP, secondary bootloader. I'm having a problem erasing sectors. When I try to erase a sector, it hangs at function "iap_entry(command, result)" in erase function.
It passes through Prepare function successfully.
The code:
#define IAP_LOCATION 0x7FFFFFF1 #define IAP_CLK 48000000 #define AP_ADDR 0x10000// where the user app located typedef void (*FP)(void);/* run the user application from pre-specified address*/ #define iap_entry(a, b) ((void (*)())(IAP_LOCATION))(a, b) unsigned long command[5]; unsigned long result[3];
The ERASE FUNCTION:
unsigned long IAP_EraseSec (unsigned long StartSecNum, unsigned long EndSecNum) { if (EndSecNum < StartSecNum) return IAP_STA_INVALD_PARAM; command[0] = IAP_CMD_EraseSec; command[1] = StartSecNum; command[2] = EndSecNum; command[3] = IAP_CLK / 1000; _printf("\r\n*******ERASE3************"); iap_entry(command, result); _printf("\r\n*******ERASE4************"); return result[0]; }
The PREPARE FUNCTION:(that one works ok)
unsigned long IAP_PrepareSec (unsigned long StartSecNum, unsigned long EndSecNum) { if (EndSecNum < StartSecNum) return IAP_STA_INVALD_PARAM; command[0] = IAP_CMD_EraseSec; command[1] = StartSecNum; command[2] = EndSecNum; command[3] = IAP_CLK / 1000; _printf("\r\n*******ERASE3************"); iap_entry(command, result); _printf("\r\n*******ERASE4************"); return result[0]; }
Can anyone help me?
thanks
Additional to my previous comment.
The user application was trying to use systen setting of the bootloader and that was affecting his usage of UAR and others. Was solved reseting systems settings to correct values.
Thanks for you answer Christian. But I think then my problem isn't this..
The problem is a little before run the user code. Is in Erase function of IAP.
For me maybe is some problem in IRAM config, or in the delaration of iap_entry.. I don't know.. I'm running out of options..
If someone have already worked with IAP and works ok, please tell me the compiler options used. And the If someone have already worked with IAP and works ok, please tell me the compiler options used.
By the way.. I'm using uVision 4.
Thanks
Is in Erase function of IAP.
many have been bitten by their watchdog when erasing.
Erik
Hey! I've found my stupid error. The line that should clear all interrupts was in the wrong place. So another interrupt was set before ERASE function be called.
Thank you all for the help!
Congratulations.
I should have cut/pasted some more source code lines in my previous post - complete with interrupts and watchdog-kick.