94 if (RESET != usart_interrupt_flag_get(USART0, USART_INT_FLAG_RBNE)) {
96 unsigned char rcv_data = usart_data_receive(USART0);
106 if (SET == timer_interrupt_flag_get(TIMER2, TIMER_INT_UP)) {
107 timer_interrupt_flag_clear(TIMER2, TIMER_INT_UP);
126 if (SET == timer_interrupt_flag_get(TIMER13, TIMER_INT_UP)) {
127 timer_interrupt_flag_clear(TIMER13, TIMER_INT_UP);
#define SPEED_UP_FREQ
set speed update frequency to 200Hz
void encoder_update_speed(void)
called every 2 milliseconds to calculate the speed.
float encoder_get_electronic_angle(void)
according to the electrical angle calculated from the mechanical angle, this function will call encod...
void foc_calculate_dutycycle(float elect_angle, float d, float q, float *u, float *v, float *w)
calculate the corresponding three-phase PWM duty cycle under the current electrical angle
volatile FOC_Structure_t FOC_Struct
FOC handler.
volatile unsigned char phase_sequence
motor phase sequence flag variable
void TIMER2_IRQHandler(void)
this function handles TIMER2 TIMER_INT_UP interrupt request
void UsageFault_Handler(void)
this function handles UsageFault exception
void HardFault_Handler(void)
this function handles HardFault exception
void MemManage_Handler(void)
this function handles MemManage exception
void SVC_Handler(void)
this function handles SVC exception
void PendSV_Handler(void)
this function handles PendSV exception
void NMI_Handler(void)
this function handles NMI exception
void BusFault_Handler(void)
this function handles BusFault exception
void TIMER13_IRQHandler(void)
this function handles TIMER13 TIMER_INT_UP interrupt request
void USART0_IRQHandler(void)
this function handles USART RBNE interrupt request
void SysTick_Handler(void)
this function handles SysTick exception
static unsigned char systick_counter
systick interrupt count variable is used to realize the encoder update function.
void DebugMon_Handler(void)
this function handles DebugMon exception
gd32f1x0 interrupt handler function header file
main function Header File
volatile unsigned char pid_control_mode_flag
flag variable of PID closed loop mode
volatile PID_Structure_t angle_pid_handler
algorithm handler of PID angle loop
volatile PID_Structure_t speed_pid_handler
algorithm handler of PID speed loop
float pid_calculate_result(PID_Structure_t *pid_handler, float collect)
calculate result using sampling value
#define ANGLE_LOOP_CONTROL
angle loop control mode
float user_expect
user expect value of miniFOC
float rotate_speed
motor rotate speed calculate from timer
float mechanical_angle
mechanical angle read form encoder
structure of PID algorithm
float expect
user expectations in PID
void delay_decrement(void)
delay counter decrement function, called by systick handler
void update_pwm_dutycycle(float ch0, float ch1, float ch2)
update timer1 ch0 1 2 duty-cycle
void mdtp_receive_handler(unsigned char data)
medium capacity data transmission protocol unpacking handler