I think i found another bug! I tested this on a easydsPIC2 board.
Code: Select all
Dim t1 as float
t1 = 2 * cos(pi) ' this should be -2
Main:
TRISB = $0000
TRISF = $0000
if t1 < -1.9 then LATB = $0001
end if
If t1 > -2.1 then LATF = $0001
end if
end.
both LED's should be on but on one of them lights
I tried splitting it up as shown below which made it work
Code: Select all
Dim t1 as float
Dim temp as float
temp = cos(pi)
t1 = 2 * temp ' this should be -2
Main:
TRISB = $0000
TRISF = $0000
if t1 < -1.9 then LATB = $0001
end if
If t1 > -2.1 then LATF = $0001
end if
end.
According to the debugger both methods worked but only the second actually worked on the chip. A problem that i got when i used the second method throughout my main program was that it didnt start, or it just kept on making the program reset. Any ideas what could cause this as my code ran through fine on my chip before i fixed all the cosine and sine's in it, but it just produced the wrong answer. Unfortunetly i cant put to much of my source code on here as it is for work. Any help will be very appreciated