Simulator fail to start and mikroC "not responce"(freeze)!!!

General discussion on mikroElektronika website & forums.
Post Reply
Author
Message
nevo
Posts: 2
Joined: 30 Jun 2014 10:07

Simulator fail to start and mikroC "not responce"(freeze)!!!

#1 Post by nevo » 30 Jun 2014 10:36

If at some moment simulator fail to start , one of the reason may be that you don't initialize variable in main section and may be if you use this var in while loop.

EX1. main.c - with this code simulator do not start and freeze mikroC

unsigned int i=0; //declaration and initialization outside main{}

main{
while(i<0)
{
.....
}
}


EX2. main.c - with this code simulator start

unsigned int i; //declaration outside main{}

main{
i=0; //initialization inside main
while(i<0)
{
.....
}
}

User avatar
dejan.odabasic
mikroElektronika team
Posts: 2649
Joined: 30 Apr 2012 14:20

Re: Simulator fail to start and mikroC "not responce"(freeze

#2 Post by dejan.odabasic » 01 Jul 2014 16:03

Hello,

Could you please please provide more details which could help up replicate the issue.
In which compiler have you tested this code- mikroC PRO for ???

Could you please provide complete code snippet which can replicate the issue?

Best regards.

nevo
Posts: 2
Joined: 30 Jun 2014 10:07

Re: Simulator fail to start and mikroC "not responce"(freeze

#3 Post by nevo » 01 Jul 2014 16:49

I use microC pro 6.0.0 (windows 7 - 64bit)


ex1 - this way simulator is NOT working,

main.c
----------------------
//microC600, PIC18F25K22, 16 Mhz Internal clock

#include "rs232.h"

void main()
{
if(send_tx(ASCII33,sizeof(ASCII33)))
........
}
------------------------------



rs232.h
-----------------------

const unsigned short ASCII33[] = {27,38,3,33,37,9,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};

unsined short send_tx(const unsigned short *p_arr,unsigned int ln_arr)
{ static unsigned int rs_i = 0;
static unsigned int rs_stime = 0;

if(t_ms(rs_stime,5))
{ if(rs_i >= ln_arr)
{ rs_i = 0;
return 1;
}else
{ TXREG2 = *(p_arr + rs_i);
rs_i++;
rs_stime = ms;
}
}
return 0;
}
-----------------------------------------





ex2 - this way simulator is working, var rs_i and rs_stime are global in this case
but I wont var rs_i and rs_stime to be local and static like in ex1.

main.c
----------------------
//microC600, PIC18F25K22, 16 Mhz Internal clock

#include "rs232.h"

void main()
{
rs_i=0; //host rs232
rs_stime=0; //host rs232

if(send_tx(ASCII33,sizeof(ASCII33)))
........
}
------------------------------



rs232.h
-----------------------

const unsigned short ASCII33[] = {27,38,3,33,37,9,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};

unsigned int rs_i;
unsigned int rs_stime;


unsigned short send_tx(const unsigned short *p_arr,unsigned int ln_arr)
{ if(t_ms(rs_stime,5))
{ if(rs_i >= ln_arr)
{ rs_i = 0;
return 1;
}else
{ TXREG2 = *(p_arr + rs_i);
rs_i++;
rs_stime = ms;
}
}
return 0;
}
-----------------------------------------

Post Reply

Return to “Website & Forums General Discussion”