Open Quas7 opened 3 years ago
I had to add a LL_GPIO_Init call into the TIM6_IRQHandler(void) interrupt function to keep SWD programming fully functional. It would be more appropriate to set only a varialbe as a flag and do the GPIO handling in the main loop afterwards, if the timing penalty is too high in this handler.
After testing a bit, the sensitivity needs to be rather high (~1.8deg) to not falsely trigger on starting of rotation.
Offloaded the pin handling from the interrupt routine to main. Decreased sensitivity to prevent triggering during regular movement. Added noise filter functionality on top: deviation treshold has to be hit multiple times in a row.
Use SWDO pin (silkscreen on PCB) of S42B communication pin header as active low signal to trigger endstop based on angular deviation.
Mind that connecting SWDIO to an endstop pin on the mainboard is a non-buffered direct connection to the STM32 controller on the S42B Adjust the sensitivty for sensorless homing with #define sensorless_sensitivty. And generally do not home too fast during testing.
Also note that the repurposing of the SWDIO Pin (PA13) as sensorless homing endstop output might break the on-the-fly SWD programming. Pressing RES(ET) on the S42B once and retry programming normally works fine. The triggering of the sensorless homing sensitivty threshold kills the on-the-fly SWD interface!). If it does not, you will have to hold the RES(ET) button manually until "hla_swd" is shown during openOCD programming. Releasing RES directly at this point will start the normal programming. Holding RES too long will result in a timeout.