本帖最后由 yangjie1388 于 2021-6-10 10:18 编辑
示波器显示信号是错误的。
主要代码如下:
while(1)
{
/* USER CODE BEGIN WHILE */
g_sendCANMsgInfo.DATA[0] = 0x01;
g_sendCANMsgInfo.ID = 0x189;
g_sendCANMsgInfo.IDE = 1;
g_sendCANMsgInfo.DLC = 7;
CAN_TransmitMessage(CAN0, &g_sendCANMsgInfo, CAN_TRANSMIT_PRIMARY);
/* USER CODE END WHILE */
mdelay(2000);
}
static void ATC_CAN_Init(void)
{
/* USER CODE BEGIN CAN_Init 0 */
/* USER CODE END CAN_Init 0 */
CAN_BitrateConfigType normalBitrate;
CAN_ConfigType canConfig;
/* USER CODE BEGIN CAN_Init 1 */
/* USER CODE END CAN_Init 1 */
MSP_CAN_Init(CAN0);
normalBitrate.PRESC = 5;
normalBitrate.SEG_1 = 11;
normalBitrate.SEG_2 = 2;
normalBitrate.SJW = 2;
canConfig.canMode = CAN_MODE_NORMAL;
canConfig.errorWarningLimit = 1;
canConfig.clockSrc = CAN_CLKSRC_AHB;
canConfig.tsMode = CAN_TSMODE_FIFO;
canConfig.tsAmount = CAN_TRANSMIT_ALL;
canConfig.interruptEn = ENABLE;
canConfig.tpss = DISABLE;
canConfig.tsss = DISABLE;
canConfig.timeStampEn = DISABLE;
canConfig.rom = CAN_RECV_DISCARD;
canConfig.selfAckEn = DISABLE;
canConfig.fdModeEn = DISABLE;
canConfig.interruptMask = CAN_IRQ_ALL_ENABLE_MSK;
canConfig.normalBitrate = &normalBitrate;
canConfig.callback = CAN0_IRQHandler_Callback;
CAN_Init(CAN0, &canConfig);
/* USER CODE BEGIN CAN_Init 2 */
/* USER CODE END CAN_Init 2 */
}
|