I am connecting 15 serial devices to a 40 pin PIC (18F452) and I was wondering if there was a way to have a variable number: 1-15 select which port the serial data is sent to?
For example:
-------------------
SELECT CASE address
CASE 1
port var portd.0
CASE 2
port var portd.1
CASE 3
port var portd.2
CASE ELSE
goto error
END SELECT
SerOut2 port,baud,["output string",10,13]
-------------------
Where "address" is a variable byte that stores a decimal number.
This example will not compile since you are not allowed to declare an alias more than once.
I also tried a LOOKUP statement but I cannot store the port addresses (or alias) into variable bytes or words. I also thought about using the address variable and the Pin numbers but since I am dealing with a larger PIC, I cannot access all of this pins with this command.
Any ideas on how to do this without making a routine for each port that I need to read/write to?
THANKS!
Bookmarks