I'm really hoping you have a solution. Please enlighten...
I'm really hoping you have a solution. Please enlighten...
It depends on what pins the serial data is coming in on too, hopefully they are all on only 2 PORTS.
Here's the idea.
In your PBP folder, open the .BAS file associated with the chip you are using. You'll see these variables.
PORTL VAR PORTB
PORTH VAR PORTC
TRISL VAR TRISB
TRISH VAR TRISC
They are the Starting locations for the Numbered Ports.
For 0-7 it uses PORTL and TRISL
for 8-15 it uses PORTH and TRISH
These can actually be assigned 2 different ports. You could have PORTL on PORTA, and PORTH on PORTE. Then 0-7 would be PORTA, and 8-15 would be PORTE.
DO NOT just edit the file. Comment out the lines, and declare the PORTs in your main program. This way when you write another program for that chip, the compiler will remind you that the file has been changed.
After that there are many ways to handle the numbers. But it's something like this.
PORTH VAR PORTE
TRISH VAR TRISE
P = 9 ; PORTE.1
SERIN2 P, 49236, [Commbyte]
Last edited by Darrel Taylor; - 19th July 2006 at 22:53. Reason: .
DT
D:
Thanks for the info, but I'll need another solution for my application. I'm using pins scattered across B, C, D, and E ports. For now I've hard-coded individual SELECT CASE statements for each comm group for both SERIN2 and SEROUT2 commands... yuk!
Too bad you can't alias individual array elements to user-defined pins. That would be sweet.
Any other suggestions out there??????????
Ok, then one more question.
16F or 18F?
DT
18F458 - 44pin plcc
blaine,
I think this might work for you.
It uses the same numbers that you were expecting before.
PORTA.0 = 0
PORTB.0 = 8
PORTE.1 = 33
SerinP2 will return 1 byte from the selected PIN. Received data will be in Commbyte.Code:P = 33 : gosub SetSerinPin GOSUB SerinP2
Code:;----------------------------------------------------------------------- @P_A = PORTA ; Find address for PORTA P_A CON EXT PinPort VAR WORD ; Address of selected Port PinBit VAR Byte ; Bit Mask of selected port SetSerinPin: PinPort = P_A + (P >> 3) ; PORTA + P/8 Find selected PORT PinBit = DCD (P & %111) ; create BIT mask return SerinP2: ; Get a BYTE from the specified PORT RM1 = PinBit RR1 = PinPort.LowByte RS1 = PinPort.HighByte @ SERIN2MODE?C 49236 @ SERIN2?B _Commbyte RETURN @ ifdef doesnotcompile ; Force PBP to include SERIN2 library SERIN2 1, 1, [Commbyte] @ endif ;-----------------------------------------------------------------------
DT
I'll have to study this, and will probably try it tonight or tomorrow; but, initially it looks exactly like what I'm looking for.
Elegant, clean, versatile, sweet!
Thanks D.
bcf
Bookmarks