WordToStr not working

General discussion on mikroProg™ programmer and debugger and mikroProg Suite software as well.
Post Reply
Author
Message
Terry.Stefanski
Posts: 23
Joined: 29 Jan 2016 21:13

WordToStr not working

#1 Post by Terry.Stefanski » 24 Apr 2018 22:09

Greetings, All:

I am currently unable to get the sub WordToStr to work. I have it implemented as shown in the help section, and I get no compiler errors. I have an analog input on PORTA0, and have verified the word variable is getting the correct data by sending to digital outputs, but it is not being transferred to the associated string.
Declared as follows:
dim PotVal as word
Text1 as char[5]

'
sub procedure WordToStr(dim PotVal as word, dim byref Text1 as string[5])
'
end sub

I get no compiler errors, but do get two "Hints" associated with the line for the above procedure declaration:
1001 Hint: Variable "PotVal" has been declared, but not used
1001 Hint: Variable "Text1" has been declared, but not used
In the main program section, where variables at initialized, are the following:
Text1 = "12345"
PotVal = 15000
'
PotVal = ADC_Read (0) 'Discard first reading
PotVal = ADC_Read (0)
Delay_ms (10)
PotVal = PotVal + ADC_Read (0)
Delay_ms (10)
PotVal = PotVal + ADC_Read (0)
Delay_ms (10)
PotVal = PotVal + ADC_Read (0)
PotVal = PotVal / 4
WordToStr(PotVal, Text1) 'Average 4 readings
'
SPI_Lcd_Cmd (_LCD_CLEAR)
SPI_Lcd_Out (1,1,"Analog Value ")
SPI_Lcd_Out_CP (Text1)
'
GoTo LoopHere
'
What come out on the LCD is:
ANALOG VALUE 12345

Suggestions appreciated.
Comments welcome.

Terry Stefanski

Terry.Stefanski
Posts: 23
Joined: 29 Jan 2016 21:13

Re: WordToStr not working

#2 Post by Terry.Stefanski » 25 Apr 2018 20:22

Solved the problem. Example in help incorrect - the procedure does not have to be declared, but the "Conversions" library needs to be manually selected.

Post Reply

Return to “mikroProg™ programmer and debugger”