PDA

View Full Version : Shot meself in the foot again...



muddy0409
- 20th June 2007, 10:16
Some time ago, I experimented with SHIFTOUT and got it working ok. Of course I didn't save the file anywhere, 'cos it was so easy. Now I want to use SHIFTOUT again but can't find any reference to the required DEFINEs, especially the one that sets the port for the clock & data lines. I am sure I remember that the PORT has to be defined somewhere, somehow so that I can just use a constant as the CLOCKPIN number rather than a full PORTX.Y. Can someone please point me at the correct DEFINEs that are required?????

Darrel Taylor
- 20th June 2007, 11:17
Ok Peter, Now put the gun down.

Cause you might shoot yourself in the head after this...
SHIFTOUT DataPin,ClockPin,Mode,[Var{\Bits}...]
| | ^
| | |
Data "Line"---' | |
Clock "Line"----' |
What to worry about------'

The only DEFINE is ....<pre>DEFINE SHIFT_PAUSEUS 50 'Slow down the Shiftin and Shiftout clock</pre>But it's unlikely you'll need it. SHIFTIN/OUT is pretty slow to begin with ... ~50khz.

Still here? Still got ammo in that gun? :)
<br>

muddy0409
- 21st June 2007, 13:15
The PBPbook says I can use a simple number for CLOCKPIN: SHIFTOUT,datapin,2,5,[var]...... DOESN'T GO. How is the beasty supposed to know that 2 means portc.2....The thing is I gotta use 0 - 7 as the clockpin and using a variable does not work! (I am feeding 8 shift registers sequentially)

I spoke to the bloke that has the old thing I did, but that is useless to me without a DE COMPILER (is there such a thing) to get it back to a language I can understand.
I have tried port indexing, using examples found in here also, but nothing seems to work. EG SHIFTOUT DAT,2,5,[S1] DAT is the DATAPIN which is common to all the S/Rs S1 is the data variable and 2 is the clockpin (goes to the second of 8 S/R's). This don't go.

SHIFTOUT DAT,portc.2,5,[S1] DOES go
SHIFTOUT DAT,sect,5,[S1] DON'T go (sect is the index var which is pointing at the relevant S/R.)
SHIFTOUT DAT,portc.0[sect],5,[S1] Also DON't go.

The overall program is running, as I can see the DATAPIN blinking away merrily on my logic probe, it's just the CLOCKPIN part that has me stymied.

If I do SHIFTOUT DAT,portc.2,5,[S1] and watch the clock on the S/R and the outputs from the S/R all is fine.

The thing I did a while ago works great (as a prototype) but I'm damned if I can remember what I did with this bit of code. IT BLOODY WORKS I TELL YA!!!!!
This current model is simply a smaller device with EXACTLY same circuit, so???????????????????????????????????????????????? ??????

Well, I s'pose something's gotta keep me up at night?



I think I'll try a new chip, but seeing that it does work sometimes, I'm not too excited about that fixing it.

mister_e
- 21st June 2007, 14:35
Number or PORT real name or Alias to pin it has to work

Have a look to section 4.11, or in MCS Help topics>>PICBASIC PRO Basics>>> Pins

To me, real port name (PORTB.3) or aliases (DO) is more valuable than pin #.

But... it's me ;)


SS var PORTB.1 ' ISD4002 SS pin
SCLK var PORTB.2 ' ISD4002 SCLK pin
MOSI var PORTB.3 ' ISD4002 MOSI pin
MISO var PORTB.4 ' ISD4002 MISO pin
'
'
'
'
ss = 0
shiftout MOSI,SCLK,LSBFIRST,[ISDword\16]
ss = 1
'
'
'
'
ss=0
shiftin miso,sclk,lsbpre,[isdpointer\16]
ss=1

Darrel Taylor
- 21st June 2007, 18:31
Peter,


How is the beasty supposed to know that 2 means portc.2....The thing is I gotta use 0 - 7 as the clockpin

Not sure if you really mean "I gotta use 0 - 7".

Usually PORTC.2 is number 10, but that depends on the chip you are using.
If you really need it to be 0-7, see this thread for how to change it.

http://www.picbasic.co.uk/forum/showthread.php?p=35224&highlight=PORTL+PORTH

HTH,

muddy0409
- 21st June 2007, 19:04
Right, I'll have a look at that in a jiffy.
Meantime, I "delooped" the thing and addressed each CLOCKPIN as exactly what it was, eg PORTC.0 up to PORTC.7 and now works perfect. Still don't think that was what I did on the previous thing but....


I'll go have a look at that link now and play around some more...

muddy0409
- 21st June 2007, 19:29
Yep, that done it.
Has anyone ever done a edited version of the PBP manual with all this stuff included? Or asked MELABS to add to the original manual?????????

Hope they are reading this!!!

Thanks shiploads blokes, you are life savers as always. I've locked the ammo away again, but kept the rifle out to belt meself about the head.

muddy0409
- 22nd June 2007, 09:30
Hi all.
As a follow-up to my previous, Would it be feasable to start a thread or even a full forum containing all those undocumented little gems that some people discovered. I think it would be a real good help to some people, 'specially twits like me?

selbstdual
- 5th July 2007, 20:45
Hey muddy0409, how does your foot feel in the meantime ?

muddy0409
- 6th July 2007, 04:10
Gettin' better slooooowwly!

Darrel Taylor
- 6th July 2007, 04:52
Peter,

You owe me $20.

For the dinner I just lost. :eek:
Eeeewwww.
<br>

SteveB
- 6th July 2007, 19:30
As Darrel has alluded to, viewer discretion is advised. Content may be upsetting to small children, or those with weak stomachs. :)

SteveB