在 F281X_EV1_HALL3_Determine_State(p);函数中, p->HallGpio = p->HallGpio>>8;检测到后为什么要移位啊?感谢老师们的回复
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
下面是部分代码,
void F281X_EV1_HALL3_Determine_State(HALL3 *p)
{
EALLOW; // Enable EALLOW
// Configure CAP1-3 as GPIO-inputs (GPIO8-GPIO10)
GpioMuxRegs.GPAMUX.all &= 0xF8FF;
// config GPIO8-GPIO10 as inputs
GpioMuxRegs.GPADIR.bit.GPIOA8 = 0;
GpioMuxRegs.GPADIR.bit.GPIOA9 = 0;
GpioMuxRegs.GPADIR.bit.GPIOA10 = 0;
EDIS; // Disable EALLOW
p->HallGpio = GpioDataRegs.GPADAT.all&0x0700; // HallGpio.2-0 = GPIO10-GPIO8
p->HallGpio = p->HallGpio>>8;
EALLOW; // Enable EALLOW
GpioMuxRegs.GPAMUX.all |= 0x0700; // Set up the CAP1-3 pins to primary functions
EDIS; // Disable EALLOW
}
感谢您百忙之中的回复!!
老师:
您好!感谢您的回复。问题是这样的,在debounce程序中 Stallcount 是什么啊,为什么计数这么多次呢? 非常感谢您的回复程序附录如下:
void F281X_EV1_HALL3_Debounce(HALL3 *p)
{
if (p->HallGpio == p->HallGpioAccepted) // GPIO_UNCHANGED: 没变Current GPIO reading == debounced GPIO reading?
{
if (p->Revolutions <= 0) // Only create hall map during initial Revolutions
F281X_EV1_HALL3_Create_Map(p);
p->StallCount -= 1; // Decrement stall counter
if (p->StallCount == 0)
{
p->EdgeDebounced = 0x7FFF; // If motor has stalled, then user trigger to commutate
p->StallCount = 0xFFFF; // Reset counter to starting value
}
}
else // GPIO_CHANGED: If not zero, then the motor has moved to a new position.
{
if (p->HallGpio == p->HallGpioBuffer) // Current GPIO reading == previous GPIO reading?
{
if (p->DebounceCount >= p->DebounceAmount) // If equal, is current GPIO reading debounced?
{
p->HallGpioAccepted = p->HallGpioBuffer; // Current GPIO reading is now debounced,当前位置已经去抖
p->EdgeDebounced = 0x7FFF; // Edge/position debounced, trigger commutation
p->DebounceCount = 0; // Reset debounce counter
if (p->HallMapPointer==0)
p->Revolutions += 1; // Increment on every rev (HallMapPointer = 0)
}
else // DEBOUNCE_MORE
p->DebounceCount += 1; // Increment debounce counter
}
else // NEW_READING
{
p->HallGpioBuffer = p->HallGpio; // Save new reading and reset debounce counter
p->DebounceCount = 0;
}
}
}