Shop OBEX P1 Docs P2 Docs Learn Events
functions and pin parameters in SX/B — Parallax Forums

functions and pin parameters in SX/B

DunnseptDunnsept Posts: 115
edited 2007-03-30 20:42 in General Discussion
Hey guys, haven't posted in a long time, so .. here goes:

I would like to write a function that would have a PIN as a parameter and would return a word.
The assembler is complaining that my parameter is not a hardware pin

so, how do I pass a pin as a parameter?· This is going to be for controlling DS2760's so I would much rather
have functions than have to duplicate code.

code is something like

mash var RA.0
 
check_temp func 1
 
main:
     hlt_temp = check_temp mash
 
 goto main
 
 
check_temp:
     which_ds = __param1
   'whole bunch o 1wire stuff
 
   return theTemp

but the compiler complains on the __param1 line that "bit is not a hardware pin"

thanks!

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
stand back! I have a slide rule and I know how to use it!

Comments

  • JonnyMacJonnyMac Posts: 8,941
    edited 2007-03-30 18:56
    You can't pass a pin (e.g., RA.0) as a parameter. If you're using 1-Wire, why wouldn't you have just one buss and identify the units by their serial number?
  • DunnseptDunnsept Posts: 115
    edited 2007-03-30 19:03
    yea.. I was just trying to figure out other ways to do this. I've got plenty of pins open and kinda thought instead of having to deal with figuring out the serials I would just put them on different pins and call it good.

    currently using an SX tech board, can I just go from, say RB.0 to data pin on one DS2760 and then jumper over to data pin on other DS2760?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    stand back! I have a slide rule and I know how to use it!
  • JonnyMacJonnyMac Posts: 8,941
    edited 2007-03-30 19:41
    Yes. You'll put a 4.7K pull-up on RA.0 for the buss. All of your 1-Wire devices connect to this. To be candid, I find 1-Wire more trouble than it's worth and tend to choose I2C parts -- IMHO it's easier to give up an additional pin than to implement all the interfacing code to deal with the 1W serial numbers. But if your part is unique to 1W, you just have to go the code route.
  • DunnseptDunnsept Posts: 115
    edited 2007-03-30 20:02
    well, I'm working with the DS2760 kits from parallax.. so all I have to do is hookup vdd, vss and data.. good to go. just trying to consolidate code so I can run 2 of these, plus 3 displays..running out of space already

    thanks

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    stand back! I have a slide rule and I know how to use it!
  • JonnyMacJonnyMac Posts: 8,941
    edited 2007-03-30 20:23
    I'm a bit packed up now, but I'll get one of those out and see what I can come up in the next couple weeks.
  • DunnseptDunnsept Posts: 115
    edited 2007-03-30 20:42
    dont worry about it.. I'll get it eventually. Just finally getting back into programming these things (sx) after a hiatus. gotta get back into the swing of things.
    thanks for the offer

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    stand back! I have a slide rule and I know how to use it!
Sign In or Register to comment.