cancel
Showing results for 
Search instead for 
Did you mean: 

Disabling JTAG on STM32L151

Mikk Leini
Senior
Posted on May 05, 2012 at 18:46

I'm using STM32L151R8. I have SPI slave on SPI1 pins PB3-PB5 and CS on PA15. The SPI doesn't seem to work and i need to double check the warning about disabling the JTAG pins.

But STM32L151xx reference manual has funny text in chapter 24.4.2  Flexible SWJ-DP pin assignment:

''For more details on how to disable SWJ-DP port pins, please refer to Section 24.4.2: Flexible SWJ-DP pin assignment.''.

 

This leads back to the same chapter which doesn't say how should the JTAG is disabled.

I have read that F1 series have  function for that:

GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable | GPIO_Remap_SWJ_NoJTRST, ENABLE);

But how it is supposed to be done in STM32L151 ??

#stm32l-stm32l151-jtag-disable #stm32l151-spi1-problem #off-topic
4 REPLIES 4
Posted on May 06, 2012 at 01:20

But how it is supposed to be done in STM32L151 ??

a) You config the GPIO pins not to be in AF mode

or

b) Use GPIO_PinAFConfig() to park the AF mux at something other than GPIO_AF_SWJ or GPIO_AF_TRACE. You'll need to enable the SYSCFG clock for this to work, and use PinSource to designate each pin function individually.
Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Mikk Leini
Senior
Posted on May 06, 2012 at 21:22

Ok, the option b was what i thought. But it had an error:

I called:

GPIO_PinAFConfig(GPIOB,  GPIO_Pin_3,  GPIO_AF_SPI1);

But should have called:

GPIO_PinAFConfig(GPIOB,  GPIO_PinSource3,  GPIO_AF_SPI1);

So got SPI working finally:)

arulprabhu
Associate II
Posted on January 11, 2013 at 14:04

Hi all,

I am testing SPI on STM32L151CB and used PinA4-A7 for SPI1and it is not woking.

This is my SPI configuration,

 GPIO_InitTypeDef  GPIO_InitStructure;

 SPI_InitTypeDef   SPI_InitStructure;

    

    

    

    

  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);

  RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1, ENABLE);

    

        

  GPIO_PinAFConfig(GPIOA, GPIO_PinSource5, GPIO_AF_SPI1);

 

  GPIO_PinAFConfig(GPIOA, GPIO_PinSource6, GPIO_AF_SPI1);

 

  GPIO_PinAFConfig(GPIOA, GPIO_PinSource7, GPIO_AF_SPI1);

 

 

  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5|GPIO_Pin_6|GPIO_Pin_7;

  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;

  GPIO_Init(GPIOA, &GPIO_InitStructure);

  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4;

  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;

  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;

  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;

  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;

  GPIO_Init(GPIOA, &GPIO_InitStructure);

    

  GPIO_SetBits(GPIOA, GPIO_Pin_4);

 

    

 

  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_Low;

  SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge;

  SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;

  SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_128;

  SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;

  SPI_InitStructure.SPI_CRCPolynomial = 7;

  SPI_Init(SPI1, &SPI_InitStructure);

 

  SPI_Cmd(SPI1, ENABLE);

What is the problem with the code.

Can anyone help me.

Posted on January 11, 2013 at 16:04

The question is a bit Off Topic for this thread, in the future create a new thread when starting an unrelated topic.

You should perhaps initialize the GPIO structure more completely for a start

  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5|GPIO_Pin_6|GPIO_Pin_7;

  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;

  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;

  GPIO_InitStructure.GPIO_PuPd  = GPIO_PuPd_DOWN;

  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_40MHz;

  GPIO_Init(GPIOA, &GPIO_InitStructure);

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..