Trouble in working with mplab simulator

Status
Not open for further replies.

Murugesh_89

Full Member level 5
Hi,
I want to work with mplab simulator debugger. So i started with the very basic program.

Code C - [expand]1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include<18f45k22.h>
#fuses NOWDT,INTRC_IO,MCLR,NOPUT,DEBUG,NOPROTECT,NOBROWNOUT,NOLVP
#use delay( clock = 8M )
unsigned long count = 0;

void main()
{
count = 0;

while( 1 )
{
delay_ms(200);
count++;
}
}

I run the program and after 15 seconds in my wrist watch i halted the execution. I want the variable "count" to be 75 but instead it showing some values around 200.

I repeated this for various timing but the "count" value is showing wrongly.

I am using MPLAB 8.92 and selected MPLAB SIM under debugger.

Could anybody pls correct me?

Last edited by a moderator:

mdorian

Member level 2
Hi , MPLAB sim is not a real time simulator , use the time from stopwatch instead.

betwixt

Super Moderator
Staff member
The simulator runs as fast as your computer lets it. The simulation times are accurate but not real-time as mdorian stated.

To check the program simulation running time, use 'Debugger/Stopwatch' from the menu bar. Make sure you reset it if you are timing the delay between different parts of the program. It is very useful when used in conjuction with 'Set PC at cursor' and breakpoints or for timing loops.

Brian.

Murugesh_89

Murugesh_89

Points: 2
Status
Not open for further replies.

Replies
14
Views
3K
Replies
0
Views
1K
Replies
2
Views
2K
Replies
0
Views
2K
Replies
0
Views
1K