cancel
Showing results for 
Search instead for 
Did you mean: 

SPI3 problem with STM32f4- discovery and stm32f103

miroslav
Associate II
Posted on January 27, 2014 at 13:42

Hi,

I have problem with SPI3 and st-link debugger. CLK pin is always unaveilable.

I configure MCU to not use JTDO but in debug mode when I look at AFIO register there is written some other value for SWJ_CFG(always 0x50) and I want it to be 0x20.

I already work with SPI1 and SPI2 and they work perfect in interrupt and non-interrupt mode.

How to solve problem?

there is little code:

tmp = AFIO->MAPR;

tmp &= 0xF8FFFFFF;

tmp |= AFIO_MAPR_SWJ_CFG_JTAGDISABLE;

AFIO->MAPR = tmp;

  DBGMCU->CR &= ~DBGMCU_CR_TRACE_IOEN; //disable async trace for every case

it works same as GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE); 

All the best,

Miroslav

#stm32 #stm32-st-link-swd #stm32discovery
7 REPLIES 7
miroslav
Associate II
Posted on January 27, 2014 at 13:47

Hi,

Also PB3 pin, used for CLK I can't use for anything as I can't even toggle it like GPIO.

Here are port settings:

GPIO_InitStructure.GPIO_Pin = CLK | MOSI ;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;

GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

GPIO_Init(GPIOB, &GPIO_InitStructure);

Posted on January 27, 2014 at 14:09

> Subject: SPI3 problem with STM32f4 an stm32f103

So is it STM32F4, or STM32F103?

> I configure MCU to not use JTDO but in debug mode when I look at AFIO register there is

> written some other value for SWJ_CFG(always 0x50) and I want it to be 0x20.

Isn't SWJ_CFG a 3-bit bitfield? Then it can't be 0x50 nor 0x20.

AFIO clock enabled when you try to rewrite its registers?

> Also PB3 pin, used for CLK I can't use for anything as I can't even toggle it like GPIO.

Once you set it to AF, then you can't use it as a GPIO output.

JW

miroslav
Associate II
Posted on January 27, 2014 at 14:23

Hi,

I use STM32F03 with st-link debbuger.

It imposible to set AFIO register.

Every value written will always be restored by debugger.

miroslav
Associate II
Posted on January 27, 2014 at 14:31

As i said, when I set it to be GPIO out, not AF, I can't use it. 

Next line:

 AFIO->MAPR = ''what ever I put''; will resul that MAPR is 0x04000000.

That is also lie!!! Because 0x04000000 will disable JTAG and SW together but debugger continue working!

Posted on January 27, 2014 at 15:04

AFAIK, STLink is a relatively dumb USB-to-JTAG/SWD convertor.

So, if you suspect ''something'' is overwriting the registers during debugging, it's the PC-side software you have to blame. You might want to review the documentation coming with that.

JW

miroslav
Associate II
Posted on January 27, 2014 at 15:16

Hi,

Yes, it must be problem with ukeil. Compiler probably predefine some settings for that.

Funny thing is that on ukeil without debbuger selected, built code after UART download works!

Once I select debugger all stop working and I cant return to previous state.

All the best,

Miroslav

miroslav
Associate II
Posted on January 27, 2014 at 17:03

All working now,

One global chip erase did the job.

All the best and thanx for atention.

Miroslav