2019-04-03 01:14 AM
Good Morning
I use STM32F1VCT with the CANOPEN_Stack of the company EMTAS. For the CAN I use PIN PB8-PB9.
If the program starts normally, the CAN bus works as desired.
However, if I want to debug, the debugger will abort as soon as the macro "__HAL_AFIO_REMAP_CAN1_2 ();" is performed.
Also the "STM32 ST-LINK Utility" can not connect and the output via SWO does not work.
When I remove the macro, the SWO and the debugger work normally.
How do I find the mistake?
Thanks for your help
2019-04-03 02:08 AM
It helps, if you give full type of used MCU. What is "STM32F1VCT"? I have looked at the F107 datasheet, and CAN does not collide with JTAG/SWD/DEBUG. So the problem is probably in the HAL. Have a look at the HAL code doing the remap.
2019-04-03 02:23 AM
Sorry the right type is STM32F103VCT6.
GPIO_InitStruct.Pin = GPIO_PIN_9;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
GPIO_InitStruct.Pin = GPIO_PIN_8;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
__HAL_AFIO_REMAP_CAN1_2();
Thanks for your help
2019-04-03 05:12 AM
I can not find the mistake ...
2019-04-03 11:46 AM
Good evening,
what information should I still give? How can I further narrow down the problem?
Thanks for your help
2019-04-04 12:26 AM
One more information as discussed with the TO directly:
The write of
AFIO->MAPR = 0x07004000;
deactivate the SWD. The manual say and it work in all other environments we know, the SWL_CFG = 7 has no effect. He use the Atollic environment.
2019-04-04 02:29 AM
It was the solved Bug in the HAL
HAL GPIO update
Rework AFIO remap macros to avoid issue with Read-modify-write sequence on AFIO_MAPR register