Skip to main content
Visitor II
September 23, 2019
Solved

Arduino connector - stm32mp157-dk2

  • September 23, 2019
  • 4 replies
  • 1466 views

Hi,

I am working with stm32mp157-dk2.

Arduino connector CN16-pin5 is giving 5v.

How can I switch on/off this pin in my M4 program ?

I couldn't find a solution or example, could you please help me ?

    This topic has been closed for replies.
    Best answer by PatrickF

    This pin is tied to 5V_VIN (VBUS supply from USB Type-C connector CN6) thru a 0ohm resistor. No way to switch off by SW.

    This 5V is present on all Arduino.

    On STM32MP157-DK2, in case of conflict with your Arduino shield, you could disconnect it permanently by removing R165 (visible on PCB close the the 5V CN16 pin).

    0690X00000ARUJJQA5.jpg

    4 replies

    PatrickFAnswer
    Technical Moderator
    September 23, 2019

    This pin is tied to 5V_VIN (VBUS supply from USB Type-C connector CN6) thru a 0ohm resistor. No way to switch off by SW.

    This 5V is present on all Arduino.

    On STM32MP157-DK2, in case of conflict with your Arduino shield, you could disconnect it permanently by removing R165 (visible on PCB close the the 5V CN16 pin).

    0690X00000ARUJJQA5.jpg

    IYetkAuthor
    Visitor II
    September 23, 2019

    thank you. I dont use Arduino shield. I just want to control a 5v ventilator with m4 program on dk2 board. (just switching on / off)

    I think I should use gpio connectors. There are two gpio pins that give 5v supply.

    Technical Moderator
    September 23, 2019

    Altough GPIOs could sustain 5V, they are limited in power to about 20mA (with 1.3V output, which mean only 3.7V remain on the load), so you probably can't control a fan power in that way. You must add a transistor or similar power control.

    To control FAN, you could better make use of a PWM fan (e.g. most fan used in computers) which could be supplied from 5V or 12V directly whereas the PWM pin could be handled directly by a timer output in 3.3V from STM32MP1 to control fan speed from 0 to 100%.

    Alternatively, if intermediate speeds are not required, a simple GPIO on the fan PWM pin could control from 0 or 100% (i.e. OFF/ON).

    IYetkAuthor
    Visitor II
    September 23, 2019

    I havent done yet any project including PWM control. Is there any referance code or example written for m4 (dk2) that I can refer ?

    Technical Moderator
    September 23, 2019

    Examples are no need to be DK2 specific. You probably find some just googling "STM32 PWM".

    First you need to configure your timer in PWM mode at the needed frequency (usually 25kHz for PC PWM fan) on the pin you want the output control. This is mostly done under STM32CubeMx.

    Then in your code, once init you have to use the HAL_TIM_PWM_Start() and __HAL_TIM_SET_COMPARE() to change the duty cycle.

    Note that as PWM fan also provide a tachometer output, you could also monitor the fan speed using another timer input.

    see also: STM32MP1-WDG_TIMERS-General_Purpose_Timer_GPTIM.pdf

    IYetkAuthor
    Visitor II
    September 23, 2019

    thanks for detailed answer