cancel
Showing results for 
Search instead for 
Did you mean: 

Hardware port fault

juanjo
Associate II
Posted on November 17, 2013 at 19:37

I have esperiencing port hardware fault in my prototype. I want to say exactly that the port doesn't work.

One of th ethings that happend to my device few month ago is that the port PA0 doesn't write anything if I say to the port to write ''1'' or ''0''

Always is ''0'' level.

This is not something related to the software, I think so, just becaues in other device works perfectly. This only happen in this device, this is the reason

why I think that is a port hardware fault. The hardware connected to the port is a resistor of 1k5 and a amber led. Th eport is configured with the PWM to generated

le blinking. Well one of the prototype doesn't work, led alway off. but if I test the software in other prototype it work perfectly.

�There is a way to know if the port is broken?, �Can be related to some changes during debugging?

When it happend I suppose that maybe I made a short with some VDD pins, but if you put 3.3v to an output pin it broke? mmmm.

This is the GPIO port configuration:

    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;          // Alt Function - Push Pull

The reason why I'm asking that is because in other prototype the SPI (MOSI) is not working, I can test and no signal is present, but Clock signal is OK, the slave doesn't respond

due to teh lack of signal of the master.

And here is the same circunstance, the comunication with the external EPROM work perfectly in other device, but not in this.

The port I'm using is PB15 (5 volts tolerant).

I don't know why the port doesn't work, but it seem that ports arfe not robust enought or there is something that I can not understand.

Any idea?

Any help will be wellcome. If need more information it would be a pleasure for me to give it.

Thanks in advance.

#gpio-port #stm32
13 REPLIES 13
deathvag
Associate II
Posted on November 04, 2014 at 00:05

Hello guys,

I seem to have the exact same problem. I have implemented PWM generation for infrared control on STM32F103ZG before, but on a different board. Now (the same CPU but different board) that the IR led is on another pin, it doesn't work. I experience exactly the same. I set the pin to Out_PP and I am able with GPIO SetBits to turn it on, but not have PWM.

When I set to AF_PP for PWM, it doesn't work at all. Not only in the PWM generation, but even with GPIO SetBits it doesn't turn on. The funny thing is that the same timer (Timer3_CH2)is mapped to the pin but as jjTronix

0690X0000060MmsQAE.gifnoted in AF_PP mode it is just dead...Any ideas?

Vagelis

Posted on November 04, 2014 at 01:06

So which pin? PB5 would need a remap for TIM3_CH2, which would require AFIO being clocked/configured.

The STM32F1 series parts have a somewhat inflexible pin mapping/remapping options. Pins like PA15 will also conflict with JTAG pins if that interface is not reconfigured.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
deathvag
Associate II
Posted on November 04, 2014 at 13:00

Hello,

Thank you for your immediate response. Yes it actually PB5. AFIO is enalbed and TIM3 is fully remapped.

  void initializePWM(void)

 {

      TIM_TimeBaseInitTypeDef TIM_TimeBaseInitStruct;

      TIM_OCInitTypeDef TIM_OCInitStruct;

      GPIO_InitTypeDef GPIO_InitStructure;

      RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB | RCC_APB2Periph_AFIO ,ENABLE);

   

      RCC_APB1PeriphClockCmd( RCC_APB1Periph_TIM3| RCC_APB1Periph_TIM4, ENABLE );

RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB,ENABLE);

  

  GPIO_InitStructure.GPIO_Pin =  GPIO_Pin_5;

  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; 

  GPIO_Init( GPIOB, &GPIO_InitStructure );

  GPIO_PinRemapConfig( GPIO_FullRemap_TIM3, ENABLE );   // Map TIM3_CH2

 

  //tim3-channel 2 for PWM1 generation 

      TIM_TimeBaseStructInit( &TIM_TimeBaseInitStruct );

      TIM_TimeBaseInitStruct.TIM_ClockDivision = 0;

      TIM_TimeBaseInitStruct.TIM_Period =179;   // 0..179

      TIM_TimeBaseInitStruct.TIM_Prescaler = 9; //0-9 ->72M/(40K*180)

      TIM_TimeBaseInit( TIM3, &TIM_TimeBaseInitStruct );

   

      TIM_OCStructInit( &TIM_OCInitStruct );

      TIM_OCInitStruct.TIM_OutputState = TIM_OutputState_Enable;

      TIM_OCInitStruct.TIM_OCMode = TIM_OCMode_PWM1;

      TIM_OCInitStruct.TIM_Pulse = 135; // 75% duty cycle 

      TIM_OC2Init( TIM3, &TIM_OCInitStruct ); // Channel 2

 //timer4 for delay_us function implementation 

TIM4->PSC = 71; // 1MHz

TIM4->CR1 = TIM_CR1_CEN;

//DBGMCU->CR = DBGMCU_CR_DBG_TIM4_STOP;

  }

note that the exact same batch of code works in my previous board,with the only difference that it was PC9 and TIM3_ch3

deathvag
Associate II
Posted on November 04, 2014 at 14:54

Thank you so much Clive for for concern but I found it!(page 180, reference manual) PB5 needs a partialremap not a full one. PC9(previous board) needed a fullremap so that's why it was working.

Now with the partialremap it works! Thanks anyway

Vagelis