cancel
Showing results for 
Search instead for 
Did you mean: 

Lost SWD debugging Connection at ''__HAL_AFIO_REMAP_CAN1_2(); ''

ahssax
Associate
Posted on November 18, 2015 at 12:26

Dear all, 

My development environments are as followings,

 - STM32F103VET7

 - IAR EWARM

 - STLink/V2 & SWD connection 

Program download and ''go'' are no problem. But I always failed to stop debugging with communication error message(Target is running, Failed to stop the Target).

I tried to find the position where debugger lost the connection and found it as below.

__HAL_AFIO_REMAP_CAN1_2()  of HAL_CAN_MspInit();

&sharpdefine __HAL_AFIO_REMAP_CAN1_2() MODIFY_REG(AFIO->MAPR, AFIO_MAPR_CAN_REMAP, AFIO_MAPR_CAN_REMAP_REMAP2)

The macro is just for AFIO_MAPR remapping(PB8, PB9 for CAN1).

I cannot understand why it casued brake debugger connection. If I deleted the line as temporary, ''debugging stop & go'' is possible , but failed to use BxCAN1.  

Please help me...

#swd #stm32 #bxcan #debugger
6 REPLIES 6
Posted on November 18, 2015 at 14:57

I guess you'd need to double check the defines, and the register they are acting upon, and confirm what's actually being done in the Reference Manual. There are plenty of bugs in the HAL waiting to be discovered.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
denisb-popov
Associate II
Posted on November 18, 2015 at 15:08

kim.jc

Try to remap CAN before switching to SWD. I had a simular problem with SPI1 remap

Amel NASRI
ST Employee
Posted on November 18, 2015 at 15:26

Hi kim.jc,

In the project available under ''STM32Cube_FW_F1_V1.2.0\Projects\STM3210E_EVAL\Examples\CAN\CAN_Networking'', there is a call for __HAL_AFIO_REMAP_CAN1_2. I tested this project and I didn't faced any issue.

Could you please do the same and let me know if you still have same problem?

-Mayla-

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

ahssax
Associate
Posted on November 19, 2015 at 01:05

Wow  !!

Thank a lot for your coonsideration.

As your recommend, I tried to change the location of can port remap.

But I couldn't get a correct operation. 

Anyway,  If i delete __HAL_AFIO_REMAP_SWJ_NOJTAG() in HAL_MspInit(),

everything is OK. 

  //__HAL_AFIO_REMAP_SWJ_NOJTAG();

Repeatly speaking, thank p.denis very much.

BR,

JC Kim

misagh
Associate III
Posted on August 31, 2016 at 06:19

Hi,

I have the same problem. in my code the

__HAL_AFIO_REMAP_SWJ_NOJTAG();

changes the AFIO>MPR register value to 0x04000000 instead of 0x02000000!!! any suggestion? Thanks, Misagh
Posted on December 21, 2016 at 09:14

Hi! I found same error with reading different values from this register. I even tried to read/write values as pointer to (volatile uint32_t).

https://community.st.com/0D50X00009XkYWnSAN