Change CAN to 1 Mbaud instead of 666.667 Kbaud; put can_init in ifdef

This commit is contained in:
Michael Ehrenreich
2021-04-11 21:46:58 +02:00
parent b167180b91
commit 4452a54226
2 changed files with 5 additions and 4 deletions

2
can.c
View File

@ -144,7 +144,7 @@ void can_init(void)
CanHandle.Init.Mode = CAN_MODE_NORMAL;
CanHandle.Init.SyncJumpWidth = CAN_SJW_1TQ;
CanHandle.Init.TimeSeg1 = CAN_BS1_6TQ;
CanHandle.Init.TimeSeg2 = CAN_BS2_5TQ;
CanHandle.Init.TimeSeg2 = CAN_BS2_1TQ;
CanHandle.Init.Prescaler = 4;
if (HAL_CAN_Init(&CanHandle) != HAL_OK)

View File

@ -229,14 +229,15 @@ int main()
//#define UART_DMA_CHANNEL DMA1_Channel2
//UART3_Init();
#ifdef FEATURE_CAN
can_init();
#endif
#ifdef MOTOR_TEST
int pwm = 0;
int8_t dir = 1;
#else
can_config();
MODIFY_REG(RCC->CR, RCC_CR_HSITRIM, (0x1aU << RCC_CR_HSITRIM_Pos));
#ifndef FEATURE_CAN
HAL_UART_Receive_DMA(&huart2, (uint8_t *)&command, sizeof(command));
#endif // FEATURE_CAN