2020-04-22 06:04 AM
I'm making my own low level CAN driver.
I have a problem releasing the CANperipheral from sleep mode.
So there are more requirements then I found so far.
LL_AHB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_CAN1);
LL_AHB3_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_CAN1);
LL_AHB3_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_CAN1);
/* Exit from sleep mode */
CLEAR_BIT(Instance->MCR, CAN_MCR_SLEEP);
while ((Instance->MSR & CAN_MSR_SLAK) != 0U);
Any suggestion?
Thanks!
2020-04-22 06:33 AM
You're mixing up AHB1, APB1, and AHB3. You need to call the correct one, with the correct argument. The LL file lists the valid arguments for each call.
LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_CAN1);
LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_CAN1);
LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_CAN1);
2020-04-22 06:47 AM
Ok thanks. That did not solve it unfortunately.
2020-04-28 12:51 AM
Somehow the candriver I/O needs to be configured before the module can exit sleep mode.
I can't get the io pins configured correctly with the lowlevel driver
So what is the difference between this two:
__HAL_RCC_GPIOA_CLK_ENABLE();
GPIO_InitStruct.Pin = GPIO_PIN_12;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Alternate = GPIO_AF9_CAN1;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
/* CAN1 RX GPIO pin configuration */
GPIO_InitStruct.Pin = GPIO_PIN_11;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Alternate = GPIO_AF9_CAN1;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
and:
__HAL_RCC_GPIOA_CLK_ENABLE();
LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_GPIOA);
LL_GPIO_SetPinSpeed(GPIOA, LL_GPIO_PIN_12, LL_GPIO_SPEED_FREQ_VERY_HIGH);
LL_GPIO_SetPinOutputType(GPIOA, LL_GPIO_PIN_12, LL_GPIO_OUTPUT_PUSHPULL);
LL_GPIO_SetPinPull(GPIOA, LL_GPIO_PIN_12, LL_GPIO_PULL_UP);
LL_GPIO_SetAFPin_8_15(GPIOA, LL_GPIO_PIN_12, LL_GPIO_AF_9);
LL_GPIO_SetPinMode(GPIOA, LL_GPIO_PIN_12, LL_GPIO_MODE_ALTERNATE);
LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_GPIOA);
LL_GPIO_SetPinSpeed(GPIOA, LL_GPIO_PIN_11, LL_GPIO_SPEED_FREQ_VERY_HIGH);
LL_GPIO_SetPinOutputType(GPIOA, LL_GPIO_PIN_11, LL_GPIO_OUTPUT_PUSHPULL);
LL_GPIO_SetPinPull(GPIOA, LL_GPIO_PIN_11, LL_GPIO_PULL_UP);
LL_GPIO_SetAFPin_8_15(GPIOA, LL_GPIO_PIN_11, LL_GPIO_AF_9);
LL_GPIO_SetPinMode(GPIOA, LL_GPIO_PIN_11, LL_GPIO_MODE_ALTERNATE);
Edit: solved.