cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F407ZGT, SPI3 and Debugging with SWD

mkunz9
Associate II
Posted on January 12, 2015 at 10:52

Hello,

i'm using an STM32F407ZET6 with SPI1, SPI2, SP3 and SWD.

SPI1 and SPI2 are always working fine.

SPI3 works when the CPU is running without debugging.

Whenever I set a breakpoint SPI3 Clock (PortB3) has strange pulses.

I checked how to disable JTAG on STM32F4 in RM0090. It shoud be done automatically when

Changing the Pin Configuration:

...

GIO_InitStructure.GPIO_OType = GPIO_OType_PP;

GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;

...

And changing the Alternate Function mapping:

GPIO_PinAFConfig(SCK->GetPort(), SCK->GetPinSource(), GPIO_AF_SPI3);

Both is done in my code and as SPI3 is working (logic analizer and SPI-Chip is responding) as long as I break debugging via breakpoint or halt.

0690X00000604sHQAQ.png

However when I set a breakpoint SPI3 fails as SCK outputs something. I can also see that AFRL3 is always changed back to 0 and OSPEEDR3 is always changed back to 3.

Can anybody give me advice how to solve this issue?

0690X00000604KoQAI.png
7 REPLIES 7
Posted on January 12, 2015 at 11:11

PB3 is SWO, so maybe your toolchain is trying to switch on the serial-wire-output. Read the manual to your toolchain, or browse through its settings.

JW

mkunz9
Associate II
Posted on January 12, 2015 at 13:06

Hello Jan,

I guess you think the toolchain (IAR EWARM) is reactivating JTAG, again?

The Datasheet for the STM32F407XX DM00037051 says:

PA13 AF0: JTMS/SWDIO

PA14 AF0: JTCK/SWCLK

PA15 AF0: JTDI

PB3 AF0: JTDO/TRACES -> would be JTAG output

PB4 AF0: NJTRST

I tried SEGGER J-Link and IAR I-Jet, both are configured for SWD as interface. On the microcontroller only SWDIO, SWCKL, /RESET, VCC and GND are connected to the debugging probe. So normally when the toolchain reactivates JTAG it shouldn't be able to debug as the JTAG-Pins are not connected to the probe.

However,  I asked IAR, if they know an issue depending on EWARM and STM32 with SPI and SWD-debugging.

Thank you,

Martin

Posted on January 12, 2015 at 13:11

And this is with what JTAG pod and debugger/toolchain?

Check the errata, seem to recall a problem with the JTAG/SWD pins and reducing utilization.

Does the SPI device have a Chip Select?
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on January 12, 2015 at 13:15

> I guess you think the toolchain (IAR EWARM) is reactivating JTAG, again?

No. SWO is an optional  auxilliary debug/trace/whatever-you-call-it output in the SWD mode.

I don't IAR, but maybe this video might help you https://www.youtube.com/watch?feature=player_detailpage&v=pusvyW-pbsU#t=71

JW

mkunz9
Associate II
Posted on January 12, 2015 at 14:33

Hello,

I tried the following debug probes:

SEGGER J-Link PLUS

IAR I-Jet

with the IAR Embedded Workbench for ARM V7.30.4

I thought I didn't find anything related to SWD in DM00037591, but I'll double check this.

The SPI-Chip has a chip-select pin, but I'm using this controlled by Software.

 SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex;

SPI_InitStructure.SPI_Mode = SPI_Mode_Master;

 SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b;

 SPI_InitStructure.SPI_CPOL = SPI_CPOL_High;

 SPI_InitStructure.SPI_CPHA = SPI_CPHA_2Edge;

 SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;

...

From: clive1

Posted: Monday, January 12, 2015 1:11 PM

Subject: STM32F407ZGT, SPI3 and Debugging with SWD

And this is with what JTAG pod and debugger/toolchain?

Check the errata, seem to recall a problem with the JTAG/SWD pins and reducing utilization.

Does the SPI device have a Chip Select?
mkunz9
Associate II
Posted on January 15, 2015 at 08:40

Hello Jan,

the attached movie didn't help, this is just how to activate the route to IAR.

But on IAR i-Jet there was an extra Feature ->

Project-Properties -> Debugger -> I-Jet/JTAGjet -> Trace

Trace data collection

Mode: None

The J-Link does not have this Feature.

I tried connecting to J-Link via GDB Server and after that, SWO is no longer reactivated.

So I guess it's again an IAR related problem.

IAR still didn't answer yet (not a good sign with a valid service and update license agreement for 820 EUR / year)

Thank you for your help

mkunz9
Associate II
Posted on January 20, 2015 at 08:04

Hello,

IAR EWARM 7.30 does not support activating or deactivating SWO when using a J-Link.

All settings related to SWO don't touch J-Links SWO Interface configuration. You have to run J-Link.exe manually and use the commands ''SWOStart'' and ''SWOStop''