Skip to content

Commit

Permalink
TIM1_TRG_COM_IRQHandler added
Browse files Browse the repository at this point in the history
  • Loading branch information
stancecoke committed Jan 15, 2019
1 parent 99782a8 commit d7229be
Show file tree
Hide file tree
Showing 15 changed files with 1,043 additions and 1,043 deletions.
2 changes: 1 addition & 1 deletion .mxproject
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ LibFiles=Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_adc.h;Drivers/STM32F1xx_
SourceFiles=;;

[PreviousUsedSW4STM32Files]
SourceFiles=..\Src\main.c;..\Src\stm32f1xx_it.c;..\Src\stm32f1xx_hal_msp.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.c;../\Src/system_stm32f1xx.c;../Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/system_stm32f1xx.c;null;
SourceFiles=..\Src\main.c;..\Src\stm32f1xx_it.c;..\Src\stm32f1xx_hal_msp.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c;../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.c;../\Src/system_stm32f1xx.c;../Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/system_stm32f1xx.c;C:/LishuiFOC/Generated/LishuiFOC_01//startup/startup_stm32f103x6.s;
HeaderPath=..\Drivers\STM32F1xx_HAL_Driver\Inc;..\Drivers\STM32F1xx_HAL_Driver\Inc\Legacy;..\Drivers\CMSIS\Device\ST\STM32F1xx\Include;..\Drivers\CMSIS\Include;..\Inc;
CDefines=__weak:__attribute__((weak));__packed:__attribute__((__packed__));

Binary file modified Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.o
Binary file not shown.
Binary file modified Debug/LishuiFOC_01.elf
Binary file not shown.
1,309 changes: 653 additions & 656 deletions Debug/LishuiFOC_01.hex

Large diffs are not rendered by default.

5 changes: 1 addition & 4 deletions Debug/Src/main.d
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ Src/main.o: ../Src/main.c C:/LishuiFOC/Generated/LishuiFOC_01/Inc/main.h \
C:/LishuiFOC/Generated/LishuiFOC_01/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_pwr.h \
C:/LishuiFOC/Generated/LishuiFOC_01/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim.h \
C:/LishuiFOC/Generated/LishuiFOC_01/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim_ex.h \
C:/LishuiFOC/Generated/LishuiFOC_01/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_uart.h \
C:/LishuiFOC/Generated/LishuiFOC_01/Inc/stm32f1xx_it.h
C:/LishuiFOC/Generated/LishuiFOC_01/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_uart.h

C:/LishuiFOC/Generated/LishuiFOC_01/Inc/main.h:

Expand Down Expand Up @@ -80,5 +79,3 @@ C:/LishuiFOC/Generated/LishuiFOC_01/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_h
C:/LishuiFOC/Generated/LishuiFOC_01/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim_ex.h:

C:/LishuiFOC/Generated/LishuiFOC_01/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_uart.h:

C:/LishuiFOC/Generated/LishuiFOC_01/Inc/stm32f1xx_it.h:
Binary file modified Debug/Src/main.o
Binary file not shown.
Binary file modified Debug/Src/stm32f1xx_hal_msp.o
Binary file not shown.
Binary file modified Debug/Src/stm32f1xx_it.o
Binary file not shown.
658 changes: 327 additions & 331 deletions Debug/output.map

Large diffs are not rendered by default.

8 changes: 1 addition & 7 deletions Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c
Original file line number Diff line number Diff line change
Expand Up @@ -2771,8 +2771,7 @@ HAL_StatusTypeDef HAL_TIM_Encoder_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Cha
*/
void HAL_TIM_IRQHandler(TIM_HandleTypeDef *htim)
{

/* Capture compare 1 event */
/* Capture compare 1 event */
if(__HAL_TIM_GET_FLAG(htim, TIM_FLAG_CC1) != RESET)
{
if(__HAL_TIM_GET_IT_SOURCE(htim, TIM_IT_CC1) !=RESET)
Expand Down Expand Up @@ -2849,7 +2848,6 @@ void HAL_TIM_IRQHandler(TIM_HandleTypeDef *htim)
if((htim->Instance->CCMR2 & TIM_CCMR2_CC4S) != 0x00U)
{
HAL_TIM_IC_CaptureCallback(htim);

}
/* Output compare event */
else
Expand All @@ -2867,7 +2865,6 @@ void HAL_TIM_IRQHandler(TIM_HandleTypeDef *htim)
{
__HAL_TIM_CLEAR_IT(htim, TIM_IT_UPDATE);
HAL_TIM_PeriodElapsedCallback(htim);

}
}
/* TIM Break input event */
Expand All @@ -2886,8 +2883,6 @@ void HAL_TIM_IRQHandler(TIM_HandleTypeDef *htim)
{
__HAL_TIM_CLEAR_IT(htim, TIM_IT_TRIGGER);
HAL_TIM_TriggerCallback(htim);


}
}
/* TIM commutation event */
Expand Down Expand Up @@ -4320,7 +4315,6 @@ __weak void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim)
{
/* Prevent unused argument(s) compilation warning */
UNUSED(htim);

/* NOTE : This function Should not be modified, when the callback is needed,
the __HAL_TIM_IC_CaptureCallback could be implemented in the user file
*/
Expand Down
4 changes: 1 addition & 3 deletions Inc/stm32f1xx_it.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,9 @@ void DMA1_Channel1_IRQHandler(void);
void ADC1_2_IRQHandler(void);
void TIM1_UP_IRQHandler(void);
void TIM1_TRG_COM_IRQHandler(void);
void TIM1_CC_IRQHandler(void);
void USART1_IRQHandler(void);

extern uint16_t ui16_current_1;
extern uint16_t ui16_current_2;

#ifdef __cplusplus
}
#endif
Expand Down
11 changes: 10 additions & 1 deletion LishuiFOC_01.ioc
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
#MicroXplorer Configuration settings - do not modify
ADC1.Channel-3\#ChannelInjectedConversion=ADC_CHANNEL_3
ADC1.Channel-4\#ChannelRegularConversion=ADC_CHANNEL_3
ADC1.ContinuousConvMode=DISABLE
ADC1.DataAlign=ADC_DATAALIGN_RIGHT
ADC1.DiscontinuousConvMode=DISABLE
ADC1.EnableAnalogWatchDog=false
ADC1.EnableRegularConversion=ENABLE
ADC1.ExternalTrigConv=ADC_SOFTWARE_START
ADC1.ExternalTrigInjecConv=ADC_EXTERNALTRIGINJECCONV_T1_CC4
ADC1.IPParameters=master,Mode,EnableRegularConversion,Rank-3\#ChannelInjectedConversion,Channel-3\#ChannelInjectedConversion,SamplingTime-3\#ChannelInjectedConversion,InjectedOffset-3\#ChannelInjectedConversion,InjNumberOfConversion,ExternalTrigInjecConv,Rank-4\#ChannelRegularConversion,Channel-4\#ChannelRegularConversion,SamplingTime-4\#ChannelRegularConversion,NbrOfConversionFlag,NbrOfConversion
ADC1.IPParameters=Mode,EnableRegularConversion,Rank-3\#ChannelInjectedConversion,Channel-3\#ChannelInjectedConversion,SamplingTime-3\#ChannelInjectedConversion,InjectedOffset-3\#ChannelInjectedConversion,InjNumberOfConversion,ExternalTrigInjecConv,Rank-4\#ChannelRegularConversion,Channel-4\#ChannelRegularConversion,SamplingTime-4\#ChannelRegularConversion,NbrOfConversionFlag,NbrOfConversion,DataAlign,ScanConvMode,ContinuousConvMode,DiscontinuousConvMode,ExternalTrigConv,InjectedConvMode,EnableAnalogWatchDog,master
ADC1.InjNumberOfConversion=1
ADC1.InjectedConvMode=None
ADC1.InjectedOffset-3\#ChannelInjectedConversion=0
ADC1.Mode=ADC_DUALMODE_REGSIMULT_INJECSIMULT
ADC1.NbrOfConversion=1
Expand All @@ -13,6 +19,7 @@ ADC1.Rank-3\#ChannelInjectedConversion=1
ADC1.Rank-4\#ChannelRegularConversion=1
ADC1.SamplingTime-3\#ChannelInjectedConversion=ADC_SAMPLETIME_1CYCLE_5
ADC1.SamplingTime-4\#ChannelRegularConversion=ADC_SAMPLETIME_1CYCLE_5
ADC1.ScanConvMode=ADC_SCAN_DISABLE
ADC1.master=1
ADC2.Channel-1\#ChannelInjectedConversion=ADC_CHANNEL_4
ADC2.EnableRegularConversion=DISABLE
Expand Down Expand Up @@ -87,6 +94,8 @@ NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4
NVIC.RCC_IRQn=true\:0\:0\:false\:false\:true\:true
NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false
NVIC.SysTick_IRQn=true\:0\:0\:false\:false\:true\:false
NVIC.TIM1_CC_IRQn=true\:0\:0\:false\:false\:true\:true
NVIC.TIM1_TRG_COM_IRQn=true\:0\:0\:false\:false\:true\:true
NVIC.TIM1_UP_IRQn=true\:0\:0\:false\:false\:true\:true
NVIC.USART1_IRQn=true\:0\:0\:false\:false\:true\:true
NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false
Expand Down
45 changes: 22 additions & 23 deletions Src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
/* Includes ------------------------------------------------------------------*/
#include "main.h"
#include "stm32f1xx_hal.h"
#include "stm32f1xx_it.h"

/* USER CODE BEGIN Includes */

Expand Down Expand Up @@ -67,7 +66,6 @@ static void MX_USART1_UART_Init(void);
static void MX_TIM1_Init(void);
static void MX_ADC1_Init(void);
static void MX_ADC2_Init(void);
void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim);

void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim);

Expand Down Expand Up @@ -119,19 +117,23 @@ int main(void)
/* USER CODE BEGIN 2 */


HAL_TIM_PWM_Start_IT(&htim1, TIM_CHANNEL_1|TIM_CHANNEL_2|TIM_CHANNEL_3|TIM_CHANNEL_4);
HAL_TIMEx_PWMN_Start(&htim1, TIM_CHANNEL_1|TIM_CHANNEL_2|TIM_CHANNEL_3);

if(HAL_TIM_Base_Start_IT(&htim1) != HAL_OK)
{
/* Counter Enable Error */
Error_Handler();
}
HAL_ADC_Start(&hadc1);
HAL_ADC_Start(&hadc2);

__HAL_TIM_SET_COMPARE(&htim1, TIM_CHANNEL_1, 0);
__HAL_TIM_SET_COMPARE(&htim1, TIM_CHANNEL_4, 8000);
// Start Timer 1
if(HAL_TIM_Base_Start_IT(&htim1) != HAL_OK)
{
/* Counter Enable Error */
Error_Handler();
}
// Start injected ADC
if(HAL_ADCEx_InjectedStart(&hadc1) != HAL_OK)
{
/* Counter Enable Error */
Error_Handler();
}
HAL_TIM_PWM_Start_IT(&htim1, TIM_CHANNEL_1|TIM_CHANNEL_2|TIM_CHANNEL_3|TIM_CHANNEL_4);
HAL_TIMEx_PWMN_Start(&htim1, TIM_CHANNEL_1|TIM_CHANNEL_2|TIM_CHANNEL_3);

__HAL_TIM_SET_COMPARE(&htim1, TIM_CHANNEL_1, 0);
__HAL_TIM_SET_COMPARE(&htim1, TIM_CHANNEL_4, 8000);

/* USER CODE END 2 */

Expand All @@ -140,8 +142,10 @@ int main(void)
while (1)
{
char buffer[] = "abcdefghij\r\n";
buffer[0]=ui16_current_1;
buffer[4]=ui16_current_2;
//HAL_ADC_Start(&hadc1);

//buffer[0]=ui16_current_1;
//buffer[4]=ui16_current_2;
//HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_2); //Toggle the state of pin PC9
HAL_UART_Transmit(&huart1, (uint8_t *)&buffer, sizeof(buffer), 0xFFFF);

Expand Down Expand Up @@ -213,7 +217,6 @@ void SystemClock_Config(void)

/* SysTick_IRQn interrupt configuration */
HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);

}

/* ADC1 init function */
Expand Down Expand Up @@ -341,9 +344,7 @@ static void MX_TIM1_Init(void)
_Error_Handler(__FILE__, __LINE__);
}


sMasterConfig.MasterOutputTrigger = TIM_TRGO_OC4REF;

sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
if (HAL_TIMEx_MasterConfigSynchronization(&htim1, &sMasterConfig) != HAL_OK)
{
Expand All @@ -357,7 +358,6 @@ static void MX_TIM1_Init(void)
sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
sConfigOC.OCIdleState = TIM_OCIDLESTATE_RESET;
sConfigOC.OCNIdleState = TIM_OCNIDLESTATE_RESET;

if (HAL_TIM_OC_ConfigChannel(&htim1, &sConfigOC, TIM_CHANNEL_1) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
Expand Down Expand Up @@ -392,7 +392,6 @@ static void MX_TIM1_Init(void)

HAL_TIM_MspPostInit(&htim1);


}

/* USART1 init function */
Expand Down
6 changes: 6 additions & 0 deletions Src/stm32f1xx_hal_msp.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,10 @@ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base)
/* TIM1 interrupt Init */
HAL_NVIC_SetPriority(TIM1_UP_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(TIM1_UP_IRQn);
HAL_NVIC_SetPriority(TIM1_TRG_COM_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(TIM1_TRG_COM_IRQn);
HAL_NVIC_SetPriority(TIM1_CC_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(TIM1_CC_IRQn);
/* USER CODE BEGIN TIM1_MspInit 1 */
HAL_NVIC_SetPriority(TIM1_TRG_COM_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(TIM1_TRG_COM_IRQn);
Expand Down Expand Up @@ -301,6 +305,8 @@ void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base)

/* TIM1 interrupt DeInit */
HAL_NVIC_DisableIRQ(TIM1_UP_IRQn);
HAL_NVIC_DisableIRQ(TIM1_TRG_COM_IRQn);
HAL_NVIC_DisableIRQ(TIM1_CC_IRQn);
/* USER CODE BEGIN TIM1_MspDeInit 1 */

/* USER CODE END TIM1_MspDeInit 1 */
Expand Down
38 changes: 21 additions & 17 deletions Src/stm32f1xx_it.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ extern ADC_HandleTypeDef hadc1;
extern ADC_HandleTypeDef hadc2;
extern TIM_HandleTypeDef htim1;
extern UART_HandleTypeDef huart1;
uint16_t ui16_current_1;
uint16_t ui16_current_2;

/******************************************************************************/
/* Cortex-M3 Processor Interruption and Exception Handlers */
Expand Down Expand Up @@ -220,7 +218,6 @@ void DMA1_Channel1_IRQHandler(void)

/* USER CODE END DMA1_Channel1_IRQn 0 */
HAL_DMA_IRQHandler(&hdma_adc1);

/* USER CODE BEGIN DMA1_Channel1_IRQn 1 */

/* USER CODE END DMA1_Channel1_IRQn 1 */
Expand All @@ -236,14 +233,8 @@ void ADC1_2_IRQHandler(void)
/* USER CODE END ADC1_2_IRQn 0 */
HAL_ADC_IRQHandler(&hadc1);
HAL_ADC_IRQHandler(&hadc2);
//HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_2);
ui16_current_1 = ADC_JDR1_JDATA;

ui16_current_2 = ADC_JDR2_JDATA;


/* USER CODE BEGIN ADC1_2_IRQn 1 */

HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_2);
/* USER CODE END ADC1_2_IRQn 1 */
}

Expand All @@ -256,25 +247,38 @@ void TIM1_UP_IRQHandler(void)

/* USER CODE END TIM1_UP_IRQn 0 */
HAL_TIM_IRQHandler(&htim1);


/* USER CODE BEGIN TIM1_UP_IRQn 1 */

/* USER CODE END TIM1_UP_IRQn 1 */
}

/**
* @brief This function handles TIM1 trigger and commutation interrupts.
*/
void TIM1_TRG_COM_IRQHandler(void)
{
/* USER CODE BEGIN TIM1_UP_IRQn 0 */
/* USER CODE BEGIN TIM1_TRG_COM_IRQn 0 */

/* USER CODE END TIM1_UP_IRQn 0 */
/* USER CODE END TIM1_TRG_COM_IRQn 0 */
HAL_TIM_IRQHandler(&htim1);
HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_2);

/* USER CODE BEGIN TIM1_TRG_COM_IRQn 1 */

/* USER CODE BEGIN TIM1_UP_IRQn 1 */
/* USER CODE END TIM1_TRG_COM_IRQn 1 */
}

/* USER CODE END TIM1_UP_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 */
}

/**
Expand Down

0 comments on commit d7229be

Please sign in to comment.