程序在执行main函数时,执行到一段就又回到起点,(执行到Dlog_Parameter_Settings();又回到DeviceInit();)就这样一直死循环。具体代码如下所示,编译器无错误记录。希望大神们可以指点一下,万分感谢!
void main(void)
{
DeviceInit(); // Device Life support & GPIO
//————————————————————————-
// Only used if running from FLASH
// Note that the variable FLASH is defined by the compiler
#ifdef FLASH
// Copy time critical code and Flash setup code to RAM
// The RamfuncsLoadStart, RamfuncsLoadEnd, and RamfuncsRunStart
// symbols are created by the linker. Refer to the linker files.
MemCopy(&RamfuncsLoadStart, &RamfuncsLoadEnd, &RamfuncsRunStart);
// Call Flash Initialization to setup flash waitstates
// This function must reside in RAM
InitFlash(); // Call the flash wrapper init function
#endif //(FLASH)
// Tasks State-machine init
Alpha_State_Ptr = &A0;
A_Task_Ptr = &A1;
B_Task_Ptr = &B1;
// Waiting for enable flag set
while (EnableFlag==FALSE)
{
BackTicker++;
}
// Initialize all the Device Peripherals:
// This function is found in DSP280x_CpuTimers.c
InitCpuTimers();
// Configure CPU-Timer 0 to interrupt every ISR Period:
// 60MHz CPU Freq, ISR Period (in uSeconds)
// This function is found in DSP280x_CpuTimers.c
ConfigCpuTimer(&CpuTimer0, 60, 1000/ISR_FREQUENCY);
StartCpuTimer0();
// Configure CPU-Timer 1,2 for background loops
ConfigCpuTimer(&CpuTimer1, 60, 1000);
ConfigCpuTimer(&CpuTimer2, 60, 50000);
StartCpuTimer1();
StartCpuTimer2();
//————————————————————————-
// Reassign ISRs.
// Reassign the PIE vector for TINT0 to point to a different
// ISR then the shell routine found in DSP280x_DefaultIsr.c.
// This is done if the user does not want to use the shell ISR routine
// but instead wants to use their own ISR.
EALLOW; // This is needed to write to EALLOW protected registers
PieVectTable.TINT0 = &MainISR;
EDIS; // This is needed to disable write to EALLOW protected registers
// Enable PIE group 1 interrupt 7 for TINT0
PieCtrlRegs.PIEIER1.all = M_INT7;
// Enable CPU INT1 for TINT0:
IER |= M_INT1;
// Enable Global realtime interrupt DBGM
//————————————————————————-
// Enable global Interrupts and higher priority real-time debug events:
EINT; // Enable Global interrupt INTM
ERTM; // Enable Global realtime interrupt DBGM
//————————————————————————-
// Initialize PWM module
pwm1.PeriodMax = (SYSTEM_FREQUENCY/PWM_FREQUENCY)*1000; // Asymmetric PWM
pwm1.DutyFunc = ALIGN_DUTY; // DutyFunc = Q15
BLDCPWM_INIT_MACRO(1,2,3,pwm1)
//————————————————————————-
// Initialize PWMDAC module
pwmdac1.PeriodMax = 500; // @60Mhz, 1500->20kHz, 1000-> 30kHz, 500->60kHz
pwmdac1.HalfPerMax = pwmdac1.PeriodMax/2; // Needed to adjust the duty cycle range in the macro
PWMDAC_INIT_MACRO(6,pwmdac1) // PWM 6A,6B
PWMDAC_INIT_MACRO(7,pwmdac1) // PWM 7A,7B
//————————————————————————-
// Initialize Hall module
hall1.DebounceAmount = 0;
hall1.Revolutions = -3;
HALL3_INIT_MACRO(hall1)
Hall_Data_Init();
//————————————————————————-
// Initialize DATALOG module
Dlog_Parameter_Settings();
//————————————————————————-
ADC_MACRO_INIT()
Adc_Data_Init();
//————————————————————————-
CAN_Config();
Can_Data_Init();
//————————————————————————-
I2CA_Config();
I2CA_Data_Init();
//————————————————————————-
HRCap1_Config();
//————————————————————————-
Control_Module_Parameter_Init();
Torque_Angle_Init();
//————————————————————————-
//Call HVDMC Protection function
HVDMC_Protection();
//————————————————————————-
// ==============================================================================
// ================================ FOR =====================================
// ==============================================================================
// IDLE loop. Just sit and loop forever:
for(;;) //infinite loop
{
BackTicker++;
EEPROM_Data_Communication();
//Write_Data_To_EEPROM_Section();
//Read_Data_From_EEPROM_Section();
// State machine entry & exit point
//===========================================================
(*Alpha_State_Ptr)(); // jump to an Alpha state (A0,B0,…)
//===========================================================
}
} //END MAIN CODE
Eric Ma:
复位了,是不是开了看门狗,还是时钟丢失导致的复位。
ERIC
程序在执行main函数时,执行到一段就又回到起点,(执行到Dlog_Parameter_Settings();又回到DeviceInit();)就这样一直死循环。具体代码如下所示,编译器无错误记录。希望大神们可以指点一下,万分感谢!
void main(void)
{
DeviceInit(); // Device Life support & GPIO
//————————————————————————-
// Only used if running from FLASH
// Note that the variable FLASH is defined by the compiler
#ifdef FLASH
// Copy time critical code and Flash setup code to RAM
// The RamfuncsLoadStart, RamfuncsLoadEnd, and RamfuncsRunStart
// symbols are created by the linker. Refer to the linker files.
MemCopy(&RamfuncsLoadStart, &RamfuncsLoadEnd, &RamfuncsRunStart);
// Call Flash Initialization to setup flash waitstates
// This function must reside in RAM
InitFlash(); // Call the flash wrapper init function
#endif //(FLASH)
// Tasks State-machine init
Alpha_State_Ptr = &A0;
A_Task_Ptr = &A1;
B_Task_Ptr = &B1;
// Waiting for enable flag set
while (EnableFlag==FALSE)
{
BackTicker++;
}
// Initialize all the Device Peripherals:
// This function is found in DSP280x_CpuTimers.c
InitCpuTimers();
// Configure CPU-Timer 0 to interrupt every ISR Period:
// 60MHz CPU Freq, ISR Period (in uSeconds)
// This function is found in DSP280x_CpuTimers.c
ConfigCpuTimer(&CpuTimer0, 60, 1000/ISR_FREQUENCY);
StartCpuTimer0();
// Configure CPU-Timer 1,2 for background loops
ConfigCpuTimer(&CpuTimer1, 60, 1000);
ConfigCpuTimer(&CpuTimer2, 60, 50000);
StartCpuTimer1();
StartCpuTimer2();
//————————————————————————-
// Reassign ISRs.
// Reassign the PIE vector for TINT0 to point to a different
// ISR then the shell routine found in DSP280x_DefaultIsr.c.
// This is done if the user does not want to use the shell ISR routine
// but instead wants to use their own ISR.
EALLOW; // This is needed to write to EALLOW protected registers
PieVectTable.TINT0 = &MainISR;
EDIS; // This is needed to disable write to EALLOW protected registers
// Enable PIE group 1 interrupt 7 for TINT0
PieCtrlRegs.PIEIER1.all = M_INT7;
// Enable CPU INT1 for TINT0:
IER |= M_INT1;
// Enable Global realtime interrupt DBGM
//————————————————————————-
// Enable global Interrupts and higher priority real-time debug events:
EINT; // Enable Global interrupt INTM
ERTM; // Enable Global realtime interrupt DBGM
//————————————————————————-
// Initialize PWM module
pwm1.PeriodMax = (SYSTEM_FREQUENCY/PWM_FREQUENCY)*1000; // Asymmetric PWM
pwm1.DutyFunc = ALIGN_DUTY; // DutyFunc = Q15
BLDCPWM_INIT_MACRO(1,2,3,pwm1)
//————————————————————————-
// Initialize PWMDAC module
pwmdac1.PeriodMax = 500; // @60Mhz, 1500->20kHz, 1000-> 30kHz, 500->60kHz
pwmdac1.HalfPerMax = pwmdac1.PeriodMax/2; // Needed to adjust the duty cycle range in the macro
PWMDAC_INIT_MACRO(6,pwmdac1) // PWM 6A,6B
PWMDAC_INIT_MACRO(7,pwmdac1) // PWM 7A,7B
//————————————————————————-
// Initialize Hall module
hall1.DebounceAmount = 0;
hall1.Revolutions = -3;
HALL3_INIT_MACRO(hall1)
Hall_Data_Init();
//————————————————————————-
// Initialize DATALOG module
Dlog_Parameter_Settings();
//————————————————————————-
ADC_MACRO_INIT()
Adc_Data_Init();
//————————————————————————-
CAN_Config();
Can_Data_Init();
//————————————————————————-
I2CA_Config();
I2CA_Data_Init();
//————————————————————————-
HRCap1_Config();
//————————————————————————-
Control_Module_Parameter_Init();
Torque_Angle_Init();
//————————————————————————-
//Call HVDMC Protection function
HVDMC_Protection();
//————————————————————————-
// ==============================================================================
// ================================ FOR =====================================
// ==============================================================================
// IDLE loop. Just sit and loop forever:
for(;;) //infinite loop
{
BackTicker++;
EEPROM_Data_Communication();
//Write_Data_To_EEPROM_Section();
//Read_Data_From_EEPROM_Section();
// State machine entry & exit point
//===========================================================
(*Alpha_State_Ptr)(); // jump to an Alpha state (A0,B0,…)
//===========================================================
}
} //END MAIN CODE
hong shui:
回复 Eric Ma:
通过对比上一个可行的工程和当前的异常工程发现底层部分以及硬件问题都是可以排除的。以下是工程差异的对比。