2014-06-04 10:05 PM
hi, all
I'm working on a IAP function with stm32f103cb. Partition(IROM1 configuration): part base size bootloader:0x8000000 0xF800 user app: 0x800F800 0x10000 implementation: bootloader: receive user app image from uart and write to P2, jump to P2 when finishing.#define APPLICATION_ADDRESS (0x80000000+0xF800)
uint8_t jump_flag = 0;
int main(void)
{
RCC_Configuration();
NVIC_Configuration();
GPIO_Configuration();
USART2_Configuration();
if(jump_flag)
{
if (((*(__IO uint32_t*)APPLICATION_ADDRESS) & 0x2FFE0000 ) == 0x20000000)
{
/* Jump to user application */
JumpAddress = *(__IO uint32_t*) (APPLICATION_ADDRESS + 4);
Jump_To_Application = (pFunction) JumpAddress;
/* Initialize user application's Stack Pointer */
__set_MSP(*(__IO uint32_t*) APPLICATION_ADDRESS);
uprint(''Jump_To_Application!'');
delay_ms(1);
Jump_To_Application();
}
}
user app: LED binking
void NVIC_Configuration(void)
{
NVIC_InitTypeDef NVIC_InitStructure;
EXTI_InitTypeDef EXTI_InitStructure;
// NVIC_SetVectorTable(NVIC_VectTab_FLASH,APPLICATION_ADDRESS);
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0);
NVIC_InitStructure.NVIC_IRQChannel = EXTI0_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
GPIO_EXTILineConfig(GPIO_PortSourceGPIOB, GPIO_PinSource0);
EXTI_InitStructure.EXTI_Line = EXTI_Line0;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
}
int main(void)
{
RCC_Configuration();
//
NVIC_Configuration();
NVIC_SetVectorTable(NVIC_VectTab_FLASH,0xF800);
GPIO_Configuration();
USART2_Configuration();
uprintf(''LED blinking!'');
while(1)
{
delay_ms(1000);
GPIOC->ODR ^= GPIO_Pin_13;
}
}
issue:
the user app runs well if
NVIC_Configuration() orEXTI_Init(&EXTI_InitStructure); is commented.
but when uncommented it doesn't work. It's hard to debug this part. I'm confused if I missed anything. Any thoughts? Many thanks. #stm32-iap-exti2014-06-05 02:18 AM
Hi
''the user app runs well ifNVIC_Configuration() or EXTI_Init(&EXTI_InitStructure); is commented.
but when uncommented it doesn't work. It's hard to debug this part. I'm confused if I missed anything. Any thoughts?'' Yes, when you run the NVIC_config - you are enabling the interrupt for the EXTI. So, at run time you are probably getting an EXTI interrupt. If you comment out the code for the EXIT ISR but still enable the EXTI IRQ - you will get a hardfault. Make sure that whatever is connected to the EXTI line is disconnected during IAP OR make sure your IAP code handles the EXTI IRQ properly.2014-06-08 11:34 PM
hi,chen_chung
great help. appreciated.you are right. it was in the exti isr.my mistake for the gpio configuration make it triggered all the time.