[SOLVED] Pic MickroC error "PC out of scope"

Status
Not open for further replies.

sabin14

Junior Member level 3
Joined
Mar 5, 2013
Messages
30
Helped
11
Reputation
22
Reaction score
11
Trophy points
1,288
Location
Kerala,India
funzone.mobi
Activity points
1,431
Pic MikroC error "PC out of scope"

When I try to debug my project in Mikroc it show the error "PC out of scope".
when I comment the following line everything works fine.
error = Soft_UART_Init(&PORTC, 0, 1, 1200, 0);

Deatils:
Mcu : pic 18F4520
Xtal : 11.0592 Mhz
Here is the 8bit lcd library used in the code: View attachment __Lib_Lcd8.zip
Please help me to correct the code.

Here is the complete project:View attachment project_pic18f4520.zip

Here is my code:
Code:
  // LCD module connections
  sbit LCD8_RS at RD4_bit;
  sbit LCD8_RW at RD5_bit;
  sbit LCD8_EN at RD6_bit;
  sbit LCD8_D7 at RB7_bit;
  sbit LCD8_D6 at RB6_bit;
  sbit LCD8_D5 at RB5_bit;
  sbit LCD8_D4 at RB4_bit;
  sbit LCD8_D3 at RB3_bit;
  sbit LCD8_D2 at RB2_bit;
  sbit LCD8_D1 at RB1_bit;
  sbit LCD8_D0 at RB0_bit;

  sbit LCD8_RS_Direction at TRISD4_bit;
  sbit LCD8_RW_Direction at TRISD5_bit;
  sbit LCD8_EN_Direction at TRISD6_bit;
  sbit LCD8_D7_Direction at TRISB7_bit;
  sbit LCD8_D6_Direction at TRISB6_bit;
  sbit LCD8_D5_Direction at TRISB5_bit;
  sbit LCD8_D4_Direction at TRISB4_bit;
  sbit LCD8_D3_Direction at TRISB3_bit;
  sbit LCD8_D2_Direction at TRISB2_bit;
  sbit LCD8_D1_Direction at TRISB1_bit;
  sbit LCD8_D0_Direction at TRISB0_bit;
  // End LCD module connections
  sbit ACCIDENT_KEY at RD1_bit;
  sbit GPS_KEY at RD0_bit;

  char  error, byte_read;
  void Display_Risk();
  void Gps_Data();
  void Send_Sms();
  void Accident_Action();
  unsigned char time = 60;
  char temp[3];
  //************************
  //// GPS Variables
  int i = 0;
  int received = 0;
  char DataType[] = "GPXXX";
  char NMEA[] = "$xxxxx,xxxxxxxxx,xxxx.xxx,x,xxxxx.xxx,x,x,xx,x.x,xxx.x,x,xx.x,x,,*xx";
  char receive;
  // End Variables
  //Lcd strings
  char msg1[] = "RISK WARNING";
  char msg11[] ="SYSTEM";
  char msg2[] = "INITIALIZING ";
  char msg3[] = "GPS";
  char msg31[]= " MODEM";
  char msg4[] = "GSM";
  char msg5[] = "ACCIDENT ZONE";
  char msg6[] = "HAIRPIN CURVE";
  char msg7[] = "ACCIDENT DETECTED";
  char msg8[] = "LOCATION:";
  char msg9[] = "SMS SENT";

  void main(){

    TRISB = 0x00;
    PORTB = 0;
    TRISC = 0xff;
    TRISD = 0b00000011;
    error = Soft_UART_Init(&PORTC, 0, 1, 1200, 0);
    Lcd8_Init();
      Lcd8_Cmd(_LCD_CLEAR);
      Lcd8_Cmd(_LCD_CURSOR_OFF);
      Lcd8_Out(1,3,msg1);                                         //Message for LCD
      Lcd8_Out(2,6,msg11);
      Delay_ms(3000); //3000

      Lcd8_Cmd(_LCD_CLEAR);
      Lcd8_Out(1,3,msg2);                                        //lcd message
      Delay_ms(2000);

      Lcd8_Cmd(_LCD_CLEAR);
      Lcd8_Out(1,3,msg2);                                         //Message for LCD
      Lcd8_Out(2,5,msg4);
      Lcd8_Out_Cp(msg31);                                            //initializing gsm modem
      Delay_ms(2000);

      Lcd8_Cmd(_LCD_CLEAR);
      Lcd8_Out(1,3,msg2);                                         //Message for LCD
      Lcd8_Out(2,5,msg3);
      Lcd8_Out_Cp(msg31);                                           // initilizing gps modem
      Delay_ms(2000);

      Lcd8_Cmd(_LCD_CLEAR);
      Lcd8_Out(1,3,msg2);                                         //Message for LCD
      Lcd8_Out(2,5,msg4);
      Lcd8_Out_Cp(msg31);                                           //initializing gsm modem
      Delay_ms(2000);

      Lcd8_Cmd(_LCD_CLEAR);
      Lcd8_Out(1,3,msg2);                                         //Message for LCD
      Lcd8_Out(2,5,msg3);
      Lcd8_Out_Cp(msg31);                                       // initilizing gps modem
      Delay_ms(2000);


    while(1) {
      byte_read = Soft_UART_Read(&error);
      if (error){
        }
      else{
        Lcd8_Chr_CP(byte_read);
        Lcd8_Cmd(_LCD_SHIFT_LEFT);
        if(byte_read=='A')
        Display_Risk();
        }

        if(time<1)
          time = 60;
        ByteToStr(time,temp);
        Lcd8_Cmd(_LCD_CLEAR);
        Lcd8_Out(1,3,"SCANNING") ;
        Lcd8_Out_CP(temp);
        time--;

        Delay_ms(90);
        byte_read = Soft_UART_Read(&error);
        if (error){
        }
        else{
        Lcd8_Chr_CP(byte_read);
        Lcd8_Cmd(_LCD_SHIFT_LEFT);
        if(byte_read=='A')
        Display_Risk();
        }
        Accident_Action();     //call functio to check key press
        Delay_ms(910);               //985
      }
  }

  void Display_Risk(){
  Delay_ms(90);
  byte_read = Soft_UART_Read(&error);
  if (error){
  }
  else{
      //Lcd8_Chr_CP(byte_read);
      //Lcd8_Cmd(_LCD_SHIFT_LEFT);
      if(byte_read=='1') {
      Lcd8_Cmd(_LCD_CLEAR);
      Lcd8_Out(1,1,msg5);                        //accident zone lcd
      Delay_ms(6000);                            //add speed control here
      }
      if(byte_read=='2') {
      Lcd8_Cmd(_LCD_CLEAR);
      Lcd8_Out(1,1,msg6);                      //accident zone lcd
      Delay_ms(6000);                          //add speed control
      }

    }

  }

  void Accident_Action(){
if(!ACCIDENT_KEY){
        Delay_ms(20);
        if(!ACCIDENT_KEY){                                            //accident switch routine

        Lcd8_Cmd(_LCD_CLEAR);
        Lcd8_Out(1,1,msg7);                                         //Message for LCD    :accident
        Delay_ms(2000);

        Lcd8_Cmd(_LCD_CLEAR);
        Lcd8_Out(1,3,msg8);                                         //Message for LCD  : location
        Delay_ms(1000);
        Gps_Data();

        Lcd8_Cmd(_LCD_CLEAR);
        Lcd8_Out(1,1,msg9);                                         //Message for LCD  : sending sms
        Delay_ms(2000);
        Send_Sms();

        } }
       if(!GPS_KEY){
        Delay_ms(20);
        if(!GPS_KEY){                                                //gps switch routine
          Lcd8_Cmd(_LCD_CLEAR);
          Lcd8_Out(1,3,msg8);                                         //Message for LCD  : location
          Delay_ms(1000);
          Gps_Data();
        } }
  }

  void Gps_Data(){
    UART1_Init(9600);

    while(1) {
    if (UART1_Data_Ready() == 1) {
     receive = UART1_Read();
     if (receive == '$')
     {
          received = 0;
          do{
            if (UART1_Data_Ready() == 1)
            {
             UART1_Read_Text(DataType, ",", 10);  // Capture GPXXX word
             received = 1;
            }
          } while(received == 0);
          // If it is GPGGA Data, then acquire it.
          if ((DataType[2] == 'G') && (DataType[3] == 'G') && (DataType[4] == 'A'))
          {
            received = 0;
            do{
              if (UART1_Data_Ready() == 1)
              {
               UART1_Read_Text(NMEA, "*", 100);   // Stop at *XX checksum data
               received = 1;
              }
            } while(received == 0);
            Lcd8_Cmd(_LCD_CLEAR);
            Lcd8_Out(1,1,NMEA );
            Delay_ms(4000);
            break;

          }
        receive = "x";
     }
    }

  }

}


    //**************
    void Send_Sms(){
     UART1_Init(9600);
     UART1_Write_Text("AT");
     Delay_ms(100);
     UART1_Write_Text("AT+CMGF=1");
     Delay_ms(100);
     UART1_Write(0x0D);    //enter
     UART1_Write_Text("AT+CMGS=");
     Delay_ms(100);
     UART1_Write(0x22);
     Delay_ms(100);
     UART1_Write_Text("+918496829433");
     Delay_ms(200);
     UART1_Write(0x22);
     Delay_ms(100);
     UART1_Write(0x0D); // Enter
     Delay_ms(100);
     //UART1_Write(0x22);          //test by commenting it later
     UART1_Write_Text("@rws.u ");
     UART1_Write_Text(NMEA);
     Delay_ms(600);//add more message parameters here************
     UART1_Write(0x22);
     Delay_ms(100);
     UART1_Write(26); //Ctr +Z    --send
     Delay_ms(200);
    }
 
Last edited:

Re: Pic MickroC error &amp;quot;PC out of scope&amp;quot;

Use version 6.0.0

- - - Updated - - -

I just try this under ver 6 and I didnt notice error.

- - - Updated - - -

Try to make new project, import files again and try.
 

Re: Pic MickroC error &amp;quot;PC out of scope&amp;quot;

Use version 6.0.0

- - - Updated - - -

I just try this under ver 6 and I didnt notice error.

- - - Updated - - -

Try to make new project, import files again and try.
I will change the compiler version and try again. Did you try debugging the project?
 

Although I never use the debug function of the MiKroC IDE, but I think that the library functions can not be debugged because their C source does not be published, they come in binary (MCL) form.
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…