Skip to main content
PSant.8
Associate
Apr 3, 2019 8:14 AM UTC
Question

After CAN_REMAP, the debugger and SWO no longer work.

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

This topic has been closed for replies.

6 replies

Uwe Bonnes
Chief
Apr 3, 2019 9:08 AM UTC

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.

PSant.8
PSant.8Author
Associate
Apr 3, 2019 9:23 AM UTC

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

PSant.8
PSant.8Author
Associate
Apr 3, 2019 12:12 PM UTC

I can not find the mistake ...

PSant.8
PSant.8Author
Associate
Apr 3, 2019 6:46 PM UTC

Good evening,

what information should I still give? How can I further narrow down the problem?

Thanks for your help

Steffen Rose
Associate III
Apr 4, 2019 7:26 AM UTC

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.

Steffen Rose
Associate III
Apr 4, 2019 9:29 AM UTC

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