Hi all
m designing a project using pic16f877 (4Mhz)and ds1302.the controller unit drives the relay which furthur drives a star delta strater of three phase motor.
i have to save the runtime of the motor on power failure.so as soon as the power fails my system generates an interrupt and the runtime of motor is saved.
now the problem is as soon as my pic gives start command to relay and relay to starter due to back emf of starter my microcontroller section hangs up ...i have tried following hardware solutions:
1 . adding decoupling capacitors
2. flywheel diode on the relay
3. better ground lines
if i remove the interrupt from the code my controller section works fine..what might me the problem? m sending the part of code for interrupt
Your problem appears to be that you have nonsense code or you only posted part of it. You obviously think the error is in the code you posted. The reality is that it's probably not.
It's important that ISR's are as short and fast as possible, writing to EEPROM from within one isn't really a good idea (it's a very slow procedure). I don't 'do' C, but I imagine you're reseting the interrupt BEFORE writing to the EEPROM - so it may be getting called multiple times before it returns, and this is a SERIOUSLY BAD IDEA!.
What does your WriteByteToEE function look like? Does it determine the end of EE writing via interrupt flag or the PIC auto clearing of the write bit. Are you clearing the EE interrupt flag before in the function?
Have you tried simulating a power failure just by toggling the INT pin outside a noisy environment: No relays, no starter, just PIC, regulator, INT pin and a status Led?