At the bootloader, LPC1788 communicates with the bluetooth (HC05) module through UART1. After jumping to the code in the RAM, the UART1 would not work and nothing will be ready on its interrupts. My jumping code is as follows:
nand_readPartition(0, byte_wr_ptr, 29996); __disable_irq(); UART_TxCmd(UART_1, DISABLE); NVIC_DisableIRQ(UART1_IRQn); UART_DeInit(UART_1); SysTick_Config(0); //NVIC_DeInit(); //NVIC_SCBDeInit(); NVIC_SetVTOR(USER_PROGRAM_START); boot_jump(USER_PROGRAM_START);
everything is correct, i uses CAN and its interrupts. the interrupts for CAN is works fun. it means the vector interrupts remap correctly.
Best Regards, Mostafa
1. You seem to disable the interrupt before you jump. Enough to disable interrupts. 2. I'd place "NVIC_SetVTOR(USER_PROGRAM_START);" in the bootloaders itself. 3. Does you bootloader re-enable the UARTS? 4. Show bootloader entry code...
Do you re-enable the interrupts? Do you transfer control from an interrupt context?
Thank you for your really fast reply. My entry point for both of the code (bootloader and code in the RAM) is the same:
void SystemInit (void) { #if (FLASH_SETUP == 1) /* Flash Accelerator Setup */ LPC_SC->FLASHCFG = FLASHCFG_Val|0x03A; #endif #if (CLOCK_SETUP) /* Clock Setup */ LPC_SC->SCS = SCS_Val; if (SCS_Val & (1 << 5)) { /* If Main Oscillator is enabled */ while ((LPC_SC->SCS & (1<<6)) == 0);/* Wait for Oscillator to be ready */ } LPC_SC->CLKSRCSEL = CLKSRCSEL_Val; /* Select Clock Source for sysclk/PLL0*/ #if (PLL0_SETUP) LPC_SC->PLL0CFG = PLL0CFG_Val; LPC_SC->PLL0CON = 0x01; /* PLL0 Enable */ LPC_SC->PLL0FEED = 0xAA; LPC_SC->PLL0FEED = 0x55; while (!(LPC_SC->PLL0STAT & (1<<10)));/* Wait for PLOCK0 */ #endif #if (PLL1_SETUP) LPC_SC->PLL1CFG = PLL1CFG_Val; LPC_SC->PLL1CON = 0x01; /* PLL1 Enable */ LPC_SC->PLL1FEED = 0xAA; LPC_SC->PLL1FEED = 0x55; while (!(LPC_SC->PLL1STAT & (1<<10)));/* Wait for PLOCK1 */ #endif LPC_SC->CCLKSEL = CCLKSEL_Val; /* Setup Clock Divider */ LPC_SC->USBCLKSEL = USBCLKSEL_Val; /* Setup USB Clock Divider */ LPC_SC->EMCCLKSEL = EMCCLKSEL_Val; /* EMC Clock Selection */ LPC_SC->PCLKSEL = PCLKSEL_Val; /* Peripheral Clock Selection */ LPC_SC->PCONP = PCONP_Val; /* Power Control for Peripherals */ LPC_SC->CLKOUTCFG = CLKOUTCFG_Val; /* Clock Output Configuration */ #endif LPC_SC->PBOOST |= 0x03; /* Power Boost control */ #ifdef __RAM_MODE__ SCB->VTOR = 0x10000000 & 0x3FFFFF80; #else SCB->VTOR = 0x00000000 & 0x3FFFFF80; #endif Activate_ProtocolPin(PROTOCOL_KWP_RELAY, OFF_MODE); Activate_ProtocolPin(PROTOCOL_TYPE1_RELAY, OFF_MODE); Activate_ProtocolPin(PROTOCOL_CAN_RELAY, OFF_MODE); Activate_OBDPin(1, OFF_MODE); Activate_OBDPin(2, OFF_MODE); Activate_OBDPin(3, OFF_MODE); Activate_OBDPin(6, OFF_MODE); Activate_OBDPin(7, OFF_MODE); Activate_OBDPin(8, OFF_MODE); Activate_OBDPin(9, OFF_MODE); Activate_OBDPin(10, OFF_MODE); Activate_OBDPin(11, OFF_MODE); Activate_OBDPin(12, OFF_MODE); Activate_OBDPin(13, OFF_MODE); Activate_OBDPin(14, OFF_MODE); Activate_OBDPin(15, OFF_MODE); Activate_LEDPin(LED_FAULT,OFF_MODE); Activate_LEDPin(LED_BUZZER,OFF_MODE); Activate_LEDPin(LED_CONNECT,OFF_MODE); sdram_init(); }
the code in the RAM is running correctly when i dependently program the ARM. But when i jump from bootloader, it seems all thing is correct, for example, CAN receive interrupt is working. But i do not use the CAN recieve interrupt in the bootloader!!!
1-Yes i re-enable the interrupts at the begining . because the CAN interrupts works fine.
2- how should i transfer the interrupt context ? you mean VTOR? Yes, i know that it works fine because CAN interrupts works fine.
2 - No, I mean what state is the processor and NVIC in when you hand control from the loader to the app. ie inside an IRQHandler
Finally i can find the status of NVIC!!! in the NVIC veiewer:
Idx source name E P A Priority 22 UART1 1 1 1 9
It seems, it is in the interrupt routine!!! i think i jump in UART ISR :D:D:D. Am i Right?
Hard for me to know, it isn't my code and the fragment you provided gives little in the way of context. If you call from the USART IRQHandler then the processor isn't going to unstack properly and the NVIC still thinks you are in the handler, and will only service things that preempt that.