I have a simple proteus circuit simulation with a PIC18 chip and LED connected to RD0 port with a resistor.

My objective is to make the LED blink once only when i start the simulation and the following is the code I used. I set PortD as output and force it to 0 at the beginning. Thereafter, RD0 is forced to 1. 500ms later, RD0 is forced to 0.

#include <xc.h>
#define _XTAL_FREQ 8000000
void delay_ms(unsigned int t);

void main(void)
   TRISD = 0x00;
   LATD = 0x00;
   LATD = 0b00000001;
   LATD = 0b00000000;

void delay_ms(unsigned int t)
   for (int i=0 ; i<t ; i++)

When I start the simulation, the LED keep blinking forever until I stop the simulation. I did not use any form of loop in my program, what is causing this behavior?

  • $\begingroup$ what happens if you put return 0; at the end of main()? ... also try return 1; $\endgroup$
    – jsotola
    Apr 22 at 23:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.