STM32H7432 串口采用DMA方式接收不定长数据重复问题
STM32H750使用FMC控制LCD数据异常
关于STM32H750采用DMA方式发送数据到DAC产生正弦波
STM32H7配置成USB DEVICE时,连接电脑时不进入中断
STM32H753XIH6运行时发热达到五六十度
STM32H750电池供电后AD采样的电容板子电压变化异常
STM32H750VB芯片整片无法擦出
STM32H743IIT6Flash擦除问题
STM32H750 ADC 发现结果跳动很严重
STM32H743ZI无法串口下载程序
感謝, 下載看一下
怎么个不行,不妨你把你的程序发给我,我帮你看看,625194384@qq.com
u8 BspMcuCanInit(void)
{
FDCAN_FilterTypeDef sFilterConfig;
FDCAN1_Handler.Instance = FDCAN1;
__HAL_RCC_FDCAN_CLK_ENABLE();
/* 配置FDCAN参数 */
FDCAN1_Handler.Init.FrameFormat = FDCAN_FRAME_CLASSIC;
FDCAN1_Handler.Init.Mode = FDCAN_MODE_NORMAL;
FDCAN1_Handler.Init.AutoRetransmission = ENABLE;
FDCAN1_Handler.Init.TransmitPause = DISABLE;
FDCAN1_Handler.Init.ProtocolException = ENABLE;
FDCAN1_Handler.Init.NominalPrescaler = 1U;
FDCAN1_Handler.Init.NominalSyncJumpWidth = 2U;
FDCAN1_Handler.Init.NominalTimeSeg1 = 16U;
FDCAN1_Handler.Init.NominalTimeSeg2 = 8U;
FDCAN1_Handler.Init.StdFiltersNbr = 1U;
FDCAN1_Handler.Init.ExtFiltersNbr = 0U;
FDCAN1_Handler.Init.RxFifo0ElmtsNbr = 64U;
FDCAN1_Handler.Init.RxFifo0ElmtSize = FDCAN_DATA_BYTES_8;
FDCAN1_Handler.Init.RxFifo1ElmtsNbr = 0U;
FDCAN1_Handler.Init.RxBuffersNbr = 0U;
FDCAN1_Handler.Init.TxEventsNbr = 32U;
FDCAN1_Handler.Init.TxBuffersNbr = 0U;
FDCAN1_Handler.Init.TxFifoQueueElmtsNbr = 32U;
FDCAN1_Handler.Init.TxFifoQueueMode = FDCAN_TX_FIFO_OPERATION;
FDCAN1_Handler.Init.TxElmtSize = FDCAN_DATA_BYTES_8;
if (HAL_FDCAN_Init(&FDCAN1_Handler) != HAL_OK)
{
//ERROR_HANDLER(); /* 出错处理 */
}
else
{
/* nothing */
}
/* 配置接收滤波器 */
sFilterConfig.IdType = FDCAN_EXTENDED_ID;
sFilterConfig.FilterIndex = 1;
sFilterConfig.FilterType = FDCAN_FILTER_MASK;
sFilterConfig.FilterConfig = FDCAN_FILTER_TO_RXFIFO0;
sFilterConfig.FilterID1 = 0xFFF11000U;
sFilterConfig.FilterID2 = 0xFFFFE000U;
HAL_FDCAN_ConfigFilter(&FDCAN1_Handler, &sFilterConfig);
/* 启动FDCAN */
if (HAL_OK != HAL_FDCAN_Start(&FDCAN1_Handler))
{
//ERROR_HANDLER(); /* 出错处理 */
}
else
{
/* nothing */
}
/* 使能接收FIFO New Message中断 */
if (HAL_OK != HAL_FDCAN_ActivateNotification(&FDCAN1_Handler, FDCAN_IT_RX_FIFO0_NEW_MESSAGE, 0U))
{
// ERROR_HANDLER(); /* 出错处理 */
}
else
{
/* nothing */
}
/* 使能发送FIFO Empty中断 */
if (HAL_OK != HAL_FDCAN_ActivateNotification(&FDCAN1_Handler, FDCAN_IT_TX_FIFO_EMPTY, 0U))
{
// ERROR_HANDLER(); /* 出错处理 */
}
else
{
/* nothing */
}
return 0;
}
公司的文件是加密,这是我的配置,请你给看看对不对
缺少这个函数,全局滤波设置 没有这个函数,总线上任何数据你都能收到。
HAL_FDCAN_ConfigGlobalFilter(&hfdcan1, FDCAN_REJECT, FDCAN_REJECT, ENABLE, ENABLE)
u8 FDCAN1_Mode_Init(u8 tnsjw,u16 tseg1,u8 tseg2,u16 tnbrp,u8 mode)
{
FDCAN_ClkCalUnitTypeDef FDCAN1_ClkCalUnit;
FDCAN_FilterTypeDef FDCAN1_RXFilter;
//初始化FDCAN1
HAL_FDCAN_DeInit(&FDCAN1_Handler); //先清除以前的设置
FDCAN1_Handler.Instance = FDCAN1;
FDCAN1_Handler.Init.FrameFormat = FDCAN_FRAME_FD_BRS; //传统模式
FDCAN1_Handler.Init.Mode = mode; //模式设置
FDCAN1_Handler.Init.AutoRetransmission = ENABLE;//DISABLE; //关闭自动重传!传统模式下一定要关闭!!!
FDCAN1_Handler.Init.TransmitPause = DISABLE; //关闭传输暂停
FDCAN1_Handler.Init.ProtocolException = ENABLE;//DISABLE; //关闭协议异常处理
//FDCAN的Nominal波特率
//FDCAN_NBTP
FDCAN1_Handler.Init.NominalPrescaler = tnbrp; //分频系数 5
FDCAN1_Handler.Init.NominalSyncJumpWidth = tnsjw; //重新同步跳跃宽度范围:2~128 8
FDCAN1_Handler.Init.NominalTimeSeg1 = tseg1; //tseg1范围:2~256 8
FDCAN1_Handler.Init.NominalTimeSeg2 = tseg2; //tseg2范围:2~128 11
FDCAN1_Handler.Init.MessageRAMOffset = 0; //信息RAM偏移
//FDCAN的波特率Data波特率
//FDCAN_DBTP
FDCAN1_Handler.Init.DataPrescaler = 0x1;
FDCAN1_Handler.Init.DataSyncJumpWidth = 0x4;
FDCAN1_Handler.Init.DataTimeSeg1 = 0x5; // DataTimeSeg1 = Propagation_segment + Phase_segment_1 //
FDCAN1_Handler.Init.DataTimeSeg2 = 0x4;
FDCAN1_Handler.Init.StdFiltersNbr = 1; //标准信息ID滤波器编号
FDCAN1_Handler.Init.ExtFiltersNbr = 1; //扩展信息ID滤波器编号
FDCAN1_Handler.Init.RxFifo0ElmtsNbr = 1; //接收FIFO0元素编号
FDCAN1_Handler.Init.RxFifo0ElmtSize = FDCAN_DATA_BYTES_8; //接收FIFO0元素大小:8字节
FDCAN1_Handler.Init.RxFifo1ElmtsNbr = 2;
FDCAN1_Handler.Init.RxFifo1ElmtSize = FDCAN_DATA_BYTES_8;
FDCAN1_Handler.Init.RxBuffersNbr = 1;
FDCAN1_Handler.Init.RxBufferSize = FDCAN_DATA_BYTES_8; //接收缓冲编号
FDCAN1_Handler.Init.TxEventsNbr = 2; //发送事件编号
FDCAN1_Handler.Init.TxBuffersNbr = 1; //发送缓冲编号
FDCAN1_Handler.Init.TxFifoQueueElmtsNbr = 2; //发送FIFO序列元素编号
FDCAN1_Handler.Init.TxFifoQueueMode = FDCAN_TX_FIFO_OPERATION; //发送FIFO序列模式
FDCAN1_Handler.Init.TxElmtSize = FDCAN_DATA_BYTES_8; //发送大小:8字节
HAL_FDCAN_Init(&FDCAN1_Handler);
FDCAN1_ClkCalUnit.ClockCalibration = DISABLE; //不使用时钟校准功能
//FDCAN_CLOCK_DIV10 10分频,得到20Mhz的fdca_tq_ck
//FDCAN_CLOCK_DIV4 4分频,得到50Mhz的fdca_tq_ck
FDCAN1_ClkCalUnit.ClockDivider = FDCAN_CLOCK_DIV10;
HAL_FDCAN_ConfigClockCalibration(&FDCAN1_Handler,&FDCAN1_ClkCalUnit); //设置分频
//配置RX滤波器
FDCAN1_RXFilter.IdType = FDCAN_STANDARD_ID; //标准ID
FDCAN1_RXFilter.FilterIndex = 0; //滤波器索引
//滤波器类型
//FDCAN_FILTER_RANGE Range filter from FilterID1 to FilterID2
//FDCAN_FILTER_DUAL Dual ID filter for FilterID1 or FilterID2
//FDCAN_FILTER_MASK Classic filter: FilterID1 = filter, FilterID2 = mask
//FDCAN_FILTER_RANGE_NO_EIDM Range filter from FilterID1 to FilterID2, EIDM mask not applied
FDCAN1_RXFilter.FilterType = FDCAN_FILTER_DUAL;
FDCAN1_RXFilter.FilterConfig = FDCAN_FILTER_TO_RXFIFO0;//FDCAN_FILTER_TO_RXBUFFER;////过滤器0关联到FIFO0
FDCAN1_RXFilter.FilterID1 = 0x0543; //32位ID
FDCAN1_RXFilter.FilterID2 = 0x07ff; //如果FDCAN配置为传统模式的话,这里是32位掩码
FDCAN1_RXFilter.RxBufferIndex = 0;
HAL_FDCAN_ConfigFilter(&FDCAN1_Handler,&FDCAN1_RXFilter);
HAL_FDCAN_ConfigGlobalFilter(&FDCAN1_Handler, FDCAN_ACCEPT_IN_RX_FIFO0, FDCAN_ACCEPT_IN_RX_FIFO0, ENABLE, ENABLE);
// // Configure extended ID reception filter to Rx FIFO 1
// FDCAN1_RXFilter.IdType = FDCAN_STANDARD_ID;
// FDCAN1_RXFilter.FilterIndex = 0;
// FDCAN1_RXFilter.FilterType = FDCAN_FILTER_DUAL;
// FDCAN1_RXFilter.FilterConfig = FDCAN_FILTER_TO_RXFIFO1;//FDCAN_FILTER_TO_RXBUFFER;//
// FDCAN1_RXFilter.FilterID1 = 0x0643;
// FDCAN1_RXFilter.FilterID2 = 0x07ff;
// HAL_FDCAN_ConfigFilter(&FDCAN1_Handler, &FDCAN1_RXFilter);
//
// HAL_FDCAN_ConfigGlobalFilter(&FDCAN1_Handler, FDCAN_ACCEPT_IN_RX_FIFO0, FDCAN_ACCEPT_IN_RX_FIFO0, ENABLE, ENABLE);
HAL_FDCAN_Start(&FDCAN1_Handler); //开启FDCAN
HAL_FDCAN_ActivateNotification(&FDCAN1_Handler,FDCAN_IT_RX_FIFO0_NEW_MESSAGE,0);//Enable interrupts.
return 0;
}
FDCANå®éª_20190123.rar
2019-1-24 16:02 上传
点击文件名下载附件
下载积分: ST金币 -15.25 MB, 下载次数: 68, 下载积分: ST金币 -1
不要用“FDCAN_ACCEPT_IN_RX_FIFO0”这个参量,这个是标识没有匹配到要滤波的ID就放到FIFO里了 要改用“FDCAN_REJECT”参量,没有匹配到滤波的ID就拒绝接收
HAL_FDCAN_ConfigGlobalFilter(&hfdcan1, FDCAN_REJECT, FDCAN_REJECT, ENABLE, ENABLE)
顶一个