您好!
我们有一些代码在 CPU1的中断上运行(中断由 CPU2触发)。 在中断中、我们切换 GPIO、我们可以看到它在表达式窗口中切换。 因此我们知道中断正在运行。
当改变模拟输入值时、我们还会看到"AdccResultRegs.ADCRESULT0"寄存器中的变化。
// *************************************************************************************************
// *
// * Function name : Cpu1Task3Calc()
// * Creation date : 2022-06-13
// * Programmer : Ralf Rink
// *
// * Description : Task 3 der CPU1, sampling period = 128 x system sampling period
// * mit einer CONTROL_LOOP_CYCLE_TIME_NS von 31,25µs = 4 ms
// * Poti-Handling zum Sollpositionen-Generator
// *
// *************************************************************************************************
inline void Cpu1Task3Calc(IPC_CPU1Task3DataIn* input, IPC_CPU1Task3DataOut* output)
{
static uint16_t alive = 1; // Umschaltung zwischen Still-Alive-LED und Laufzeit-Messung
static uint16_t ledCounter = 0; // Variable für Still-Alive-LED
if(alive == 0)
{
// Laufzeit-Messung
GpioDataRegs.GPASET.bit.GPIO3 = 1;
} else
{
// CPU1-Alive-LED (0,5 Hz / 2000 ms)
if(ledCounter >= STILL_ALIVE_LED_UPDATE_LOOPS_CPU1_TASK3)
{
GpioDataRegs.GPATOGGLE.bit.GPIO3 = 1;
ledCounter = 0;
}
ledCounter++;
}
SOLLPOSGENERATOR::callADC(&SOLLPOSGENERATOR::sollPosGen.poti);
if(SOLLPOSGENERATOR::sollPosGen.poti.valueChanged)
{
SOLLPOSGENERATOR::potiNewCalcInit(¶msUser.kinematics[0],
&SOLLPOSGENERATOR::sollPosGen.poti,
&SOLLPOSGENERATOR::sollPosGen.kinematics.calc[0],
&SOLLPOSGENERATOR::sollPosGen.kinematics,
&SOLLPOSGENERATOR::sollPosGen.time[0],
&SOLLPOSGENERATOR::sollPosGen.time[1],
&SOLLPOSGENERATOR::sollPosGen.timeBuffer);
}
// output->data = input->data + 1;
if(alive == 0)
{
// Laufzeit-Messung
GpioDataRegs.GPACLEAR.bit.GPIO3 = 1;
}
}
在函数"SOLLPOSGENERATOR::callADC (&SOLLPOSGENERATOR::sollPosGen.poti)"中、我们将"AdcResultRegs.ADCRESULT0"复制到全局变量"AdccResult0"。 该变量始终显示零、而不是"AdccResultRegs.ADCRESULT0"中的相同值。 此外、我们的结构"SOLLPOSGENERATOR::sollPosGen"没有任何值会更新。
int32_t SOLLPOSGENERATOR::callADC(Potentiometer* pPoti)
{
int32_t errorCode = 0;
static bool Stillstand = true;
static bool Test = true;
// start conversions immediately via software, ADCA
AdccRegs.ADCSOCFRC1.all = 0x0003; //SOC0 and SOC1
// Store results
AdccResult0 = AdccResultRegs.ADCRESULT0;
if (((AdccResult0 - pPoti->value) > 90) || ((pPoti->value - AdccResult0) > 90 ))
{
pPoti->value = AdccResult0; //int32 wert mit uint16 wert
Stillstand = false;
//pPoti->PotiValueChanged = true;
} else if((!Stillstand) ) //&& (pPoti->PotiValue == AdccResult0)
{
//pPoti->PotiValueChanged = true;
if((!Stillstand) && (!Test))
{
pPoti->valueChanged = true;
Stillstand = true;
Test = true;
}
Test = false;
}
return errorCode;
}
有人能帮我们解决这个(调试)问题吗?
此致 Ralf