function error

General discussion on mikroBasic PRO for PIC32.
Post Reply
Author
Message
relinquished
Posts: 222
Joined: 09 Apr 2011 11:08
Location: ITALY / NAPOLI

function error

#1 Post by relinquished » 28 Jun 2015 09:52

prejudice I wanted to bring attention to a bug mikroBASIC pro PIC32, in practice I found that the instructions HI and LO are not working correctly
I noticed when I used this code


sub procedures WrData (size data as word)
     SPI2_Write (hi (data))
     SPI2_Write (the (data))
   end sub

Then I tried to use the correct code

sub procedures WrData (size data as word)
     SPI2_Write (data >> 8)
     SPI2_Write (data)
   end sub
and now works well, then the problem will definitely function HI

User avatar
viktor.milovanovic
Posts: 240
Joined: 08 Jun 2015 10:09

Re: function error

#2 Post by viktor.milovanovic » 29 Jun 2015 15:09

Hi,

In the help file, for the Hi function, parameter is declared as longint, while your parameter is word.
Try calling the function with the parameters as longint.

Best regards,

Viktor Milovanovic

Dany
Posts: 3854
Joined: 18 Jun 2008 11:43
Location: Nieuwpoort, Belgium
Contact:

Re: function error

#3 Post by Dany » 01 Jul 2015 13:12

Hi, the code below works (both versions of the procedure WrData):

Code: Select all

program HiLo

' Declarations section 

dim Bte as byte // test replacament for SPI_write

sub procedures WrData (dim data_ as word)
     Bte = hi (data_)
     Bte = lo (data_)
   end sub

'Then I tried to use the correct code

sub procedures WrData2 (dim data_ as word)
     Bte = (data_ >> 8)
     Bte=  (data_)
   end sub

main:
'   Main program 
  WrData(1000)
  WrData2(1000)
end.
Your code did not compile:
"the" was used in stead of "lo", "size" was used in stead of "dim" and "data" is a reserved word in mB.
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)

Post Reply

Return to “mikroBasic PRO for PIC32 General”