From bb04b8314a826328e5a4ca02e532f64efc4eba96 Mon Sep 17 00:00:00 2001 From: Lizongdi <1210855344@qq.com> Date: Wed, 1 Jul 2026 10:49:53 +0800 Subject: [PATCH] =?UTF-8?q?cubemx=E9=85=8D=E7=BD=AE=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Core/Src/fdcan.c | 2 +- Core/Src/main.c | 11 +++++++++++ Core/Src/usart.c | 8 ++++---- LWIP/Target/ethernetif.c | 5 ++++- robot | 2 +- robot_old.ioc | 24 ++++++++++++++++-------- 6 files changed, 37 insertions(+), 15 deletions(-) diff --git a/Core/Src/fdcan.c b/Core/Src/fdcan.c index e4259e6..dd00384 100644 --- a/Core/Src/fdcan.c +++ b/Core/Src/fdcan.c @@ -95,7 +95,7 @@ void MX_FDCAN2_Init(void) hfdcan2.Init.NominalPrescaler = 20; hfdcan2.Init.NominalSyncJumpWidth = 1; hfdcan2.Init.NominalTimeSeg1 = 5; - hfdcan2.Init.NominalTimeSeg2 = 1; + hfdcan2.Init.NominalTimeSeg2 = 2; hfdcan2.Init.DataPrescaler = 1; hfdcan2.Init.DataSyncJumpWidth = 1; hfdcan2.Init.DataTimeSeg1 = 1; diff --git a/Core/Src/main.c b/Core/Src/main.c index dc984e3..4d9aec8 100644 --- a/Core/Src/main.c +++ b/Core/Src/main.c @@ -252,6 +252,17 @@ void MPU_Config(void) MPU_InitStruct.IsShareable = MPU_ACCESS_SHAREABLE; MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE; + HAL_MPU_ConfigRegion(&MPU_InitStruct); + + /** Initializes and configures the Region and the memory to be protected + */ + MPU_InitStruct.Number = MPU_REGION_NUMBER3; + MPU_InitStruct.BaseAddress = 0x24000000 ; + MPU_InitStruct.Size = MPU_REGION_SIZE_512KB; + MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0; + MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_DISABLE; + MPU_InitStruct.IsShareable = MPU_ACCESS_NOT_SHAREABLE; + HAL_MPU_ConfigRegion(&MPU_InitStruct); /* Enables the MPU */ HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT); diff --git a/Core/Src/usart.c b/Core/Src/usart.c index 14b78ee..22187ce 100644 --- a/Core/Src/usart.c +++ b/Core/Src/usart.c @@ -324,10 +324,10 @@ void MX_USART3_UART_Init(void) /* USER CODE END USART3_Init 1 */ huart3.Instance = USART3; - huart3.Init.BaudRate = 921600; - huart3.Init.WordLength = UART_WORDLENGTH_9B; + huart3.Init.BaudRate = 115200; + huart3.Init.WordLength = UART_WORDLENGTH_8B; huart3.Init.StopBits = UART_STOPBITS_1; - huart3.Init.Parity = UART_PARITY_EVEN; + huart3.Init.Parity = UART_PARITY_NONE; huart3.Init.Mode = UART_MODE_TX_RX; huart3.Init.HwFlowCtl = UART_HWCONTROL_NONE; huart3.Init.OverSampling = UART_OVERSAMPLING_16; @@ -348,7 +348,7 @@ void MX_USART3_UART_Init(void) { Error_Handler(); } - if (HAL_UARTEx_EnableFifoMode(&huart3) != HAL_OK) + if (HAL_UARTEx_DisableFifoMode(&huart3) != HAL_OK) { Error_Handler(); } diff --git a/LWIP/Target/ethernetif.c b/LWIP/Target/ethernetif.c index a8294ea..ec1d435 100644 --- a/LWIP/Target/ethernetif.c +++ b/LWIP/Target/ethernetif.c @@ -225,7 +225,10 @@ static void low_level_init(struct netif *netif) #endif /* LWIP_ARP */ /* USER CODE BEGIN PHY_PRE_CONFIG */ - + HAL_GPIO_WritePin(ETH_RST_GPIO_Port,ETH_RST_Pin,GPIO_PIN_RESET); + HAL_Delay(1000); + HAL_GPIO_WritePin(ETH_RST_GPIO_Port,ETH_RST_Pin,GPIO_PIN_SET); + HAL_Delay(1000); /* USER CODE END PHY_PRE_CONFIG */ /* Set PHY IO functions */ LAN8742_RegisterBusIO(&LAN8742, &LAN8742_IOCtx); diff --git a/robot b/robot index 35274be..8866fc3 160000 --- a/robot +++ b/robot @@ -1 +1 @@ -Subproject commit 35274be076ac624c61342f01ac755b5ddd324578 +Subproject commit 8866fc3e509adecbb1b824c649bb8026c5000240 diff --git a/robot_old.ioc b/robot_old.ioc index 80a92dd..42df7b6 100644 --- a/robot_old.ioc +++ b/robot_old.ioc @@ -14,18 +14,24 @@ CAD.provider= CORTEX_M7.AccessPermission-Cortex_Memory_Protection_Unit_Region0_Settings=MPU_REGION_NO_ACCESS CORTEX_M7.AccessPermission-Cortex_Memory_Protection_Unit_Region1_Settings=MPU_REGION_FULL_ACCESS CORTEX_M7.AccessPermission-Cortex_Memory_Protection_Unit_Region2_Settings=MPU_REGION_FULL_ACCESS +CORTEX_M7.AccessPermission-Cortex_Memory_Protection_Unit_Region3_Settings=MPU_REGION_FULL_ACCESS CORTEX_M7.BaseAddress-Cortex_Memory_Protection_Unit_Region0_Settings=0 CORTEX_M7.BaseAddress-Cortex_Memory_Protection_Unit_Region1_Settings=0x30000000 CORTEX_M7.BaseAddress-Cortex_Memory_Protection_Unit_Region2_Settings=0x30004000 +CORTEX_M7.BaseAddress-Cortex_Memory_Protection_Unit_Region3_Settings=0x24000000 CORTEX_M7.CPU_DCache=Enabled CORTEX_M7.CPU_ICache=Enabled +CORTEX_M7.DisableExec-Cortex_Memory_Protection_Unit_Region3_Settings=MPU_INSTRUCTION_ACCESS_DISABLE CORTEX_M7.Enable-Cortex_Memory_Protection_Unit_Region0_Settings=MPU_REGION_ENABLE CORTEX_M7.Enable-Cortex_Memory_Protection_Unit_Region1_Settings=MPU_REGION_ENABLE CORTEX_M7.Enable-Cortex_Memory_Protection_Unit_Region2_Settings=MPU_REGION_ENABLE -CORTEX_M7.IPParameters=MPU_Control,CPU_ICache,CPU_DCache,Enable-Cortex_Memory_Protection_Unit_Region2_Settings,Enable-Cortex_Memory_Protection_Unit_Region0_Settings,BaseAddress-Cortex_Memory_Protection_Unit_Region0_Settings,Size-Cortex_Memory_Protection_Unit_Region0_Settings,IsBufferable-Cortex_Memory_Protection_Unit_Region0_Settings,AccessPermission-Cortex_Memory_Protection_Unit_Region0_Settings,Enable-Cortex_Memory_Protection_Unit_Region1_Settings,BaseAddress-Cortex_Memory_Protection_Unit_Region1_Settings,Size-Cortex_Memory_Protection_Unit_Region1_Settings,AccessPermission-Cortex_Memory_Protection_Unit_Region1_Settings,IsCacheable-Cortex_Memory_Protection_Unit_Region1_Settings,IsShareable-Cortex_Memory_Protection_Unit_Region1_Settings,TypeExtField-Cortex_Memory_Protection_Unit_Region1_Settings,IsShareable-Cortex_Memory_Protection_Unit_Region0_Settings,SubRegionDisable-Cortex_Memory_Protection_Unit_Region0_Settings,IsBufferable-Cortex_Memory_Protection_Unit_Region1_Settings,TypeExtField-Cortex_Memory_Protection_Unit_Region0_Settings,BaseAddress-Cortex_Memory_Protection_Unit_Region2_Settings,Size-Cortex_Memory_Protection_Unit_Region2_Settings,TypeExtField-Cortex_Memory_Protection_Unit_Region2_Settings,AccessPermission-Cortex_Memory_Protection_Unit_Region2_Settings,IsShareable-Cortex_Memory_Protection_Unit_Region2_Settings +CORTEX_M7.Enable-Cortex_Memory_Protection_Unit_Region3_Settings=MPU_REGION_ENABLE +CORTEX_M7.IPParameters=MPU_Control,CPU_ICache,CPU_DCache,Enable-Cortex_Memory_Protection_Unit_Region2_Settings,Enable-Cortex_Memory_Protection_Unit_Region0_Settings,BaseAddress-Cortex_Memory_Protection_Unit_Region0_Settings,Size-Cortex_Memory_Protection_Unit_Region0_Settings,IsBufferable-Cortex_Memory_Protection_Unit_Region0_Settings,AccessPermission-Cortex_Memory_Protection_Unit_Region0_Settings,Enable-Cortex_Memory_Protection_Unit_Region1_Settings,BaseAddress-Cortex_Memory_Protection_Unit_Region1_Settings,Size-Cortex_Memory_Protection_Unit_Region1_Settings,AccessPermission-Cortex_Memory_Protection_Unit_Region1_Settings,IsCacheable-Cortex_Memory_Protection_Unit_Region1_Settings,IsShareable-Cortex_Memory_Protection_Unit_Region1_Settings,TypeExtField-Cortex_Memory_Protection_Unit_Region1_Settings,IsShareable-Cortex_Memory_Protection_Unit_Region0_Settings,SubRegionDisable-Cortex_Memory_Protection_Unit_Region0_Settings,IsBufferable-Cortex_Memory_Protection_Unit_Region1_Settings,TypeExtField-Cortex_Memory_Protection_Unit_Region0_Settings,BaseAddress-Cortex_Memory_Protection_Unit_Region2_Settings,Size-Cortex_Memory_Protection_Unit_Region2_Settings,TypeExtField-Cortex_Memory_Protection_Unit_Region2_Settings,AccessPermission-Cortex_Memory_Protection_Unit_Region2_Settings,IsShareable-Cortex_Memory_Protection_Unit_Region2_Settings,Enable-Cortex_Memory_Protection_Unit_Region3_Settings,BaseAddress-Cortex_Memory_Protection_Unit_Region3_Settings,Size-Cortex_Memory_Protection_Unit_Region3_Settings,AccessPermission-Cortex_Memory_Protection_Unit_Region3_Settings,DisableExec-Cortex_Memory_Protection_Unit_Region3_Settings,IsCacheable-Cortex_Memory_Protection_Unit_Region3_Settings,IsBufferable-Cortex_Memory_Protection_Unit_Region3_Settings CORTEX_M7.IsBufferable-Cortex_Memory_Protection_Unit_Region0_Settings=MPU_ACCESS_NOT_BUFFERABLE CORTEX_M7.IsBufferable-Cortex_Memory_Protection_Unit_Region1_Settings=MPU_ACCESS_BUFFERABLE +CORTEX_M7.IsBufferable-Cortex_Memory_Protection_Unit_Region3_Settings=MPU_ACCESS_NOT_BUFFERABLE CORTEX_M7.IsCacheable-Cortex_Memory_Protection_Unit_Region1_Settings=MPU_ACCESS_NOT_CACHEABLE +CORTEX_M7.IsCacheable-Cortex_Memory_Protection_Unit_Region3_Settings=MPU_ACCESS_NOT_CACHEABLE CORTEX_M7.IsShareable-Cortex_Memory_Protection_Unit_Region0_Settings=MPU_ACCESS_SHAREABLE CORTEX_M7.IsShareable-Cortex_Memory_Protection_Unit_Region1_Settings=MPU_ACCESS_NOT_SHAREABLE CORTEX_M7.IsShareable-Cortex_Memory_Protection_Unit_Region2_Settings=MPU_ACCESS_SHAREABLE @@ -33,6 +39,7 @@ CORTEX_M7.MPU_Control=MPU_PRIVILEGED_DEFAULT CORTEX_M7.Size-Cortex_Memory_Protection_Unit_Region0_Settings=MPU_REGION_SIZE_4GB CORTEX_M7.Size-Cortex_Memory_Protection_Unit_Region1_Settings=MPU_REGION_SIZE_1KB CORTEX_M7.Size-Cortex_Memory_Protection_Unit_Region2_Settings=MPU_REGION_SIZE_16KB +CORTEX_M7.Size-Cortex_Memory_Protection_Unit_Region3_Settings=MPU_REGION_SIZE_512KB CORTEX_M7.SubRegionDisable-Cortex_Memory_Protection_Unit_Region0_Settings=0x87 CORTEX_M7.TypeExtField-Cortex_Memory_Protection_Unit_Region0_Settings=MPU_TEX_LEVEL0 CORTEX_M7.TypeExtField-Cortex_Memory_Protection_Unit_Region1_Settings=MPU_TEX_LEVEL0 @@ -192,13 +199,14 @@ FDCAN1.NominalTimeSeg1=5 FDCAN1.NominalTimeSeg2=2 FDCAN1.RxFifo0ElmtsNbr=32 FDCAN1.TxFifoQueueElmtsNbr=32 -FDCAN2.CalculateBaudRateNominal=285714 -FDCAN2.CalculateTimeBitNominal=3500 +FDCAN2.CalculateBaudRateNominal=250000 +FDCAN2.CalculateTimeBitNominal=4000 FDCAN2.CalculateTimeQuantumNominal=500.0 -FDCAN2.IPParameters=NominalPrescaler,NominalTimeSeg1,RxFifo0ElmtsNbr,TxFifoQueueElmtsNbr,CalculateTimeQuantumNominal,CalculateTimeBitNominal,CalculateBaudRateNominal,MessageRAMOffset +FDCAN2.IPParameters=NominalPrescaler,NominalTimeSeg1,RxFifo0ElmtsNbr,TxFifoQueueElmtsNbr,CalculateTimeQuantumNominal,CalculateTimeBitNominal,CalculateBaudRateNominal,MessageRAMOffset,NominalTimeSeg2 FDCAN2.MessageRAMOffset=0x500 FDCAN2.NominalPrescaler=20 FDCAN2.NominalTimeSeg1=5 +FDCAN2.NominalTimeSeg2=2 FDCAN2.RxFifo0ElmtsNbr=32 FDCAN2.TxFifoQueueElmtsNbr=32 File.Version=6 @@ -886,14 +894,14 @@ USART2.DMADisableonRxErrorParam=ADVFEATURE_DMA_DISABLEONRXERROR USART2.IPParameters=VirtualMode-Asynchronous,OverrunDisableParam,DMADisableonRxErrorParam USART2.OverrunDisableParam=ADVFEATURE_OVERRUN_DISABLE USART2.VirtualMode-Asynchronous=VM_ASYNC -USART3.BaudRate=921600 +USART3.BaudRate=115200 USART3.DMADisableonRxErrorParam=ADVFEATURE_DMA_DISABLEONRXERROR -USART3.FIFOMode=FIFOMODE_ENABLE +USART3.FIFOMode=FIFOMODE_DISABLE USART3.IPParameters=VirtualMode-Asynchronous,DMADisableonRxErrorParam,OverrunDisableParam,FIFOMode,BaudRate,WordLength,Parity USART3.OverrunDisableParam=ADVFEATURE_OVERRUN_DISABLE -USART3.Parity=PARITY_EVEN +USART3.Parity=PARITY_NONE USART3.VirtualMode-Asynchronous=VM_ASYNC -USART3.WordLength=WORDLENGTH_9B +USART3.WordLength=WORDLENGTH_8B USART6.BaudRate=19200 USART6.DMADisableonRxErrorParam=ADVFEATURE_DMA_ENABLEONRXERROR USART6.FIFOMode=FIFOMODE_ENABLE