Is it possible to pass a pin as parameter ?

Coding and general discussion relating to the compiler

Moderators: David Barker, Jerry Messina

Post Reply
Robert
Registered User
Registered User
Posts: 7
Joined: Fri Jul 04, 2008 2:11 pm
Location: France

Is it possible to pass a pin as parameter ?

Post by Robert » Fri Jul 04, 2008 5:20 pm

Good day everybody,
I am just discovering swordfish, and this is my first post on this forum.

I found the modularity of swordfish very handy, and I am looking for designing some modules as a training. One of them encapsulate the functions for use a max7219 for driving 7seg.

Here is my question: is there a way to pass the CS pin to the module "on the fly" ? I have a pic driving 2 max7219 sharing the same data and clock lines and must be able to select one or the other upon the datas to display. For that, I have to pass the relevant CS pin on the fly to the routines inside the module.

Is there a way to do that ?

By advance, thanks,

Robert

User avatar
David Barker
Swordfish Developer
Posts: 1214
Joined: Tue Oct 03, 2006 7:01 pm
Location: Saltburn by the Sea, UK
Contact:

Post by David Barker » Sat Jul 05, 2008 8:35 am

See the 'Blink - 2.bas' example supplied with the compiler. It's very simple to pass a pin, for example,

Code: Select all

Sub MySub(ByRef pPin As Bit)
   ... your code
End Sub
MySub(PORTD.7)

Robert
Registered User
Registered User
Posts: 7
Joined: Fri Jul 04, 2008 2:11 pm
Location: France

Post by Robert » Sat Jul 05, 2008 9:27 am

Hi David,
thanks for your answer. I go straight to look at this example...

regards,

Robert

Post Reply