Hi there,
Your working and not working code has the difference of only one loop. That's absurd why it should not work. If the portd.1 goes low okay then there should not a problem of level difference of the 5volt level at the micro side and maximum permissible level of 3v at the MAX side. However try inserting a diode (1n4148) with its anode coonected to the portd side in series with the 2k resistor. So you receive only the ground (negative) going pulse from portb (the on switch).
try inserting some oscilloscope check routine like toggling a pin when you enter or exit the loop and find the relation of portd alongwith it. If possible post the entire code, the asm and the .cod file. I haven't worked much on the 16F877 as my choice of MCU is the 18F series still I will spend some time reading the manual and sort out any R-M-W issues. Would you mind spending a few miliamps ? Then go for a opto. Alternatively use the ONA pin and a 3volt zener in series with limiting resistor to translate the 5 volt level from the MCU to a 3 volt for the boost converter.
Regards
Sougata




Bookmarks