Hi everyone who is facing the same issue as me, I figured out that it is my MCU. It worked on another MCU but didn't work on mine that I am working with. Thanks everyone that helped me.