0

Hi,
I need to use LPT as SPI with CS DO CLK

But how to setup LPT pins for SPI

can I use D0 D1 D2 on lpt port for this ?
is this correct ?
lpt pin 2 CLK
Lpt pin 3 CS
Lpt pin 4 DI

Const Po378 = &H378, Pi379 = &H379, P37A = &H37A, P37B = &H37B

'commands string bit states
Const EhDhCh = 7 'cs hi, do hi, clk hi'' ready state
Const ElDhCh = 3 'cs lo, do hi, clk hi ' D2
Const ElDhCl = 2 'cs lo, do hi, clk lo ' D0
Const ElDlCh = 1 'cs lo, do lo, clk hi ' D1
Const ElDlCl = 0 'cs lo, do lo, clk lo
Const Dinp = &H80
CmdStr0 = Trim("111110010101111") 
'freq 99.7 Mhz = 997 in bin  + 4 bits config (1111)

Private Sub Command1_Click()
Dim p As Integer

'BH1415F
Out Po378, ElDhCh
'send  data bits msb 1st
For p = 1 To 15 
DoEvents
If Mid$(CmdStr0, p, 1) = "1" Then
Out Po378, ElDhCh
Out Po378, ElDhCl
Out Po378, ElDhCh
Else ' lo
Out Po378, ElDlCh
Out Po378, ElDlCl
Out Po378, ElDlCh
End If

Next p
Out Po378, EhDhCh
DoEvents
End Sub

Edited by kubic: n/a

1
Contributor
1
Reply
2
Views
6 Years
Discussion Span
Last Post by kubic
0

Or is this the right pin setup ?

Const EhDhCh = 7 'cs hi, do hi, clk hi'' D0 D1 D2 'ready state
Const ElDhCh = 3 'cs lo, do hi, clk hi ' D0 D1
Const ElDhCl = 2 'cs lo, do hi, clk lo ' D1
Const ElDlCh = 1 'cs lo, do lo, clk hi ' D0
Const ElDlCl = 0 'cs lo, do lo, clk lo

'D0 lpt pin 2 CLK
'D1 Lpt pin 3 DI
'D2 Lpt pin 4 CS
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.