cancel
Showing results for 
Search instead for 
Did you mean: 

After CAN_REMAP, the debugger and SWO no longer work.

PSant.8
Associate II

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

6 REPLIES 6
Uwe Bonnes
Principal III

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
Associate II

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
Associate II

I can not find the mistake ...

PSant.8
Associate II

Good evening,

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

Thanks for your help

Steffen Rose
Associate III

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

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