>>Can you check my code why TIM4_IRQHandler is not working?
You can't just invent connectivity to TIM4_CH4 and expect it to work. Or randomly cut-n-paste code from entirely different parts with different functionality and plumbing.
To get to the RTC / LSI clock you'd need to push it out the TAMPER pin and loop it back to a TIM pin you can actually monitor.
You could also watch the RTC count, or generate interrupts on a periodic basis.
How is it that those who know the least about coding and the MCU get tasked with "safety" ?
Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..