-
bootload中断异常 sos
[i=s] 本帖最后由 tyw 于 2021-8-7 16:34 编辑 [/i] 下面是跳转程序 [color=#000000][backcolor=white] [font=Consolas, "]void IAP_Load_APP(uint32_t appxaddr) { RCC->APB1RST = 0xFFFFFFFF; RCC->APB2RST = 0xFFFFFFFF; RCC->APB1RST = 0x00000000; RCC->APB2RST = 0x00000000; if (((*(uint32_t *)appxaddr) & 0x2FFF8000) == 0x20000000) //检查栈顶地址是否合法. { jump2app = (iapfun) * (vu32 *)(appxaddr + 4); //用户代码区第二个字为程序开始地址(复位地址) __set_MSP(*(vu32 *)appxaddr); //初始化APP堆栈指针(用户代码区的第一个字用于存放栈顶地址) //MSR_MSP(*(vu32*)appxaddr); //SCB->VTOR = appxaddr; jump2app(); //跳转到APP. } } [/font] [font=Consolas, "]下面是APP串口中断测试函数void USART1_IRQHandler(void) { //AT32_LEDn_ON(LED2); intrupt_NUM++; if (USART_GetITStatus(USART1, USART_INT_RDNE) != RESET) { /* Read one byte from the receive data register */ //RxBuffer1[1] = USART_ReceiveData(USART1);//需要读取数据清除空闲标志位,否则会循环中断 USART_ClearFlag(USART1, USART_FLAG_RDNE); // AT32_LEDn_Toggle(LED2); RxBuffer1[USART_INT_RDNE_NUM] = USART_ReceiveData(USART1); USART_INT_RDNE_NUM++; if (USART_INT_RDNE_NUM > 98) USART_INT_RDNE_NUM = 98; } if (USART_GetITStatus(USART1, USART_INT_IDLEF) != RESET) { /* Read one byte from the receive data register */ // RxBuffer1[2] = USART1 -> STS; RxBuffer1[USART_INT_RDNE_NUM - 1] = USART_ReceiveData(USART1); //需要读取数据用于清除空闲标志位,否则会死机 USART_INT_RDNE_NUM = 0; USART_INT_IDLEF_NUM++; USART1_END = 0; } //printf(" %d %d %d", intrupt_NUM, USART_INT_RDNE_NUM, USART_INT_IDLEF_NUM); if (USART_GetITStatus(USART1, USART_INT_TRAC) != RESET) { USART_INT_TRAC_NUM++; } } int main(void) { AT32_Board_Init(); MX_USART1_UART_Init(); printf("Tset OTA APP !!!! \n\r"); extern uint8_t USART1_END, intrupt_NUM, USART_INT_RDNE_NUM, USART_INT_IDLEF_NUM, USART_INT_TRAC_NUM; extern uint8_t RxBuffer1[100]; while (1) { if (USART1_END == 0) { printf("RxBuffer1:%s", RxBuffer1); USART1_END = 1; if (strstr((char *)RxBuffer1, "LED_ON")) { AT32_LEDn_ON(LED2); } if (strstr((char *)RxBuffer1, "LED_OFF")) { AT32_LEDn_OFF(LED2); } memset(RxBuffer1, 0, sizeof(RxBuffer1)); } AT32_LEDn_Toggle(LED3); Delay_ms(100); } } 说明一下 APP函数单独下载到MCU中是可以运行的通过OTA后就出现不正常的情况OTA后的日志[16:19:17.371]收←◆Go to updata ^_^Tset OTA APP !!!! [16:19:19.462]发→◇LED_ON□[16:19:19.474]收←◆RxBuffer1:[16:19:20.727]发→◇LED_ON□[16:19:20.775]收←◆RxBuffer1:[16:19:21.721]发→◇LED_ON□[16:19:21.776]收←◆RxBuffer1:[16:19:22.375]发→◇LED_ON□[16:19:22.378]收←◆RxBuffer1:[16:19:22.846]发→◇LED_ON□[16:19:22.878]收←◆RxBuffer1:[16:19:23.279]发→◇LED_ON□[16:19:23.379]收←◆RxBuffer1:[16:19:23.854]发→◇LED_ON□[16:19:23.880]收←◆RxBuffer1:不能正常的打印出接收到的数据 [/font] [/backcolor][/color]
3589浏览量 0回复量 关注量 -
CC2640的I2C问题请教
我用CC2640 的I2C 模块给OPT3001光照芯片 写值,发现写不进去。该芯片寄存器是16位的,咱I2C模块可以写16位寄存器的值吗??? 我就想给0x01寄存器写个0x54,0x10,代码如下: void Set_OPT3001(uint8_t limit) { Reset_OPT3001_Register(); txBuffer[0] = 0x54;txBuffer[1] = 0x10; i2cTrans.writeCount = 3; i2cTrans.writeBuf = txBuffer; i2cTrans.readCount = 0; i2cTrans.readBuf = rxBuffer; i2cTrans.slaveAddress = 0x44; I2C_transfer(handle, &i2cTrans); }
22875浏览量 4回复量 关注量