I have Buzzer En connected to GPIO2_IO10 when En is high buzzer play, when EN is low buzzer is OFF. When my code stuck in while(1) inside reset vector - (
in startup file then buzzer keep on playing , why and how to resolve this issue since even my bootloader code not yet start to execute.
void ResetISR(void)
{
/* Disable interrupts*/
__asm volatile ("cpsid i");
__asm volatile ("MSR MSP, %0" : : "r" (&_vStackTop) : );
#if defined (__USE_CMSIS)
/* If __USE_CMSIS defined, then call CMSIS SystemInit code*/
SystemInit();
#else
// Disable Watchdog
volatile unsigned int *WDOG1_WCR = (unsigned int *) 0x400B8000;
*WDOG1_WCR = *WDOG1_WCR & ~(1 << 2);
volatile unsigned int *WDOG2_WCR = (unsigned int *) 0x400D0000;
*WDOG2_WCR = *WDOG2_WCR & ~(1 << 2);
// Write watchdog update key to unlock
*((volatile unsigned int *)0x400BC004) = 0xD928C520;
// Set timeout value
*((volatile unsigned int *)0x400BC008) = 0xFFFF;
// Now disable watchdog via control register
volatile unsigned int *RTWDOG_CS = (unsigned int *) 0x400BC000;
*RTWDOG_CS = (*RTWDOG_CS & ~(1 << 7)) | (1 << 5);
#endif // (__USE_CMSIS)
/* Enable UIB power rails early */
StatusType status = UIB_PowerEnable_Startup();
if (status != Success)
{
// ToDo - Need to discuss what to do here
}
//Cpu Test Code
if(Post_Pass != run_cpu_post())
{
while(1);
}
//Ram Test Code
if(Post_Pass != run_ram_post())
{
while(1);
}
/* Copy the data sections from flash to SRAM.*/
unsigned int LoadAddr, ExeAddr, SectionLen;
unsigned int *SectionTableAddr;
/* Load base address of Global Section Table*/
SectionTableAddr = &__data_section_table;
/* Copy the data sections from flash to SRAM.*/
while (SectionTableAddr < &__data_section_table_end) {
LoadAddr = *SectionTableAddr++;
ExeAddr = *SectionTableAddr++;
SectionLen = *SectionTableAddr++;
data_init(LoadAddr, ExeAddr, SectionLen);
}
/* At this point, SectionTableAddr = &__bss_section_table;
* Zero fill the bss segment*/
while (SectionTableAddr < &__bss_section_table_end) {
ExeAddr = *SectionTableAddr++;
SectionLen = *SectionTableAddr++;
bss_init(ExeAddr, SectionLen);
}
#if !defined (__USE_CMSIS)
// Assume that if __USE_CMSIS defined, then CMSIS SystemInit code
// will setup the VTOR register
// Check to see if we are running the code from a non-zero
// address (eg RAM, external flash), in which case we need
// to modify the VTOR register to tell the CPU that the
// vector table is located at a non-0x0 address.
unsigned int * pSCB_VTOR = (unsigned int *) 0xE000ED08;
if ((unsigned int *)g_pfnVectors!=(unsigned int *) 0x00000000) {
*pSCB_VTOR = (unsigned int)g_pfnVectors;
}
#endif // (__USE_CMSIS)
#if defined (__cplusplus)
//
// Call C++ library initialisation
//
__libc_init_array();
#endif
/* Reenable interrupts*/
__asm volatile ("cpsie i");
#if defined (__REDLIB__)
/* Call the Redlib library, which in turn calls main()*/
__main();
#else
main();
#endif
/*
* main() shouldn't return, but if it does, we'll just enter an infinite loop
*/
while (1) {
;
}
}