-
hc32l136 Lpuart发生异常
当发送指令放置在接收中断时,一切正常。如果把发送中断移值主程序,偶尔就会出现发送指令不执行或延迟执行的现象。//===================================//初始化Lpuart//===================================voidlpuart_init(void){uint16_tu16Scnt=0;stc_gpio_config_tstcGpioCfg;stc_lpuart_sclk_sel_tstcSclk;stc_lpuart_config_tstcConfig;stc_lpuart_irq_cb_tstcLPUartIrqCb;stc_lpuart_multimode_tstcMulti;stc_lpuart_baud_tstcBaud;DDL_ZERO_STRUCT(stcConfig);DDL_ZERO_STRUCT(stcLPUartIrqCb);DDL_ZERO_STRUCT(stcMulti);DDL_ZERO_STRUCT(stcBaud);DDL_ZERO_STRUCT(stcGpioCfg);DDL_ZERO_STRUCT(stcSclk);Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio,TRUE);Sysctrl_SetPeripheralGate(SysctrlPeripheralLpUart1,TRUE);stcGpioCfg.enDir=GpioDirOut;Gpio_Init(GpioPortA,GpioPin0,&stcGpioCfg);//TXstcGpioCfg.enDir=GpioDirIn;stcGpioCfg.enPuPd=GpioPu;Gpio_Init(GpioPortA,GpioPin1,&stcGpioCfg);//RXGpio_SetAfMode(GpioPortA,GpioPin0,GpioAf2);Gpio_SetAfMode(GpioPortA,GpioPin1,GpioAf2);stcLPUartIrqCb.pfnRxIrqCb=LPUartRxIntCallback;stcLPUartIrqCb.pfnTxIrqCb=NULL;stcLPUartIrqCb.pfnRxFEIrqCb=NULL;stcLPUartIrqCb.pfnPEIrqCb=NULL;stcLPUartIrqCb.pfnCtsIrqCb=NULL;stcConfig.pstcIrqCb=&stcLPUartIrqCb;stcConfig.bTouchNvic=TRUE;stcConfig.enStopBit=LPUart1bit;stcConfig.enRunMode=LPUartMode1;//stcSclk.enSclk_Prs=LPUart4Or8Div;stcSclk.enSclk_sel=LPUart_Rcl;stcConfig.pstcLpuart_clk=&stcSclk;stcMulti.enMulti_mode=LPUartNormal;stcConfig.pstcMultiMode=&stcMulti;LPUart_Init(LPUART1,&stcConfig);LPUart_SetClkDiv(LPUART1,LPUart4Or8Div);stcBaud.u32Sclk=LPUart_GetSclk(LPUART1);stcBaud.enRunMode=LPUartMode1;stcBaud.u32Baud=9600;u16Scnt=LPUart_CalScnt(LPUA
2025-01-07 0 -
使用铁电遇到的奇怪问题
从铁电MB85RC128A读两串数据4*50、20*72,偶尔会发现某个字节会读错,最常见的是读成0XFF,原因出在哪里?
2022-04-24 1