oopic oSPIL and a 74165 - bimityedye - Jun 5 14:58:37 2008
AAAAARRRRGGGG!!! I'm pulling my hair out!! I'm trying to access a
74hc165 using an oSPIL object, but to no avail. Nothing I do seems to
work. Does anyone have the magic code to make this work? I can bit
bang it well enough, but I should be able to do this with an oSPIL.
Anybody? A mind is a terrible thing. Help! oopic III+ ver 6 compiler
curent code -
Dim C165 As oSPIL
Dim Load As oDIO1
Dim Data As oByte
Dim Screen As oLCDSE
'*******************
Sub main()
Call setup
Screen.Clear
Load = 0 'Pulse Load line to input parallel
Load = 1 'data
ooPIC.Delay = 5000
Data.Value = C165.Value 'Read 74165
Screen.VString = "***********"
ooPIC.Delay = 5000
Screen.Locate(1,0)
Screen.Value = Data.Value
End Sub'Main
'********************
Sub setup()
C165.IOLineC = 8 'Use as Clock input to '165 pin 2
C165.IOLineI = 10 'Use as Data line from '165 pin 9
C165.IOLineE = 12 'Use as Clock Inhibit to '165 pin 15
C165.InvertE = cvTrue
C165.Rate = 0
C165.Width = 0
C165.Mode = 0
C165.Direction = 0
C165.Operate = cvTrue
Load.IOLine = 14 'Use as Load line to '165 pin 1
Load.High
Screen.IOLine = 16
Screen.Clear
Screen.Locate(0,0)
Dave W.
------------------------------------

(You need to be a member of oopic -- send a blank email to oopic-subscribe@yahoogroups.com )
Re: oopic oSPIL and a 74165 - rtstofer - Jun 6 9:50:22 2008
Look at IOLineE. Does it idle high or low after you invert the sense.
In a normal SPI application the enable idles high and goes low to
select the device. That's fine, just what you want as the clock
inhibit needs to be low to shift data. But you inverted it...
Check with an LED, logic probe or scope.
Since you know you need the inhibit signal at 0, remove it from the
OOPic and ground it at the '165.
Similarly, you know you need Load high. I see where you defined the
Load pin but I don't see where you made it an output. Maybe you
should disconnect that from the OOPic and pull it high through a
resistor. You can momentarily ground the pin to load something using a
jumper. It won't matter if the signal isn't clean.
At this point, all you have connected is the serial input and the
clock. Check it out and then start putting it back together.
Richard
--- In o...@yahoogroups.com, "bimityedye"
wrote:
>
> AAAAARRRRGGGG!!! I'm pulling my hair out!! I'm trying to access a
> 74hc165 using an oSPIL object, but to no avail. Nothing I do seems to
> work. Does anyone have the magic code to make this work? I can bit
> bang it well enough, but I should be able to do this with an oSPIL.
> Anybody? A mind is a terrible thing. Help! oopic III+ ver 6 compiler
> curent code -
>
> Dim C165 As oSPIL
> Dim Load As oDIO1
> Dim Data As oByte
> Dim Screen As oLCDSE
> '*******************
> Sub main()
>
> Call setup
>
> Screen.Clear
>
> Load = 0 'Pulse Load line to input parallel
> Load = 1 'data
> ooPIC.Delay = 5000
>
> Data.Value = C165.Value 'Read 74165
>
> Screen.VString = "***********"
> ooPIC.Delay = 5000
> Screen.Locate(1,0)
> Screen.Value = Data.Value
>
> End Sub'Main
> '********************
> Sub setup()
>
> C165.IOLineC = 8 'Use as Clock input to '165 pin 2
> C165.IOLineI = 10 'Use as Data line from '165 pin 9
> C165.IOLineE = 12 'Use as Clock Inhibit to '165 pin 15
> C165.InvertE = cvTrue
> C165.Rate = 0
> C165.Width = 0
> C165.Mode = 0
> C165.Direction = 0
> C165.Operate = cvTrue
>
> Load.IOLine = 14 'Use as Load line to '165 pin 1
> Load.High
>
> Screen.IOLine = 16
> Screen.Clear
> Screen.Locate(0,0)
> Dave W.
>
------------------------------------

(You need to be a member of oopic -- send a blank email to oopic-subscribe@yahoogroups.com )Re: Re: oopic oSPIL and a 74165 - David Warner - Jun 7 12:35:06 2008
Richard
Here's my current code - I've got good signals for Load and ClkInhibit but absolutely 0
for Clk coming from the OOPIC and 0 info from the 74165 (probably because no CLK from
OOPIC). Now I've loaded some oSPIL programs from the Examples directory and they all have
good signals for the CLK from the OOPIC. Am I using the wrong syntax for reading the oSPIL
object? What could be my stumbling block?
Regards
Dave W.
'********************
'Declarations
Dim C165 As oSPIL
Dim Load As oDIO1
Dim Info As oByte
Dim Screen As oLCDSE
Dim ClkInhibit As oDIO1
'*******************
Sub main()
Call setup
Do
Screen.Clear
Screen.VString = "***********"
ooPIC.Delay=5000
Load.Value = 0 '/
ooPIC.Delay = 1000 '/ Latches Parallel Input lines
Load.Value = 1 '/
ClkInhibit.Value = 0 'remove ClkInhibit
ooPIC.Delay = 1000
Info.Data = C165.Value 'Read 74165
ClkInhibit = 1 'Restore
ClkInhibit
Screen.Locate(1,0)
Screen.VString = Str$(Info.Data) 'Display Data
ooPIC.Delay=5000
Loop
End Sub'Main
'********************
Sub setup()
C165.IOLineC = 9 'Use as Clock input to '165 pin 2
C165.IOLineI = 10 'Use as Data line from '165 pin 9
C165.Rate = 0
C165.Width = cv8Bit
C165.Mode = 0
C165.Operate = cvOn
ClkInhibit.IOLine = 12 'Use as ClkInhibit to '165 pin 15
ClkInhibit.Direction = cvOutput
ClkInhibit.Value = 1
Load.IOLine = 14 'Use as Load to '165 pin 1
Load.Direction = cvOutput
Load.Value = 1
Screen.IOLine = 16
Screen.Clear
Screen.Locate(0,0)
--- On Fri, 6/6/08, rtstofer <r...@pacbell.net> wrote:
From: rtstofer <r...@pacbell.net>
Subject: [oopic] Re: oopic oSPIL and a 74165
To: o...@yahoogroups.com
Date: Friday, June 6, 2008, 1:49 PM
Look at IOLineE. Does it idle high or low after you invert the sense.
In a normal SPI application the enable idles high and goes low to
select the device. That's fine, just what you want as the clock
inhibit needs to be low to shift data. But you inverted it...
Check with an LED, logic probe or scope.
Since you know you need the inhibit signal at 0, remove it from the
OOPic and ground it at the '165.
Similarly, you know you need Load high. I see where you defined the
Load pin but I don't see where you made it an output. Maybe you
should disconnect that from the OOPic and pull it high through a
resistor. You can momentarily ground the pin to load something using a
jumper. It won't matter if the signal isn't clean.
At this point, all you have connected is the serial input and the
clock. Check it out and then start putting it back together.
Richard
--- In oopic@yahoogroups. com, "bimityedye" <bimityedye@ ...> wrote:
>
> AAAAARRRRGGGG! !! I'm pulling my hair out!! I'm trying to access a
> 74hc165 using an oSPIL object, but to no avail. Nothing I do seems to
> work. Does anyone have the magic code to make this work? I can bit
> bang it well enough, but I should be able to do this with an oSPIL.
> Anybody? A mind is a terrible thing. Help! oopic III+ ver 6 compiler
> curent code -
>
> Dim C165 As oSPIL
> Dim Load As oDIO1
> Dim Data As oByte
> Dim Screen As oLCDSE
>
>
> '*********** ********
> Sub main()
>
> Call setup
>
> Screen.Clear
>
> Load = 0 'Pulse Load line to input parallel
> Load = 1 'data
> ooPIC.Delay = 5000
>
> Data.Value = C165.Value 'Read 74165
>
> Screen.VString = "*********** "
> ooPIC.Delay = 5000
> Screen.Locate( 1,0)
> Screen.Value = Data.Value
>
>
>
> End Sub'Main
> '*********** *********
> Sub setup()
>
> C165.IOLineC = 8 'Use as Clock input to '165 pin 2
> C165.IOLineI = 10 'Use as Data line from '165 pin 9
> C165.IOLineE = 12 'Use as Clock Inhibit to '165 pin 15
> C165.InvertE = cvTrue
> C165.Rate = 0
> C165.Width = 0
> C165.Mode = 0
> C165.Direction = 0
> C165.Operate = cvTrue
>
> Load.IOLine = 14 'Use as Load line to '165 pin 1
> Load.High
>
> Screen.IOLine = 16
> Screen.Clear
> Screen.Locate( 0,0)
>
>
> Dave W.
>
[Non-text portions of this message have been removed]
------------------------------------

(You need to be a member of oopic -- send a blank email to oopic-subscribe@yahoogroups.com )
Re: oopic oSPIL and a 74165 - rtstofer - Jun 7 17:18:53 2008
--- In o...@yahoogroups.com, David Warner
wrote:
>
> Richard
> Here's my current code - I've got good signals for Load and
ClkInhibit but absolutely 0 for Clk coming from the OOPIC and 0
info from the 74165 (probably because no CLK from OOPIC). Now I've
loaded some oSPIL programs from the Examples directory and they all
have good signals for the CLK from the OOPIC. Am I using the wrong
syntax for reading the oSPIL object? What could be my stumbling
block?
> Regards
> Dave W
This code works for me! The clock pulses are a little over 20 uS
wide repeating every 80 uS. It takes a little over 600 uS to shift a
byte. Bytes are being shifted every 15 mS, more or less.
Dim C165 As oSPIL
Dim Load As oDIO1
Dim Info As oByte
Dim ClkInhibit As oDIO1
Sub main()
ooPIC.Delay = 5000
Call setup
Do
Load.Value = 0
Load.Value = 1
ClkInhibit.Value = 0
Info.Data = C165.Value
ClkInhibit = 1
Loop
End Sub
Sub setup()
C165.IOLineC = 9
C165.IOLineI = 10
C165.Rate = 0
C165.Width = cv8Bit
C165.Mode = 0
C165.Operate = cvOn
ClkInhibit.IOLine = 12
ClkInhibit.Direction = cvOutput
ClkInhibit.Value = 1
Load.IOLine = 14
Load.Direction = cvOutput
Load.Value = 1
End Sub
Richard
------------------------------------

(You need to be a member of oopic -- send a blank email to oopic-subscribe@yahoogroups.com )Re: oopic oSPIL and a 74165 - rtstofer - Jun 7 17:22:55 2008
--- In o...@yahoogroups.com, "rtstofer"
wrote:
>
> --- In o...@yahoogroups.com, David Warner wrote:
> >
> > Richard
> > Here's my current code - I've got good signals for Load and
> ClkInhibit but absolutely 0 for Clk coming from the OOPIC and
0
> info from the 74165 (probably because no CLK from OOPIC). Now I've
> loaded some oSPIL programs from the Examples directory and they all
> have good signals for the CLK from the OOPIC. Am I using the wrong
> syntax for reading the oSPIL object? What could be my
stumbling
> block?
> > Regards
> > Dave W
>
> This code works for me! The clock pulses are a little over 20 uS
> wide repeating every 80 uS. It takes a little over 600 uS to shift
a
> byte. Bytes are being shifted every 15 mS, more or less.
>
> Dim C165 As oSPIL
> Dim Load As oDIO1
> Dim Info As oByte
> Dim ClkInhibit As oDIO1
>
> Sub main()
>
> ooPIC.Delay = 5000
> Call setup
> Do
> Load.Value = 0
> Load.Value = 1
>
> ClkInhibit.Value = 0
> Info.Data = C165.Value
> ClkInhibit = 1
>
> Loop
>
> End Sub
>
> Sub setup()
>
> C165.IOLineC = 9
> C165.IOLineI = 10
> C165.Rate = 0
> C165.Width = cv8Bit
> C165.Mode = 0
> C165.Operate = cvOn
>
> ClkInhibit.IOLine = 12
> ClkInhibit.Direction = cvOutput
> ClkInhibit.Value = 1
>
> Load.IOLine = 14
> Load.Direction = cvOutput
> Load.Value = 1
>
> End Sub
>
> Richard
>
I should have said the code works on a scope. It don't have a '165
and I am using a B.2.2+ chip.
Richard
------------------------------------

(You need to be a member of oopic -- send a blank email to oopic-subscribe@yahoogroups.com )Re: oopic oSPIL and a 74165 - rtstofer - Jun 7 20:50:08 2008
>
> ClkInhibit.IOLine = 12
> ClkInhibit.Direction = cvOutput
> ClkInhibit.Value = 1
>
> Load.IOLine = 14
> Load.Direction = cvOutput
> Load.Value = 1
>
Another thought: set the .Value property BEFORE you set the .Direction
property to avoid a glitch. The IOLines will be floating high. As
soon as you set the .Direction they will pull low. Then they will go
high when you set the .Value.
Setting the .Value first will insure they change from floating high to
pulled high without going low.
It may not matter in this application but, in general, that is the
proper way to set output bits on uC's.
One way to guarantee the pins are floating high at reset is to put a
10k pull-up resistor on the pin.
Richard
------------------------------------

(You need to be a member of oopic -- send a blank email to oopic-subscribe@yahoogroups.com )
Re: Re: oopic oSPIL and a 74165 - ooPIC Tech Support - Jun 8 0:45:42 2008
Yes, it is always worth it to set the initial state of both the clock
and the data lines.
DLC
rtstofer wrote:
>> ClkInhibit.IOLine = 12
>> ClkInhibit.Direction = cvOutput
>> ClkInhibit.Value = 1
>>
>> Load.IOLine = 14
>> Load.Direction = cvOutput
>> Load.Value = 1
>>
>>
>
> Another thought: set the .Value property BEFORE you set the .Direction
> property to avoid a glitch. The IOLines will be floating high. As
> soon as you set the .Direction they will pull low. Then they will go
> high when you set the .Value.
>
> Setting the .Value first will insure they change from floating high to
> pulled high without going low.
>
> It may not matter in this application but, in general, that is the
> proper way to set output bits on uC's.
>
> One way to guarantee the pins are floating high at reset is to put a
> 10k pull-up resistor on the pin.
>
> Richard
>
> ------------------------------------

(You need to be a member of oopic -- send a blank email to oopic-subscribe@yahoogroups.com )
RE: Re: oopic oSPIL and a 74165 - Dave Warner - Jun 8 7:03:21 2008
Well I've got to say it guys, this one has beaten me. I've gotta move on. If anybody else
gas managed to interface a 74165 to an OOPIC by way of oSPIL drop me a line. For me, he
wasn't possible, call it what you will impatience, cowardice, ... I think there's an
incompatiblity there somewhere. Maybe it's just me!
https://www.invite2messenger.net/im/?source=TXT_EML_WLH_InviteFriends
[Non-text portions of this message have been removed]
------------------------------------

(You need to be a member of oopic -- send a blank email to oopic-subscribe@yahoogroups.com )
Re: oopic oSPIL and a 74165 - rtstofer - Jun 8 9:27:43 2008
--- In o...@yahoogroups.com, Dave Warner
wrote:
> Well I've got to say it guys, this one has beaten me. I've gotta
move on. If anybody else gas managed to interface a 74165 to an OOPIC
by way of oSPIL drop me a line. For me, he wasn't possible, call it
what you will impatience, cowardice, ... I think there's an
incompatiblity there somewhere. Maybe it's just me!
> https://www.invite2messenger.net/im/?source=TXT_EML_WLH_InviteFriends
>
> [Non-text portions of this message have been removed]
>
Without a 74HC165, I can't test the code. But I can find a better
datasheet than I was using. The TI datasheet is here:
http://focus.ti.com/lit/ds/symlink/sn74hc165.pdf
It has a much better logic diagram and it has a discussion about CLK INH
QUOTE
Clocking is accomplished by a low-to-high transition of the clock
(CLK) input while SH/LD is held high and CLK
INH is held low. The functions of CLK and CLK INH are interchangeable.
Since a low CLK and a low-to-high
transition of CLK INH also accomplish clocking, CLK INH should be
changed to the high level only while CLK
is high. Parallel loading is inhibited when SH/LD is held high. While
SH/LD is low, the parallel inputs to the
register are enabled independently of the levels of the CLK, CLK INH,
or serial (SER) inputs.
END QUOTE
So, the code doesn't handle CLK INH properly. In fact, the best thing
to do is ground the pin and ignore it. The internal flops are clocked
by the logical OR of the CLK INH and CLK inputs. Only one is necessary.
The code also takes more time to execute when it handles CLK INH. But
the good news is that the IOLine can be used to trigger a logic
analyzer and serves to frame the transaction. Just don't connect it
to the '165. Lacking a logic analyzer, it is probably better to just
remove the object and code.
NOTE 3 on page 4 is also important. ALL INPUTS must be either logic 0
or logic 1, they can not be left floating. TI has an application
report that deals with this and I think it says the device will be
damaged due to excess current flow. Do you KNOW your '165 is working?
You can test it with your bit-banged code. That will also test your
electrical interface.
Next time I order something from Digikey, I'll add a couple of
74HC165's and see how it comes out. From the scope, I think it works.
Richard
------------------------------------

(You need to be a member of oopic -- send a blank email to oopic-subscribe@yahoogroups.com )Re: oopic oSPIL and a 74165 - I Got It To WORK! - rtstofer - Jun 8 12:15:08 2008
I didn't have a '165 so I built one from a CPLD and a little VHDL
code based on the logic diagram from TI. It works...
The thing is, you have to define IOLines for all of the oSPIL signals
whether you use them or not. In other words, you need to add in setup
():
C165.IOLineO = 11
C165.IOLineE = 12
I added a serial port to the code so I could see the result:
Dim C165 As oSPIL
Dim Load As oDIO1
Dim Info As oByte
Dim Serial As New oSerialPort
Sub main()
ooPIC.Delay = 5000
Call setup
Serial.String = "Hello"
Do
Load.Value = 0
Load.Value = 1
Info.Data = C165.Value
Serial.String = Str$(Info.Data)
Serial = 13
Serial = 10
Loop
End Sub
Sub setup()
C165.IOLineC = 9
C165.IOLineI = 10
C165.IOLineO = 11
C165.IOLineE = 12
C165.Rate = 0
C165.Width = cv8Bit
C165.Mode = 0
C165.Operate = cvOn
Load.IOLine = 14
Load.Direction = cvOutput
Load.Value = 1
Serial.Baud = cv9600
Serial.Operate = cvTrue
End Sub
I couldn't get the Comm window in V6 to work reliably. Then again,
Hyperterminal doesn't always connect either. I looked at the serial
transmit pin to verify I was sending stuff and them kept kicking at
Hyperterminal until it worked. What a piece of crap!
So, lesson learned: just because the 'scope makes it look like the
object is working doesn't mean it actually receives anything.
Sometimes you just have to connect to real hardware.
Lesson reinforced: CPLDs are a lot of fun.
Richard
------------------------------------

(You need to be a member of oopic -- send a blank email to oopic-subscribe@yahoogroups.com )
Re: Re: oopic oSPIL and a 74165 - I Got It To WORK! - David Warner - Jun 8 14:27:12 2008
Richard YOU ARE A GENIUS! I added the full complement of signals for the oSPIL and
THAT did the trick! I also dropped the ClkInhibit line and tied that off to Ground.
Now when I switch my data lines around I get a different reading (correct) every time.
Thanks so much for hangin' in with me even when I gave up! I've gotta scrounge a 'scope
from somewhere. WHOO_HOO I can move on. Thanks again man.
Dave W.
--- On Sun, 6/8/08, rtstofer <r...@pacbell.net> wrote:
From: rtstofer <r...@pacbell.net>
Subject: [oopic] Re: oopic oSPIL and a 74165 - I Got It To WORK!
To: o...@yahoogroups.com
Date: Sunday, June 8, 2008, 4:15 PM
I didn't have a '165 so I built one from a CPLD and a little VHDL
code based on the logic diagram from TI. It works...
The thing is, you have to define IOLines for all of the oSPIL signals
whether you use them or not. In other words, you need to add in setup
():
C165.IOLineO = 11
C165.IOLineE = 12
I added a serial port to the code so I could see the result:
Dim C165 As oSPIL
Dim Load As oDIO1
Dim Info As oByte
Dim Serial As New oSerialPort
Sub main()
ooPIC.Delay = 5000
Call setup
Serial.String = "Hello"
Do
Load.Value = 0
Load.Value = 1
Info.Data = C165.Value
Serial.String = Str$(Info.Data)
Serial = 13
Serial = 10
Loop
End Sub
Sub setup()
C165.IOLineC = 9
C165.IOLineI = 10
C165.IOLineO = 11
C165.IOLineE = 12
C165.Rate = 0
C165.Width = cv8Bit
C165.Mode = 0
C165.Operate = cvOn
Load.IOLine = 14
Load.Direction = cvOutput
Load.Value = 1
Serial.Baud = cv9600
Serial.Operate = cvTrue
End Sub
I couldn't get the Comm window in V6 to work reliably. Then again,
Hyperterminal doesn't always connect either. I looked at the serial
transmit pin to verify I was sending stuff and them kept kicking at
Hyperterminal until it worked. What a piece of crap!
So, lesson learned: just because the 'scope makes it look like the
object is working doesn't mean it actually receives anything.
Sometimes you just have to connect to real hardware.
Lesson reinforced: CPLDs are a lot of fun.
Richard
[Non-text portions of this message have been removed]
------------------------------------

(You need to be a member of oopic -- send a blank email to oopic-subscribe@yahoogroups.com )
Re: oopic oSPIL and a 74165 - Improved! - rtstofer - Jun 8 17:35:45 2008
Given that the OOPic is going to generate an enable signal, we might
as well use it to drive the SH/LD' input. The Load object and code
is redundant.
Dim C165 As oSPIL
Dim Info As oByte
Dim Serial As New oSerialPort
Sub main()
ooPIC.Delay = 5000
Call setup
Serial.String = "Hello"
Do
Info.Data = C165.Value
Serial.String = Str$(Info.Data)
Serial = 13
Serial = 10
Loop
End Sub
Sub setup()
C165.IOLineC = 9
C165.IOLineI = 10
C165.IOLineO = 11
C165.IOLineE = 12
C165.Rate = 0
C165.Width = cv8Bit
C165.Mode = 0
C165.Operate = cvOn
Serial.Baud = cv9600
Serial.Operate = cvTrue
End Sub
The reason it works is that the load input of the '156 is
asynchronous (not clocked). So, the OOPic will normally hold the
signal low (shift register follows inputs continually) until we start
to read. At that point the OOPic will set the enable signal high
which will put the '156 into Shift mode, latching the current value
of the inputs - just what we want.
See if it works for you...
Richard
------------------------------------

(You need to be a member of oopic -- send a blank email to oopic-subscribe@yahoogroups.com )