PDA

View Full Version : Shiftout question.



muddy0409
- 2nd April 2007, 11:56
Hi all, once again a question for the brains trust.
I am using shiftout to drive some shift registers. Everything seems to work OK so far, BUT there is a question:
The manual says SHIFTOUT, Datapin,Clockpin,Mode,[data stuff] and then says the Datapin & Clockpin can be straight numbers, Port pin names, or variables.
So far so good.
I am using
DAT var portd.3 which is common data pin for all shift regs
sect VAR byte, (up the top with the other variable defs.)
SHIFTOUT DAT,sect,5,[S1]
S1 is the data byte,

sect is a variable simply containing a number 0 - 7 which is the portb pin for the clock of the 8 shift registers.

NOWHERE do I define that the number in sect variable is in fact portb.sect or anything like that, SO HOW DOES THE BLOODY THING KNOW THAT'S WHAT I MEAN????? 'COS IT WORKS????

Intriguing, ain't it??

Thanks, as always

skimask
- 2nd April 2007, 13:45
Sounds like a holdover from BS2, sorta like where you can use just the plain number (0-7, 8-15) to use as an alias for a pin on PortB or PortC (or PortD, not sure). Automatically defined, handled in the background, etc.etc. Heck, if it works...who cares :)

Darrel Taylor
- 2nd April 2007, 14:04
Hi Peter,

Those are "PIN Numbers".
Their location is specified by PORTL and PORTH.

See posts #4, 12 and 14 here ...
http://www.picbasic.co.uk/forum/showthread.php?t=6013
<br>

Pic_User
- 2nd April 2007, 14:41
Check this out:)


For compatibility with the BASIC Stamp, pins used in PicBasic Pro Compiler commands may also be referred to by a number, 0 - 15. This number references different physical pins on the PICmicro MCU hardware ports dependent on how many pins the microcontroller has.

If a port does not have 8 pins, such as PORTA, only the pin numbers that exist may be used, i.e. 8 - 12. Using pin numbers 13 - 15 will have no discernable effect.

This pin number, 0 - 15, has nothing to do with the physical pin number of a PICmicro MCU. Depending on the particular PICmicro MCU, pin number 0 could be physical pin 6, 21 or 33, but in each case it maps to PORTB.0 (or GPIO.0 for 8-pin devices, or PORTC.0 for a PIC14000).

-Adam-

muddy0409
- 2nd April 2007, 15:10
Hmmmm..
Yeah, I thought it was probably sumpthin' like that. Is there any documentation around for the pin numbering as mentioned and as to what port lines they refer to on different PICs??

Pic_User
- 2nd April 2007, 15:57
PicBasic Pro Compiler manual
http://www.picbasic.co.uk/forum/attachment.php?attachmentid=1512&stc=1&d=1175525419
-Adam-