Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange errors if "Hard limits" are enabled #39

Closed
lakeroe opened this issue Mar 18, 2018 · 2 comments
Closed

Strange errors if "Hard limits" are enabled #39

lakeroe opened this issue Mar 18, 2018 · 2 comments

Comments

@lakeroe
Copy link

lakeroe commented Mar 18, 2018

I've always had strange errors in bCNC when zeroing X, Y or Z axis or pressing the stop button several times in a row. The errors only happen if "Hard limits" are enabled ($21=1). After some debugging I found that EXTI15_10_IRQHandler() in limits.c gets triggered although it should not. I think the problem is somehow related to USB connected to pins PA11/PA12 and the Y/Z limit switches connected to PB11/PB12. After changing the Y/Z limit switches to PA1/9 the problem is gone.

So maybe that's worth some more debugging ...

@lakeroe
Copy link
Author

lakeroe commented Mar 20, 2018

After some more testing I found that PA9 also interferes with something and can not be used as input. PA10 works fine though ...
So in summary: If using USB and "Hard limits" PA9, PA11 and PA12 can not be used

@lakeroe
Copy link
Author

lakeroe commented Mar 27, 2018

I think I've now found the root cause of the problem.
In limits.c the function GPIO_EXTILineConfig (in stm32f10x_gpio.c) is called which does a read/modify/write of the "External interrupt configuration registers (AFIO_EXTICRx)" to select the appropriate interrupt input pin.
This function is implemented in a wrong way what causes the wrong input be selected (for a very short time) everytime it's called and triggers an false interrupt.
After changing

tmp = ((uint32_t)0x0F) << (0x04 * (GPIO_PinSource & (uint8_t)0x03));
AFIO->EXTICR[GPIO_PinSource >> 0x02] &= ~tmp;
AFIO->EXTICR[GPIO_PinSource >> 0x02] |= (((uint32_t)GPIO_PortSource) << (0x04 * (GPIO_PinSource & (uint8_t)0x03)));

to

tmp = AFIO->EXTICR[GPIO_PinSource >> 0x02];
tmp &= ~(((uint32_t)0x0F) << (0x04 * (GPIO_PinSource & (uint8_t)0x03)));
tmp |= (((uint32_t)GPIO_PortSource) << (0x04 * (GPIO_PinSource & (uint8_t)0x03)));
AFIO->EXTICR[GPIO_PinSource >> 0x02] = tmp;

the hard limit interrupts (on pins PB10/11/12) work as expected and no more false interrupts are triggered (when pressing the stop-button in bCNC).

Best regards,
lakeroe

@lakeroe lakeroe mentioned this issue Jun 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants