Search code examples
cmicrocontrollermicrochipmicroc

"$MCLR$ is low. Processor is in reset." Error on Pic18


On this circuit and code, I tried to make a counter that when no one pass through (for example it is a passage at the metro station), there will read 1 value at RC7 lead of the processor. If someone pass through the signal change to 0. And program will count the how many people pass away over there and show the number of people on the 7-Segment LCD until 10. When 10 people pass through of the passage, the LED (D1) will be blinking for 1 seconds.

I tried to write a code about this algorithm, and when I load it to Pic18F45K22 but, it is not working. Proteus show error message like,

[PIC18] PC=0x0000. $MCLR$ is low. Processor is in reset. [U1]

The circuit that I designed given at below Figure 1:

Figure 1

The solutions that I tried:

  1. I used pull-up resistors. It did not work.
  2. We describe the frequency value in Micro C code. It did not work.

And the algorithm given at below:

#include <xc.h>
#define _XTAL_FREQ 4000000



unsigned char x=0;
void MSDelay(unsigned int);
void main()
{
    TRISC=0xff;
    TRISA=0x00;
    while(1)
    {
        if (PORTC==0)
        {
            x++;
            MSDelay(200);
        }
        if (x==1)
        {
            PORTA==0x3f;
        }
        if (x==2)
        {
            PORTA==0x06;
        }
        if (x==3)
        {
            PORTA==0x5b;
        }
        if (x==4)
        {
            PORTA==0x4f;
        }
        if (x==5)
        { 
            PORTA==0x66;
        }
        if (x==6)
        {
            PORTA==0x6d;

        }
    }

}

void MSDelay(unsigned int itime){                   //for delay
    unsigned int i;
    unsigned int j;
    for(i=0;i<itime;i++){
        for(j=0;j<165;j++){
        }
    }

}

Solution

  • So I make the answer for you:
    The error ist here:

    if (x==1)
        {
            PORTA==0x3f;
        }
    

    If you want assign a value you need = and not ==

        if (x==1)
        {
            PORTA=0x3f;
        }