Variable data integrety after use

Coding and general discussion relating to the compiler

Moderators: David Barker, Jerry Messina

Post Reply
Gunplumber
Posts: 38
Joined: Wed Nov 02, 2022 10:31 am

Variable data integrety after use

Post by Gunplumber » Thu Dec 01, 2022 7:08 am

Hi guys

I am chasing some bugs in my code that i'm at an absolute loss to explain.. Consider the following code. Device is a 18F26K40.

Code: Select all

Dim Array(10)
Dim XBUS_Throt as Array(6).AsWord



Sub data_print()
	LCD.WriteAt(1,12,DecToStr(XBUS_Throt,4," "))       //Print on line 1
        
	LCD.WriteAt(2,12,DecToStr(XBUS_Throt,4," "))	     //Print again on line 2

	if xbus_throt>1050 then 				//Check if above set position
            time_enable=true         
	end if      
end sub

Start:       
// main code here that loads a 12 bit number into Array (6) and Array(7)

Data_print()

goto Start
When i run this code in a loop the Number stored in Alias XBUS_throt is printed correctly to the first line of the LCD, however the second line is printed garbled.. The garbled data sometimes has elements of other data that is printed to the screen in other subroutines..
More interestingly though is that the second line will print correctly when the IF-End-if check condition is true, IE if Xbus_throt is greater than 1050.. :shock:
I am at an absolute loss to explain how this could be???
If i remove the IF End-if block then the code runs as it should and prints correctly to both lines.

Any advice appreciated..

Cheers
Lee

Jerry Messina
Swordfish Developer
Posts: 1473
Joined: Fri Jan 30, 2009 6:27 pm
Location: US

Re: Variable data integrety after use

Post by Jerry Messina » Thu Dec 01, 2022 2:36 pm

This may be related to the latest compiler update. Check your PM.

Post Reply