Vincent helped me debug the output log of hardfault handler recently. Thank you.
1 void Delay_UART5(uint16_t cnt)2 {3 for(;cnt;cnt--);4 }
1 //void HardFault_Handler(void) //uart5 38400 2 //{ 3 // 4 // uint32_t addrbegin=__get_MSP() ; //???·?· 5 uint32_t addr; 6 // uint8_t i, j, str; 7 // uint16_t loopcnt=0; 8 // 9 //// USART3->CR1 &=~ (1<<7);10 //// GPIOB->CRH &= 0xFFFF00FF; //uart 3,PB10,PB1111 //// GPIOB->CRH |= 0x00004100;12 //// GPIOB->BSRR |= (0x0001<<10);13 //14 // UART5->CR1 &=~ (1<<7);15 // GPIOC->CRH &= 0xFFF0FFFF; //uart 5,PC12TX,PD2RX16 // GPIOC->CRH |= 0x10000;17 // GPIOC->BSRR |= (0x0001<<12);18 //19 // while(1)20 // {21 // Delay_UART5(7969);22 // loopcnt++;23 // GPIOC->BSRR |= (0x0001<<12);24 // 25 // if(loopcnt > 3000)26 // {27 // 28 // addr= addrbegin+0x30;29 // loopcnt=0;30 // for(i=0; i<255; i++)31 // {32 // 33 // str= (*(uint8_t*) addr--);34 //35 // if(i>250)36 // str = ‘\r‘;37 // 38 // // Delay_UART5(1076*4); //960039 // // Delay_UART5(1076); //3840040 // // Delay_UART5(818);41 // Delay_UART5(1000);42 //43 // GPIOC->BRR |= (0x0001<<12);44 // // Delay_UART5(1076); //usart end45 // // Delay_UART5(269);46 // // Delay_UART5(205);47 // Delay_UART5(260);48 //49 // for(j=0; j<8; j++)50 // {51 // if((str&(0x01<<j)))52 // GPIOC->BSRR |= (0x0001<<12);53 // else54 // GPIOC->BRR |= (0x0001<<12);55 // // Delay_UART5(1076); //usart end56 // // Delay_UART5(269);57 // // Delay_UART5(205);58 // Delay_UART5(260);59 // }60 // GPIOC->BSRR |= (0x0001<<12);61 // // Delay_UART5(1076*2); //usart end62 // // Delay_UART5(538);63 // // Delay_UART5(410);64 // ;Delay_UART5(500);65 // }66 // }67 // }68 //}
There are two problems: 1. the latency function needs to be adjusted, and the latency must be 26us.
2. The SP address has changed when the sp value is removed.