Ignore:
Timestamp:
Jan 22, 2025, 11:40:26 AM (4 days ago)
Author:
Zed
Message:

FAN PWM control and TACHO signal measuring are working.

Location:
ctrl/firmware/Main/CubeMX
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • ctrl/firmware/Main/CubeMX/Core/Inc/main.h

    r62 r66  
    8282#define GSM_STATUS_Pin GPIO_PIN_13
    8383#define GSM_STATUS_GPIO_Port GPIOD
     84#define FAN_TACHO_Pin GPIO_PIN_6
     85#define FAN_TACHO_GPIO_Port GPIOC
     86#define FAN_PWM_Pin GPIO_PIN_7
     87#define FAN_PWM_GPIO_Port GPIOC
    8488#define SD_DETECT_Pin GPIO_PIN_8
    8589#define SD_DETECT_GPIO_Port GPIOA
  • ctrl/firmware/Main/CubeMX/Core/Inc/stm32h7xx_it.h

    r64 r66  
    5656void DMA1_Stream1_IRQHandler(void);
    5757void DMA1_Stream2_IRQHandler(void);
     58void TIM3_IRQHandler(void);
    5859void USART3_IRQHandler(void);
     60void TIM8_CC_IRQHandler(void);
    5961void SDMMC1_IRQHandler(void);
    6062void TIM7_IRQHandler(void);
  • ctrl/firmware/Main/CubeMX/Core/Src/app_threadx.c

    r65 r66  
    3333#include "gsm_thread.h"
    3434#include "gsm_rx_thread.h"
     35#include "fan_thread.h"
    3536
    3637/* USER CODE END Includes */
     
    4748#define GSM_THREAD_STACK_SIZE_BYTES                     (1024U)
    4849#define GSM_RX_THREAD_STACK_SIZE_BYTES          (1024U)
     50#define FAN_THREAD_STACK_SIZE_BYTES                     (512U)
    4951
    5052/* USER CODE END PD */
     
    6163TX_THREAD gsm_thread_ptr;
    6264TX_THREAD gsm_rx_thread_ptr;
     65TX_THREAD fan_thread_ptr;
    6366
    6467/* USER CODE END PV */
     
    8386  VOID *gsm_thread_pointer;
    8487  VOID *gsm_rx_thread_pointer;
     88  VOID *fan_thread_pointer;
    8589
    8690  /* USER CODE END App_ThreadX_MEM_POOL */
     
    97101
    98102
    99   // Allocate the stack for gsm thread
     103  // Allocate the stack for gsm send thread
    100104  ret = tx_byte_allocate(byte_pool, &gsm_thread_pointer, GSM_THREAD_STACK_SIZE_BYTES, TX_NO_WAIT);
    101105  if (ret != TX_SUCCESS) { printf("Cannot allocate bytes of memory!\n"); return ret; }
     
    105109  if (ret != TX_SUCCESS) { printf("Cannot create %s!\n", gsm_thread_name); return ret; }
    106110
    107   // Allocate the stack for gsm send thread
     111  // Allocate the stack for gsm rx thread
    108112  ret = tx_byte_allocate(byte_pool, &gsm_rx_thread_pointer, GSM_RX_THREAD_STACK_SIZE_BYTES, TX_NO_WAIT);
    109113  if (ret != TX_SUCCESS) { printf("Cannot allocate bytes of memory!\n"); return ret; }
    110114
    111115  char* gsm_rx_thread_name = "GSM RX Thread";
    112   ret = tx_thread_create(&gsm_rx_thread_ptr, gsm_rx_thread_name, gsmRxThread, 0x0001,   gsm_rx_thread_pointer, GSM_RX_THREAD_STACK_SIZE_BYTES, TX_MAX_PRIORITIES-1, TX_MAX_PRIORITIES-1, TX_NO_TIME_SLICE, TX_AUTO_START);
     116  ret = tx_thread_create(&gsm_rx_thread_ptr, gsm_rx_thread_name, gsmRxThread, 0x0001, gsm_rx_thread_pointer, GSM_RX_THREAD_STACK_SIZE_BYTES, TX_MAX_PRIORITIES-1, TX_MAX_PRIORITIES-1, TX_NO_TIME_SLICE, TX_AUTO_START);
    113117  if (ret != TX_SUCCESS) { printf("Cannot create %s!\n", gsm_rx_thread_name); return ret; }
    114118
     119  // Allocate the stack for fan control thread
     120  ret = tx_byte_allocate(byte_pool, &fan_thread_pointer, FAN_THREAD_STACK_SIZE_BYTES, TX_NO_WAIT);
     121  if (ret != TX_SUCCESS) { printf("Cannot allocate bytes of memory!\n"); return ret; }
     122
     123  char* fan_thread_name = "FAN Thread";
     124  ret = tx_thread_create(&fan_thread_ptr, fan_thread_name, fanThread, 0x0001, fan_thread_pointer, FAN_THREAD_STACK_SIZE_BYTES, TX_MAX_PRIORITIES-1, TX_MAX_PRIORITIES-1, TX_NO_TIME_SLICE, TX_AUTO_START);
     125  if (ret != TX_SUCCESS) { printf("Cannot create %s!\n", fan_thread_name); return ret; }
    115126
    116127
  • ctrl/firmware/Main/CubeMX/Core/Src/gpio.c

    r63 r66  
    8888
    8989  /*Configure GPIO pins : PC13 PC0 PC1 PC2
    90                            PC3 PC4 PC5 PC6
    91                            PC7 */
     90                           PC3 PC4 PC5 */
    9291  GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2
    93                           |GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6
    94                           |GPIO_PIN_7;
     92                          |GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5;
    9593  GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
    9694  GPIO_InitStruct.Pull = GPIO_NOPULL;
  • ctrl/firmware/Main/CubeMX/Core/Src/main.c

    r61 r66  
    2525#include "sdmmc.h"
    2626#include "spi.h"
     27#include "tim.h"
    2728#include "usart.h"
    2829#include "gpio.h"
     
    120121  MX_SDMMC1_SD_Init();
    121122  MX_USART3_UART_Init();
     123  MX_TIM3_Init();
     124  MX_TIM8_Init();
    122125  /* USER CODE BEGIN 2 */
    123126#undef MX_SDMMC1_SD_Init
  • ctrl/firmware/Main/CubeMX/Core/Src/stm32h7xx_it.c

    r65 r66  
    2525
    2626#include "gsm_rx_thread.h"
     27#include "fan_thread.h"
    2728
    2829/* USER CODE END Includes */
     
    6263extern DMA_HandleTypeDef hdma_spi4_tx;
    6364extern SPI_HandleTypeDef hspi4;
     65extern TIM_HandleTypeDef htim3;
     66extern TIM_HandleTypeDef htim8;
    6467extern DMA_HandleTypeDef hdma_usart3_rx;
    6568extern DMA_HandleTypeDef hdma_usart3_tx;
     
    212215
    213216/**
     217  * @brief This function handles TIM3 global interrupt.
     218  */
     219void TIM3_IRQHandler(void)
     220{
     221  /* USER CODE BEGIN TIM3_IRQn 0 */
     222
     223  /* USER CODE END TIM3_IRQn 0 */
     224  HAL_TIM_IRQHandler(&htim3);
     225  /* USER CODE BEGIN TIM3_IRQn 1 */
     226
     227  /* USER CODE END TIM3_IRQn 1 */
     228}
     229
     230/**
    214231  * @brief This function handles USART3 global interrupt.
    215232  */
     
    226243
    227244/**
     245  * @brief This function handles TIM8 capture compare interrupt.
     246  */
     247void TIM8_CC_IRQHandler(void)
     248{
     249  /* USER CODE BEGIN TIM8_CC_IRQn 0 */
     250
     251  /* USER CODE END TIM8_CC_IRQn 0 */
     252  HAL_TIM_IRQHandler(&htim8);
     253  /* USER CODE BEGIN TIM8_CC_IRQn 1 */
     254
     255  /* USER CODE END TIM8_CC_IRQn 1 */
     256}
     257
     258/**
    228259  * @brief This function handles SDMMC1 global interrupt.
    229260  */
     
    278309//------------------------------------------------------------------------------
    279310
    280 /*void HAL_UART_RxCpltCallback(UART_HandleTypeDef * huart)
    281 {
    282         //if (huart->Instance == USART3) gsmUnitSentData();
    283 }*/
     311void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim)
     312{
     313        if (htim->Instance == TIM8) pulseMeasured();
     314}
    284315
    285316//------------------------------------------------------------------------------
  • ctrl/firmware/Main/CubeMX/charger.ioc

    r65 r66  
    33CAD.pinconfig=
    44CAD.provider=
    5 CORTEX_M7.AccessPermission_S-Cortex_Memory_Protection_Unit_Region1_Settings_S=MPU_REGION_FULL_ACCESS
    6 CORTEX_M7.BaseAddress_S-Cortex_Memory_Protection_Unit_Region1_Settings_S=0x30000000
    75CORTEX_M7.CPU_DCache=Enabled
    86CORTEX_M7.CPU_ICache=Enabled
    9 CORTEX_M7.DisableExec_S-Cortex_Memory_Protection_Unit_Region1_Settings_S=MPU_INSTRUCTION_ACCESS_DISABLE
    10 CORTEX_M7.Enable_S-Cortex_Memory_Protection_Unit_Region1_Settings_S=MPU_REGION_ENABLE
    11 CORTEX_M7.IPParameters=default_mode_Activation,CPU_ICache,CPU_DCache,Enable_S-Cortex_Memory_Protection_Unit_Region1_Settings_S,BaseAddress_S-Cortex_Memory_Protection_Unit_Region1_Settings_S,Size_S-Cortex_Memory_Protection_Unit_Region1_Settings_S,AccessPermission_S-Cortex_Memory_Protection_Unit_Region1_Settings_S,DisableExec_S-Cortex_Memory_Protection_Unit_Region1_Settings_S,IsShareable_S-Cortex_Memory_Protection_Unit_Region1_Settings_S
    12 CORTEX_M7.IsShareable_S-Cortex_Memory_Protection_Unit_Region1_Settings_S=MPU_ACCESS_SHAREABLE
    13 CORTEX_M7.Size_S-Cortex_Memory_Protection_Unit_Region1_Settings_S=MPU_REGION_SIZE_1KB
     7CORTEX_M7.Enable_S-Cortex_Memory_Protection_Unit_Region1_Settings_S=__NULL
     8CORTEX_M7.IPParameters=default_mode_Activation,CPU_ICache,CPU_DCache,Enable_S-Cortex_Memory_Protection_Unit_Region1_Settings_S
    149CORTEX_M7.default_mode_Activation=1
    1510Dma.Request0=SPI4_TX
     
    8075Mcu.IP0=CORTEX_M7
    8176Mcu.IP1=DEBUG
    82 Mcu.IP10=USART3
     77Mcu.IP10=TIM3
     78Mcu.IP11=TIM8
     79Mcu.IP12=USART3
    8380Mcu.IP2=DMA
    8481Mcu.IP3=MEMORYMAP
     
    8986Mcu.IP8=SPI4
    9087Mcu.IP9=SYS
    91 Mcu.IPNb=11
     88Mcu.IPNb=13
    9289Mcu.Name=STM32H723ZETx
    9390Mcu.Package=LQFP144
     
    105102Mcu.Pin19=PD13
    106103Mcu.Pin2=PC15-OSC32_OUT
    107 Mcu.Pin20=PC8
    108 Mcu.Pin21=PC9
    109 Mcu.Pin22=PA8
    110 Mcu.Pin23=PA13(JTMS/SWDIO)
    111 Mcu.Pin24=PA14(JTCK/SWCLK)
    112 Mcu.Pin25=PC10
    113 Mcu.Pin26=PC11
    114 Mcu.Pin27=PC12
    115 Mcu.Pin28=PD2
    116 Mcu.Pin29=PD7
     104Mcu.Pin20=PC6
     105Mcu.Pin21=PC7
     106Mcu.Pin22=PC8
     107Mcu.Pin23=PC9
     108Mcu.Pin24=PA8
     109Mcu.Pin25=PA13(JTMS/SWDIO)
     110Mcu.Pin26=PA14(JTCK/SWCLK)
     111Mcu.Pin27=PC10
     112Mcu.Pin28=PC11
     113Mcu.Pin29=PC12
    117114Mcu.Pin3=PH0-OSC_IN
    118 Mcu.Pin30=PG9
    119 Mcu.Pin31=PG10
    120 Mcu.Pin32=PG11
    121 Mcu.Pin33=PG12
    122 Mcu.Pin34=PG13
    123 Mcu.Pin35=PG15
    124 Mcu.Pin36=VP_RTC_VS_RTC_Activate
    125 Mcu.Pin37=VP_SYS_VS_tim7
    126 Mcu.Pin38=VP_MEMORYMAP_VS_MEMORYMAP
    127 Mcu.Pin39=VP_STMicroelectronics.X-CUBE-AZRTOS-H7_VS_RTOSJjThreadX_6.4.0_3.3.0
     115Mcu.Pin30=PD2
     116Mcu.Pin31=PD7
     117Mcu.Pin32=PG9
     118Mcu.Pin33=PG10
     119Mcu.Pin34=PG11
     120Mcu.Pin35=PG12
     121Mcu.Pin36=PG13
     122Mcu.Pin37=PG15
     123Mcu.Pin38=VP_RTC_VS_RTC_Activate
     124Mcu.Pin39=VP_SYS_VS_tim7
    128125Mcu.Pin4=PH1-OSC_OUT
    129 Mcu.Pin40=VP_STMicroelectronics.X-CUBE-AZRTOS-H7_VS_FileOoSystemJjFileX_6.4.0_3.3.0
    130 Mcu.Pin41=VP_STMicroelectronics.X-CUBE-AZRTOS-H7_VS_FileOoSystemJjInterfaces_3.3.0_3.3.0
     126Mcu.Pin40=VP_TIM3_VS_ClockSourceINT
     127Mcu.Pin41=VP_TIM8_VS_ControllerModeReset
     128Mcu.Pin42=VP_TIM8_VS_ClockSourceINT
     129Mcu.Pin43=VP_MEMORYMAP_VS_MEMORYMAP
     130Mcu.Pin44=VP_STMicroelectronics.X-CUBE-AZRTOS-H7_VS_RTOSJjThreadX_6.4.0_3.3.0
     131Mcu.Pin45=VP_STMicroelectronics.X-CUBE-AZRTOS-H7_VS_FileOoSystemJjFileX_6.4.0_3.3.0
     132Mcu.Pin46=VP_STMicroelectronics.X-CUBE-AZRTOS-H7_VS_FileOoSystemJjInterfaces_3.3.0_3.3.0
    131133Mcu.Pin5=PF15
    132134Mcu.Pin6=PG0
     
    134136Mcu.Pin8=PE7
    135137Mcu.Pin9=PE11
    136 Mcu.PinsNb=42
     138Mcu.PinsNb=47
    137139Mcu.ThirdParty0=STMicroelectronics.X-CUBE-AZRTOS-H7.3.3.0
    138140Mcu.ThirdPartyNb=1
     
    159161NVIC.SavedSystickIrqHandlerGenerated=true
    160162NVIC.SysTick_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:true\:false
     163NVIC.TIM3_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:true\:true
    161164NVIC.TIM7_IRQn=true\:15\:0\:false\:false\:true\:false\:false\:true\:true
     165NVIC.TIM8_CC_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:true\:true
    162166NVIC.TimeBase=TIM7_IRQn
    163167NVIC.TimeBaseIP=TIM7
     
    183187PC15-OSC32_OUT.Mode=LSE-External-Oscillator
    184188PC15-OSC32_OUT.Signal=RCC_OSC32_OUT
     189PC6.GPIOParameters=GPIO_PuPd,GPIO_Label
     190PC6.GPIO_Label=FAN_TACHO
     191PC6.GPIO_PuPd=GPIO_PULLUP
     192PC6.Locked=true
     193PC6.Signal=S_TIM8_CH1
     194PC7.GPIOParameters=GPIO_Label
     195PC7.GPIO_Label=FAN_PWM
     196PC7.Locked=true
     197PC7.Signal=S_TIM3_CH2
    185198PC8.Locked=true
    186199PC8.Mode=SD_4_bits_Wide_bus
     
    315328ProjectManager.UAScriptBeforePath=
    316329ProjectManager.UnderRoot=true
    317 ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_DMA_Init-DMA-false-HAL-true,4-MX_RTC_Init-RTC-false-HAL-true,5-MX_SPI4_Init-SPI4-false-HAL-true,6-MX_SDMMC1_SD_Init-SDMMC1-false-HAL-true,7-MX_USART3_UART_Init-USART3-false-HAL-true,0-MX_CORTEX_M7_Init-CORTEX_M7-false-HAL-true
     330ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_DMA_Init-DMA-false-HAL-true,4-MX_RTC_Init-RTC-false-HAL-true,5-MX_SPI4_Init-SPI4-false-HAL-true,6-MX_SDMMC1_SD_Init-SDMMC1-false-HAL-true,7-MX_USART3_UART_Init-USART3-false-HAL-true,8-MX_TIM3_Init-TIM3-false-HAL-true,9-MX_TIM8_Init-TIM8-false-HAL-true,0-MX_CORTEX_M7_Init-CORTEX_M7-false-HAL-true
    318331RCC.ADCFreq_Value=166666666.66666666
    319332RCC.AHB12Freq_Value=100000000
     
    400413SDMMC1.HardwareFlowControl=SDMMC_HARDWARE_FLOW_CONTROL_ENABLE
    401414SDMMC1.IPParameters=ClockPowerSave,HardwareFlowControl
     415SH.S_TIM3_CH2.0=TIM3_CH2,PWM Generation2 CH2
     416SH.S_TIM3_CH2.ConfNb=1
     417SH.S_TIM8_CH1.0=TIM8_CH1,Input_Capture1_from_TI1
     418SH.S_TIM8_CH1.1=TIM8_CH1,TriggerSource_TI1FP1
     419SH.S_TIM8_CH1.ConfNb=2
    402420SPI4.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_4
    403421SPI4.CalculateBaudRate=6.25 MBits/s
     
    417435STMicroelectronics.X-CUBE-AZRTOS-H7.3.3.0.FileOoSystemJjInterfaces_Checked=true
    418436STMicroelectronics.X-CUBE-AZRTOS-H7.3.3.0.FileXCcFileOoSystemJjFileXJjCore=true
    419 STMicroelectronics.X-CUBE-AZRTOS-H7.3.3.0.IPParameters=TX_APP_MEM_POOL_SIZE,FX_APP_MEM_POOL_SIZE,TX_APP_GENERATE_INIT_CODE,TX_APP_CREATION,TX_ENABLE_STACK_CHECKING,TX_NO_FILEX_POINTER,TX_LOW_POWER,FX_ENABLE_EXFAT,FX_ENABLE_FAULT_TOLERANT,FX_FAULT_TOLERANT,FX_FAULT_TOLERANT_DATA,FX_DRIVER_SD_INIT,TX_TIMER_TICKS_PER_SECOND,ThreadXCcRTOSJjThreadXJjCore,ThreadXCcRTOSJjThreadXJjLowOoPowerOosupport,FileXCcFileOoSystemJjFileXJjCore,InterfacesCcFileOoSystemJjFileXOoSDOointerface,TX_APP_MSG_QUEUE_CREATION,TX_MSG_QUEUE_NAME,TX_NB_MSG
     437STMicroelectronics.X-CUBE-AZRTOS-H7.3.3.0.IPParameters=TX_APP_MEM_POOL_SIZE,FX_APP_MEM_POOL_SIZE,TX_APP_GENERATE_INIT_CODE,TX_APP_CREATION,TX_ENABLE_STACK_CHECKING,TX_NO_FILEX_POINTER,TX_LOW_POWER,FX_ENABLE_EXFAT,FX_ENABLE_FAULT_TOLERANT,FX_FAULT_TOLERANT,FX_FAULT_TOLERANT_DATA,FX_DRIVER_SD_INIT,TX_TIMER_TICKS_PER_SECOND,TX_APP_MSG_QUEUE_CREATION,TX_MSG_QUEUE_NAME,TX_NB_MSG,ThreadXCcRTOSJjThreadXJjCore,ThreadXCcRTOSJjThreadXJjLowOoPowerOosupport,FileXCcFileOoSystemJjFileXJjCore,InterfacesCcFileOoSystemJjFileXOoSDOointerface
    420438STMicroelectronics.X-CUBE-AZRTOS-H7.3.3.0.InterfacesCcFileOoSystemJjFileXOoSDOointerface=true
    421439STMicroelectronics.X-CUBE-AZRTOS-H7.3.3.0.RTOSJjThreadX_Checked=true
     
    434452STMicroelectronics.X-CUBE-AZRTOS-H7.3.3.0_IsAnAzureRtosMw=true
    435453STMicroelectronics.X-CUBE-AZRTOS-H7.3.3.0_SwParameter=InterfacesCcFileOoSystemJjFileXOoSDOointerface\:true;ThreadXCcRTOSJjThreadXJjLowOoPowerOosupport\:true;FileXCcFileOoSystemJjFileXJjCore\:true;ThreadXCcRTOSJjThreadXJjCore\:true;
     454TIM3.AutoReloadPreload=TIM_AUTORELOAD_PRELOAD_ENABLE
     455TIM3.Channel-PWM\ Generation2\ CH2=TIM_CHANNEL_2
     456TIM3.IPParameters=AutoReloadPreload,Channel-PWM Generation2 CH2,Prescaler,Period,Pulse-PWM Generation2 CH2,OCPolarity_2
     457TIM3.OCPolarity_2=TIM_OCPOLARITY_LOW
     458TIM3.Period=1000
     459TIM3.Prescaler=3
     460TIM3.Pulse-PWM\ Generation2\ CH2=200
     461TIM8.AutoReloadPreload=TIM_AUTORELOAD_PRELOAD_ENABLE
     462TIM8.Channel-Input_Capture1_from_TI1=TIM_CHANNEL_1
     463TIM8.ICPolarity_CH1=TIM_INPUTCHANNELPOLARITY_BOTHEDGE
     464TIM8.IPParameters=Channel-Input_Capture1_from_TI1,ICPolarity_CH1,Prescaler,AutoReloadPreload,Period
     465TIM8.Period=65536 - 1
     466TIM8.Prescaler=32 - 1
    436467USART3.DMADisableonRxErrorParam=ADVFEATURE_DMA_DISABLEONRXERROR
    437468USART3.IPParameters=VirtualMode-Asynchronous,SwapParam,DMADisableonRxErrorParam
     
    450481VP_SYS_VS_tim7.Mode=TIM7
    451482VP_SYS_VS_tim7.Signal=SYS_VS_tim7
     483VP_TIM3_VS_ClockSourceINT.Mode=Internal
     484VP_TIM3_VS_ClockSourceINT.Signal=TIM3_VS_ClockSourceINT
     485VP_TIM8_VS_ClockSourceINT.Mode=Internal
     486VP_TIM8_VS_ClockSourceINT.Signal=TIM8_VS_ClockSourceINT
     487VP_TIM8_VS_ControllerModeReset.Mode=Reset Mode
     488VP_TIM8_VS_ControllerModeReset.Signal=TIM8_VS_ControllerModeReset
    452489board=custom
Note: See TracChangeset for help on using the changeset viewer.