Saturday, June 20, 2026

STM32 Development Log 5: Current consumption

When running the  Switches_LED_Demo program,]

Current consumption increase by 100mA when SW3 is pressed. 

  1. When only heart beat LED is running, 0.179 Ampere @12V
  2. SW1:With LD5 on 0.187 Ampere = 8 mA increase over case 1
  3. SW2:With LD4 on 0.195 Ampere = 8 mA increase over case 2
  4. SW3:With LD3 on 0.305 Ampere =  110 mA increase over case 3 Why? SW3 switches PI14 and PI15. PI14 is LD3. PI15 is J3 connector, pin 38, switching relay  1. However this cannot add 100mA to the current consumption. 
 

After disable PI15 relay output in software, the current consumption is correct:

  • When only green heart beat LED is running, 0.175 Ampere @12V
  • SW1:With LD5 red on 0.184 Ampere = 9 mA increase over case 1
  • SW2:With LD4 red on 0.192 Ampere = 8 mA increase over case 2
  • SW3:With LD3 red on 0.193 Ampere = 1 mA increase over case 3 
  • SW4:With LD2 green on 0.195 Ampere = 2 mA increase over case 4
  • SW5:With LD1 green on 0.197 Ampere = 2 mA increase over case 5
  • SW6:With SW_LED green on 0.198 Ampere = 2 mA increase over case 6, in the control module.
  • if(button3 == 1)

    {

    if(button3_state == 0)

    {

    HAL_GPIO_WritePin(GPIOI, GPIO_PIN_14, GPIO_PIN_SET);

    button3_state = 1;

    // PI 15 is relay 1

    // This code is for testing only

    // HAL_GPIO_WritePin(GPIOI, GPIO_PIN_15, GPIO_PIN_SET);

    }

    else

    {

    HAL_GPIO_WritePin(GPIOI, GPIO_PIN_14, GPIO_PIN_RESET);

    button3_state = 0;

    // PI 15 is relay 1

    // This code is for testing only

    // HAL_GPIO_WritePin(GPIOI, GPIO_PIN_15, GPIO_PIN_RESET);


    }

    button3 = 0 ;


    }


     

    Comments

    1. LD2 , triggered by SW4, PA0 , needs long press for the LED to switch states, it is not interrupt driven, it is polled.
    2.  LD1, triggered by SW5, increases current consumption by only 3mA
    3. SW_LD10, triggered by SW6,  increases current consumption by only 4mA, SW_LD10 is physically located on the compute module, not on the base board.

    STM32 Development Log 4: Heart beat LED

    System clock setting:

    RCC_OscInitStruct.PLL.PLLM = 4;

    RCC_OscInitStruct.PLL.PLLN = 50;

    RCC_OscInitStruct.PLL.PLLP = 2;

     

    Timer duration set in tim.c

    /* USER CODE END TIM13_Init 1 */

    htim13.Instance = TIM13;

    htim13.Init.Prescaler = 9999;

    htim13.Init.CounterMode = TIM_COUNTERMODE_UP;

    htim13.Init.Period = 9999;

    htim13.Init.ClockDivision = TIM_CLOCKDIVISION_DIV4;

    htim13.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;

    Interrupt Frequency =
    TIM13 Clock / ((Prescaler + 1) × (Period + 1))

     PF2 Toggle  code in main.c:

    if(htim->Instance == TIM13)

    {


    if(heart_beat == 0)

    {

    heart_beat = 1 ;

    HAL_GPIO_WritePin(GPIOF, GPIO_PIN_2, GPIO_PIN_SET);

    }

    else

    {


    heart_beat = 0 ;

    HAL_GPIO_WritePin(GPIOF, GPIO_PIN_2, GPIO_PIN_RESET);

    }



     

    STM32 Development Log 3: Button details

    Button Summary

    Button Net Name MCU Pin Input Type Detection Method Interrupt Type Pull-up Type Pull-up Resistor
    SW1 SW_INP1 PF10 Digital Input EXTI Interrupt Falling Edge External R62 = 10 kΩ
    SW2 SW_INP2 PC0 Digital Input EXTI Interrupt Falling Edge External R61 = 10 kΩ
    SW3 SW_INP3 PC1 Digital Input EXTI Interrupt Falling Edge External R60 = 10 kΩ
    SW4 SW_INP4 PA0 Digital Input TIM7 Polling None External R59 = 10 kΩ
    SW5 SW_INP5 PH2 Digital Input EXTI Interrupt Falling Edge External R57 = 10 kΩ
    SW6 SW_INP6 PH3 Digital Input EXTI Interrupt Falling Edge External R56 = 10 kΩ

    Switch Debounce and Protection Components

    Button Series Resistor Debounce Capacitor TVS / ESD Protection
    SW1 R14 = 100 Ω C10 = 0.1 µF VS6
    SW2 R15 = 100 Ω C11 = 0.1 µF VS7
    SW3 R16 = 100 Ω C12 = 0.1 µF VS8
    SW4 R17 = 100 Ω C13 = 0.1 µF VS11
    SW5 R18 = 100 Ω C14 = 0.1 µF VS9
    SW6 R19 = 100 Ω C15 = 0.1 µF VS10

    Output / LED Summary

    Function MCU Output Pin(s) GPIO Configuration Controlled By
    Heartbeat LED PF2 Digital Output (Push-Pull) TIM13 Interrupt
    Output 1 PI12, PB1 Digital Output (Push-Pull) SW1
    Output 2 PI13, PB2 Digital Output (Push-Pull) SW2
    Output 3 PI14, PI15 Digital Output (Push-Pull) SW3
    Output 4 PF4 Digital Output (Push-Pull) SW4
    Output 5 PH5 Digital Output (Push-Pull) SW5
    Output 6 PK2 Digital Output (Push-Pull) SW6

    STM32 Development Log 2: Build fail

     If build fails again with the error:

     

    make: *** No rule to make target 'G:/03_NAL/2024_RC_amb/10_controls/STM32Cube/Repository/STM32Cube_FW_H7_V1.12.0/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal.c', needed by 'Drivers/STM32H7xx_HAL_Driver/stm32h7xx_hal.o'. Stop.

    make: *** Waiting for unfinished jobs....

    "make -j4 all" terminated with exit code 2. Build might be incomplete.


    16:48:08 Build Failed. 2 errors, 0 warnings. (took 34s.189ms)


     Probably becaluse it is still looking for repository. In properties, delete the linked resources looking for old repository files:

     


    Friday, June 19, 2026

    STM32 Development Log 1: Internet required 4 times= CubeIDE + CubeMX + Firmware H7 download + STLink upgrage

    1.  For STM32 cube IDE version 2.1.1, the stm32cubeMX has to be downloaded separately
    2.  stm32cubeMX is required to open ioc file.
    3. With  stm32cubeMX and ioc file of the board, the stm32halxx.c and stm32halxx.h files have to be generated.
    4. STM32 cube IDE version 2.1.1 will also ask to upgrade the firmware of STLINKV2 . This requires internet. 

    Importing project folder from older stm32cube into stm32 2.1.1

    1. File>Import>General>Existing projects into workspace>Next>""G:\03_NAL\2024_RC_amb\10_controls\controlPrograms\20260327_baseBoardTestCodes\BASE BOARD TEST CODES\Switches_LED Demo"" . 
    2. Ensure the project is ticked in the list below 
    3. Ensure "Copy projects into workspace" is ticked. Otherwise the original copy will be edited when i make changes in the ide.
    4. In the project explorer, right click and refresh, then project>clean, then build project. 
    5. Error: 16:15:55 **** Build of configuration Debug for project Switches_LED Demo ****
      make -j4 all
      make: *** No rule to make target 'G:/03_NAL/2024_RC_amb/10_controls/controlPrograms/STM32Cube/Repository/STM32Cube_FW_H7_V1.12.0/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal.c', needed by 'Drivers/STM32H7xx_HAL_Driver/stm32h7xx_hal.o'.  Stop.
      "make -j4 all" terminated with exit code 2. Build might be incomplete.
    6. The driver c and h files are not in the Drivers  directory at all. 
    7. Double click the ioc file in the project explorer. It will launch the stm32cubeMx software separately.  Enable:Copy only the necessary library files Generate peripheral initialization as a pair of '.c/.h' files per peripheral (optional)

    8.  
    9. Then download the required H7 package. 584 MB, only the firmware packages.  
    10.  After generating code, the folder is populated with driver c and h files.

    Tuesday, June 9, 2026

    My husband's wife

    1.  Finished in 2 days
    2. Reveals major relationships, roles and details later in the story to keep you in the dark as long as possible. So that i will keep reading to know what happens.
    3. Does not present facts upfront and makes you do detective work like Bleirot. 
    4. Some sentences on the observations of the society are good. 
    5. Relies too much on coincidence. But a good entertainer to spend time in a journey. I wasted productive time though.