Proteus problem when using float type

Status
Not open for further replies.

muoinhohn

Full Member level 2
Joined
Nov 5, 2004
Messages
135
Helped
5
Reputation
10
Reaction score
5
Trophy points
1,298
Location
Hanoi
Activity points
1,007
Hi all
I use Proteus v7.1 SP2 to simulate ATmega32.
My test program is simple:
--------------------------------------
#include <avr/io.h>
int main()
{
float ek;
signed char i, j;

while (1)
{
i = PORTA;
ek += i - 2;
if (ek < 2) { j = 0; ek = 10;}
else j = 1;
}
return 0;
}
----------------------------------------------
When I use AVR Studio to simulate, all is ok:
* variable i is always equal 0
* ek has values 10, 8, 6, 4, 2, 0
* variable j had 0 or 1

But when i use Proteus, j variable is always equal 1. This means that equation (ek < 2) is always false.

The same program like above, but I change "float ek" to "signed int ek" then all is ok in AVRStudio and Proteus too.

Anyone can help me to explain this problem.
Thanks in advance
Regards

Muoinhohn
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…