************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
Porta.0[14,20 or 26] is supposed to be an undeclared array and since the PORTS are located sequentially in memory PicBasic Pro takes the value in brackets and treats it as an offset from porta.0 so
porta.0[1] is porta.1
porta.0[8] is portb.0
The problem with using loops and select case is that my code will start to get really long and nasty looking.
Can someone explain why this will not work with the serout/serin functions? I had given up doing it this way and writing the program using cases for each pair of ports that I want to talk to, but it is looking like i am going to run out of flash memory on the PIC doing it this way.
Relay var Byte[4]
x var byte
i var byte
Relay[1] = 14 'RB6
Relay[2] = 20 'RC4
Relay[3] = 26 'RD2
main:
' cycle through relays
for i = 1 to 3
x = relay[i]
serout2 porta.0[x], 8276, ["hello"]
PAUSE 300
next i
porta.0[x] is an Array function.
When used with HIGH LOW SEROUT or any command other than a math formula, it reads the indicated array element (a pin) and returns the value to be used in the command.
Since it's a BIT Array, it will only return a 0 or 1 depending on the state of the indexed PIN.
Therefore, the serout2 command will only output on PORTB.0 or PORTB.1
To reiterate my previous recommendation ...
If you moved your serial outputs so they are all on two PORTs, instead of scattered across 3 or four ports ... you can do exactly what you want by using pin "Numbers", and a very small bit of code.
DT
Ok, so am I just out of luck using some kind of loop to reduce code and make it easier to modify the in the future if I want to use ports ABCDE? Not because I have them spread out but I just have that many serial devices I want to talk to. What is the reason why there are only 2 ports at a time that you can reference with a pin "number".
Can I change PORTL and PORTH during runtime to other ports?
Thanks.
Bookmarks