diff --git a/Core/Inc/main.h b/Core/Inc/main.h index a5f6ce9..cb779f7 100644 --- a/Core/Inc/main.h +++ b/Core/Inc/main.h @@ -261,8 +261,8 @@ void Error_Handler(void); #define FMC_D15_GPIO_Port GPIOD #define ARDUINO_A1_Pin GPIO_PIN_10 #define ARDUINO_A1_GPIO_Port GPIOF -#define ARDUINO_A2_Pin GPIO_PIN_9 -#define ARDUINO_A2_GPIO_Port GPIOF +#define OUT1_Pin GPIO_PIN_9 +#define OUT1_GPIO_Port GPIOF #define ARDUINO_A3_Pin GPIO_PIN_8 #define ARDUINO_A3_GPIO_Port GPIOF #define FMC_SDCKE0_Pin GPIO_PIN_3 diff --git a/Core/Inc/stm32f7xx_it.h b/Core/Inc/stm32f7xx_it.h index a173c23..0718c57 100644 --- a/Core/Inc/stm32f7xx_it.h +++ b/Core/Inc/stm32f7xx_it.h @@ -56,6 +56,7 @@ void DebugMon_Handler(void); void PendSV_Handler(void); void SysTick_Handler(void); void ADC_IRQHandler(void); +void TIM1_CC_IRQHandler(void); void TIM6_DAC_IRQHandler(void); void LTDC_IRQHandler(void); void DMA2D_IRQHandler(void); diff --git a/Core/Src/main.c b/Core/Src/main.c index ba4c304..d2a91c0 100644 --- a/Core/Src/main.c +++ b/Core/Src/main.c @@ -254,7 +254,7 @@ static void MX_ADC3_Init(void) /** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time. */ - sConfig.Channel = ADC_CHANNEL_4; + sConfig.Channel = ADC_CHANNEL_0; sConfig.Rank = ADC_REGULAR_RANK_1; sConfig.SamplingTime = ADC_SAMPLETIME_3CYCLES; if (HAL_ADC_ConfigChannel(&hadc3, &sConfig) != HAL_OK) @@ -595,8 +595,6 @@ static void MX_TIM1_Init(void) TIM_ClockConfigTypeDef sClockSourceConfig = {0}; TIM_MasterConfigTypeDef sMasterConfig = {0}; - TIM_OC_InitTypeDef sConfigOC = {0}; - TIM_BreakDeadTimeConfigTypeDef sBreakDeadTimeConfig = {0}; /* USER CODE BEGIN TIM1_Init 1 */ @@ -617,10 +615,6 @@ static void MX_TIM1_Init(void) { Error_Handler(); } - if (HAL_TIM_PWM_Init(&htim1) != HAL_OK) - { - Error_Handler(); - } sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; sMasterConfig.MasterOutputTrigger2 = TIM_TRGO2_RESET; sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; @@ -628,36 +622,9 @@ static void MX_TIM1_Init(void) { Error_Handler(); } - sConfigOC.OCMode = TIM_OCMODE_PWM1; - sConfigOC.Pulse = 0; - sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH; - sConfigOC.OCNPolarity = TIM_OCNPOLARITY_HIGH; - sConfigOC.OCFastMode = TIM_OCFAST_DISABLE; - sConfigOC.OCIdleState = TIM_OCIDLESTATE_RESET; - sConfigOC.OCNIdleState = TIM_OCNIDLESTATE_RESET; - if (HAL_TIM_PWM_ConfigChannel(&htim1, &sConfigOC, TIM_CHANNEL_1) != HAL_OK) - { - Error_Handler(); - } - sBreakDeadTimeConfig.OffStateRunMode = TIM_OSSR_DISABLE; - sBreakDeadTimeConfig.OffStateIDLEMode = TIM_OSSI_DISABLE; - sBreakDeadTimeConfig.LockLevel = TIM_LOCKLEVEL_OFF; - sBreakDeadTimeConfig.DeadTime = 0; - sBreakDeadTimeConfig.BreakState = TIM_BREAK_DISABLE; - sBreakDeadTimeConfig.BreakPolarity = TIM_BREAKPOLARITY_HIGH; - sBreakDeadTimeConfig.BreakFilter = 0; - sBreakDeadTimeConfig.Break2State = TIM_BREAK2_DISABLE; - sBreakDeadTimeConfig.Break2Polarity = TIM_BREAK2POLARITY_HIGH; - sBreakDeadTimeConfig.Break2Filter = 0; - sBreakDeadTimeConfig.AutomaticOutput = TIM_AUTOMATICOUTPUT_DISABLE; - if (HAL_TIMEx_ConfigBreakDeadTime(&htim1, &sBreakDeadTimeConfig) != HAL_OK) - { - Error_Handler(); - } /* USER CODE BEGIN TIM1_Init 2 */ /* USER CODE END TIM1_Init 2 */ - HAL_TIM_MspPostInit(&htim1); } @@ -1049,6 +1016,9 @@ static void MX_GPIO_Init(void) /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(GPIOG, ARDUINO_D4_Pin|ARDUINO_D2_Pin|EXT_RST_Pin, GPIO_PIN_RESET); + /*Configure GPIO pin Output Level */ + HAL_GPIO_WritePin(OUT1_GPIO_Port, OUT1_Pin, GPIO_PIN_RESET); + /*Configure GPIO pin : OTG_HS_OverCurrent_Pin */ GPIO_InitStruct.Pin = OTG_HS_OverCurrent_Pin; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; @@ -1268,6 +1238,13 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); + /*Configure GPIO pin : OUT1_Pin */ + GPIO_InitStruct.Pin = OUT1_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + HAL_GPIO_Init(OUT1_GPIO_Port, &GPIO_InitStruct); + /*Configure GPIO pins : ULPI_STP_Pin ULPI_DIR_Pin */ GPIO_InitStruct.Pin = ULPI_STP_Pin|ULPI_DIR_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; diff --git a/Core/Src/stm32f7xx_hal_msp.c b/Core/Src/stm32f7xx_hal_msp.c index 4e8e232..e763e30 100644 --- a/Core/Src/stm32f7xx_hal_msp.c +++ b/Core/Src/stm32f7xx_hal_msp.c @@ -59,7 +59,7 @@ /* USER CODE END 0 */ void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim); - /** + /** * Initializes the Global MSP. */ void HAL_MspInit(void) @@ -101,12 +101,10 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) PF7 ------> ADC3_IN5 PF6 ------> ADC3_IN4 PF10 ------> ADC3_IN8 - PF9 ------> ADC3_IN7 PF8 ------> ADC3_IN6 PA0/WKUP ------> ADC3_IN0 */ - GPIO_InitStruct.Pin = ARDUINO_A4_Pin|ARDUINO_A5_Pin|ARDUINO_A1_Pin|ARDUINO_A2_Pin - |ARDUINO_A3_Pin; + GPIO_InitStruct.Pin = ARDUINO_A4_Pin|ARDUINO_A5_Pin|ARDUINO_A1_Pin|ARDUINO_A3_Pin; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); @@ -146,12 +144,10 @@ void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc) PF7 ------> ADC3_IN5 PF6 ------> ADC3_IN4 PF10 ------> ADC3_IN8 - PF9 ------> ADC3_IN7 PF8 ------> ADC3_IN6 PA0/WKUP ------> ADC3_IN0 */ - HAL_GPIO_DeInit(GPIOF, ARDUINO_A4_Pin|ARDUINO_A5_Pin|ARDUINO_A1_Pin|ARDUINO_A2_Pin - |ARDUINO_A3_Pin); + HAL_GPIO_DeInit(GPIOF, ARDUINO_A4_Pin|ARDUINO_A5_Pin|ARDUINO_A1_Pin|ARDUINO_A3_Pin); HAL_GPIO_DeInit(ARDUINO_A0_GPIO_Port, ARDUINO_A0_Pin); @@ -661,6 +657,7 @@ void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) */ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base) { + GPIO_InitTypeDef GPIO_InitStruct = {0}; if(htim_base->Instance==TIM1) { /* USER CODE BEGIN TIM1_MspInit 0 */ @@ -668,6 +665,21 @@ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base) /* USER CODE END TIM1_MspInit 0 */ /* Peripheral clock enable */ __HAL_RCC_TIM1_CLK_ENABLE(); + + __HAL_RCC_GPIOA_CLK_ENABLE(); + /**TIM1 GPIO Configuration + PA8 ------> TIM1_CH1 + */ + GPIO_InitStruct.Pin = ARDUINO_PWM_D10_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF1_TIM1; + HAL_GPIO_Init(ARDUINO_PWM_D10_GPIO_Port, &GPIO_InitStruct); + + /* TIM1 interrupt Init */ + HAL_NVIC_SetPriority(TIM1_CC_IRQn, 0, 0); + HAL_NVIC_EnableIRQ(TIM1_CC_IRQn); /* USER CODE BEGIN TIM1_MspInit 1 */ /* USER CODE END TIM1_MspInit 1 */ @@ -744,32 +756,11 @@ void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef* htim_pwm) void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim) { GPIO_InitTypeDef GPIO_InitStruct = {0}; - if(htim->Instance==TIM1) - { - /* USER CODE BEGIN TIM1_MspPostInit 0 */ - - /* USER CODE END TIM1_MspPostInit 0 */ - __HAL_RCC_GPIOA_CLK_ENABLE(); - /**TIM1 GPIO Configuration - PA8 ------> TIM1_CH1 - */ - GPIO_InitStruct.Pin = ARDUINO_PWM_D10_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.Alternate = GPIO_AF1_TIM1; - HAL_GPIO_Init(ARDUINO_PWM_D10_GPIO_Port, &GPIO_InitStruct); - - /* USER CODE BEGIN TIM1_MspPostInit 1 */ - - /* USER CODE END TIM1_MspPostInit 1 */ - } - else if(htim->Instance==TIM2) + if(htim->Instance==TIM2) { /* USER CODE BEGIN TIM2_MspPostInit 0 */ /* USER CODE END TIM2_MspPostInit 0 */ - __HAL_RCC_GPIOA_CLK_ENABLE(); /**TIM2 GPIO Configuration PA15 ------> TIM2_CH1 @@ -865,6 +856,14 @@ void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base) /* USER CODE END TIM1_MspDeInit 0 */ /* Peripheral clock disable */ __HAL_RCC_TIM1_CLK_DISABLE(); + + /**TIM1 GPIO Configuration + PA8 ------> TIM1_CH1 + */ + HAL_GPIO_DeInit(ARDUINO_PWM_D10_GPIO_Port, ARDUINO_PWM_D10_Pin); + + /* TIM1 interrupt DeInit */ + HAL_NVIC_DisableIRQ(TIM1_CC_IRQn); /* USER CODE BEGIN TIM1_MspDeInit 1 */ /* USER CODE END TIM1_MspDeInit 1 */ diff --git a/Core/Src/stm32f7xx_it.c b/Core/Src/stm32f7xx_it.c index 54f847d..128ae24 100644 --- a/Core/Src/stm32f7xx_it.c +++ b/Core/Src/stm32f7xx_it.c @@ -58,6 +58,7 @@ extern ADC_HandleTypeDef hadc3; extern DMA2D_HandleTypeDef hdma2d; extern LTDC_HandleTypeDef hltdc; +extern TIM_HandleTypeDef htim1; extern TIM_HandleTypeDef htim6; /* USER CODE BEGIN EV */ @@ -216,6 +217,20 @@ void ADC_IRQHandler(void) /* USER CODE END ADC_IRQn 1 */ } +/** + * @brief This function handles TIM1 capture compare interrupt. + */ +void TIM1_CC_IRQHandler(void) +{ + /* USER CODE BEGIN TIM1_CC_IRQn 0 */ + + /* USER CODE END TIM1_CC_IRQn 0 */ + HAL_TIM_IRQHandler(&htim1); + /* USER CODE BEGIN TIM1_CC_IRQn 1 */ + + /* USER CODE END TIM1_CC_IRQn 1 */ +} + /** * @brief This function handles TIM6 global interrupt, DAC1 and DAC2 underrun error interrupts. */ diff --git a/RealtimeOscilloscope.ioc b/RealtimeOscilloscope.ioc index 2d1ffbe..b400ac1 100644 --- a/RealtimeOscilloscope.ioc +++ b/RealtimeOscilloscope.ioc @@ -1,13 +1,7 @@ #MicroXplorer Configuration settings - do not modify -ADC3.Channel=ADC_CHANNEL_7 -ADC3.Channel-0\#ChannelRegularConversion=ADC_CHANNEL_4 +ADC3.Channel-0\#ChannelRegularConversion=ADC_CHANNEL_0 ADC3.Channel-IN0=ADC_CHANNEL_0 -ADC3.Channel-IN4=ADC_CHANNEL_4 -ADC3.Channel-IN5=ADC_CHANNEL_5 -ADC3.Channel-IN6=ADC_CHANNEL_6 -ADC3.Channel-IN7=ADC_CHANNEL_7 -ADC3.Channel-IN8=ADC_CHANNEL_8 -ADC3.IPParameters=Channel-IN6,Channel-IN7,Channel-IN0,Channel-IN8,Channel,Channel-IN5,Channel-0\#ChannelRegularConversion,Channel-IN4 +ADC3.IPParameters=Channel-IN0,Channel-0\#ChannelRegularConversion FMC.CASLatency1=FMC_SDRAM_CAS_LATENCY_3 FMC.ExitSelfRefreshDelay1=7 FMC.IPParameters=CASLatency1,SDClockPeriod1,SDClockPeriod2,ReadBurst1,ReadBurst2,LoadToActiveDelay1,ExitSelfRefreshDelay1,SelfRefreshTime1,RowCycleDelay1,RowCycleDelay2,WriteRecoveryTime1,RPDelay1,RPDelay2,RCDDelay1 @@ -267,6 +261,7 @@ NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:true NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:true NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:false\:true\:true +NVIC.TIM1_CC_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true NVIC.TIM6_DAC_IRQn=true\:15\:0\:false\:false\:true\:false\:true\:true NVIC.TimeBase=TIM6_DAC_IRQn NVIC.TimeBaseIP=TIM6 @@ -647,7 +642,6 @@ PF10.GPIO_Label=ARDUINO A1 PF10.GPIO_Mode=GPIO_MODE_ANALOG PF10.GPIO_PuPd=GPIO_NOPULL PF10.Locked=true -PF10.Mode=IN8 PF10.Signal=ADC3_IN8 PF11.GPIOParameters=GPIO_Label PF11.GPIO_Label=FMC_SDNRAS [MT48LC4M32B2B5-6A_RAS] @@ -690,29 +684,23 @@ PF6.GPIO_Label=ARDUINO A5 PF6.GPIO_Mode=GPIO_MODE_ANALOG PF6.GPIO_PuPd=GPIO_NOPULL PF6.Locked=true -PF6.Mode=IN4 PF6.Signal=ADC3_IN4 PF7.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_Mode PF7.GPIO_Label=ARDUINO A4 PF7.GPIO_Mode=GPIO_MODE_ANALOG PF7.GPIO_PuPd=GPIO_NOPULL PF7.Locked=true -PF7.Mode=IN5 PF7.Signal=ADC3_IN5 PF8.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_Mode PF8.GPIO_Label=ARDUINO A3 PF8.GPIO_Mode=GPIO_MODE_ANALOG PF8.GPIO_PuPd=GPIO_NOPULL PF8.Locked=true -PF8.Mode=IN6 PF8.Signal=ADC3_IN6 -PF9.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_Mode -PF9.GPIO_Label=ARDUINO A2 -PF9.GPIO_Mode=GPIO_MODE_ANALOG -PF9.GPIO_PuPd=GPIO_NOPULL +PF9.GPIOParameters=GPIO_Label +PF9.GPIO_Label=OUT1 PF9.Locked=true -PF9.Mode=IN7 -PF9.Signal=ADC3_IN7 +PF9.Signal=GPIO_Output PG0.GPIOParameters=GPIO_Label PG0.GPIO_Label=FMC_A10 [MT48LC4M32B2B5-6A_A10] PG0.Locked=true @@ -1220,7 +1208,7 @@ SH.GPXTI6.0=GPIO_EXTI6 SH.GPXTI6.ConfNb=1 SH.S_TIM12_CH1.0=TIM12_CH1,PWM Generation1 CH1 SH.S_TIM12_CH1.ConfNb=1 -SH.S_TIM1_CH1.0=TIM1_CH1,PWM Generation1 CH1 +SH.S_TIM1_CH1.0=TIM1_CH1 SH.S_TIM1_CH1.ConfNb=1 SH.S_TIM2_CH1_ETR.0=TIM2_CH1,PWM Generation1 CH1 SH.S_TIM2_CH1_ETR.ConfNb=1 @@ -1233,8 +1221,8 @@ SPI2.Direction=SPI_DIRECTION_2LINES SPI2.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate SPI2.Mode=SPI_MODE_MASTER SPI2.VirtualType=VM_MASTER -TIM1.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1 -TIM1.IPParameters=Channel-PWM Generation1 CH1 +TIM1.IPParameters=Prescaler +TIM1.Prescaler=0 TIM12.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1 TIM12.IPParameters=Channel-PWM Generation1 CH1 TIM2.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1