Sub with parameters problem
For the life of me, I cannot find the problem with the snippet below. I am trying to create a new Sub, TX1_Byte, which will take in one to four parameters. It seems to work ok with one parameter, but it will not work with two or more parameters. I just can't see the problem. Maybe there is a better way to accomplish this?
Thanks
Ray
****************
temp1 var Byte (4)
TX1_Byte sub 1,4
TX1_Byte:
'Fills the array with PARAM values
·· temp1(0) = __PARAM1
·· temp1(1) = __PARAM2
·· temp1(2) = __PARAM3
·· temp1(3) = __PARAM4
·· temp2 = __PARAMCNT··· 'Get the PARAMCNT
·· do while temp2 > 0···· 'Is the PARAMCNT greater than 0
···· serout tx1, T57600, temp1(0)
···· dec temp2······· 'Reduce the PARAMCNT value by 1
···· inc temp1(0)··· 'Will it increment the array to the next element?
·· loop
return
Thanks
Ray
****************
temp1 var Byte (4)
TX1_Byte sub 1,4
TX1_Byte:
'Fills the array with PARAM values
·· temp1(0) = __PARAM1
·· temp1(1) = __PARAM2
·· temp1(2) = __PARAM3
·· temp1(3) = __PARAM4
·· temp2 = __PARAMCNT··· 'Get the PARAMCNT
·· do while temp2 > 0···· 'Is the PARAMCNT greater than 0
···· serout tx1, T57600, temp1(0)
···· dec temp2······· 'Reduce the PARAMCNT value by 1
···· inc temp1(0)··· 'Will it increment the array to the next element?
·· loop
return
Comments
I think you want:
temp1(0) = temp1(1)
temp1(1) = temp1(2)
temp1(2) = temp1(3)
This will shift the elements down so temp1(0) is the next value.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Teacher: What is the difference between ignorance and apathy ?
Student: I don't know and I don't care
Teacher: Correct !
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.hittconsulting.com
·
****************
x var byte
temp1 var Byte (4)
TX1_Byte sub 1,4
TX1_Byte:
'Fills the array with PARAM values
·· temp1(0) = __PARAM1
·· temp1(1) = __PARAM2
·· temp1(2) = __PARAM3
·· temp1(3) = __PARAM4
·· temp2 = __PARAMCNT··· 'Get the PARAMCNT
·· do while temp2 > 0···· 'Is the PARAMCNT greater than 0
···· serout tx1, T57600, temp1(x)
···· dec temp2······· 'Reduce the PARAMCNT value by 1
···· inc·x·· 'Will it increment the array to the next element?
·· loop
return
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
While on the SUB and serin/serout topic, has anybody created a sub for serin/serout. What I am thinking is something like Ser_In/Ser_Out sub with·three parameters. That way you could use it like this:
· Ser_Out TX1, T57600, 'A'···· 'TX1 could be re.0
· Ser_Out TX2, N19200, 128··· 'TX2 could be re.2
Using this method, you could access the different pins from your code line, and the code generated would only being using one instance of serin/serout, I think. With only 4096 bytes of code space, I would like·to minimize as much as possible.
Thanks
Ray
My understanding is that the pin designator of the SEROUT command (or any other SX/B command) can not be a variable.
- Sparks
Ray