Shop OBEX P1 Docs P2 Docs Learn Events
Conditional Compile Directives & Multiple program slots — Parallax Forums

Conditional Compile Directives & Multiple program slots

KurtKurt Posts: 7
edited 2005-03-12 15:55 in BASIC Stamp
Hi:

I'm hoping the answer is yes smile.gif

Can I·define a conditional compile variable in my Slot 0 code that works during compile throughout the other Slots? In other words, I have this code in JEM5 Init.bpe (Slot 0):

'{$STAMP BS2pe,MainLoop.bpe,Announce.bpe,ISDDATA.BPE,GPS.bpe,DTMF.bpe}
'{$PBASIC 2.5}
' 20050308 -kk Setup for Loading all boards (enter JEM5 S/N in the "BoadNumber" constant
' Code rev 2.1.0
 
'+++++++++++++++++++++++++
' Compile Directives
'+++++++++++++++++++++++++
 
#DEFINE BoardNumber = 10


It seems that I need to put this is each succesive slot as well in order to have this symbol evaluated in the "Announce.bpe" program.· I'm hoping that I can define all variables in one place i.e "JEM5 Init.bpe".

BTW - Here's some of the "later" code that is effected by the conditional:

InitTemp:
DEBUG "Init Temperature", CR
ConvTemp:
#SELECT BoardNumber
#CASE 10
  OWOUT OneWire, 1, [noparse][[/noparse]MatchROM,$28,$20,$C2,$76,$00,$00,$00,$A8, ConvertTemp]  ' Send Calculate Temperature command
#CASE 09
  OWOUT OneWire, 1, [noparse][[/noparse]MatchROM,$28,$92,$D2,$76,$00,$00,$00,$BD, ConvertTemp]  ' Send Calculate Temperature command
#CASE 08
  OWOUT OneWire, 1, [noparse][[/noparse]MatchROM,$28,$9B,$19,$76,$00,$00,$00,$79, ConvertTemp]  ' Send Calculate Temperature command
#CASE 07
  OWOUT OneWire, 1, [noparse][[/noparse]MatchROM,$28,$27,$CE,$76,$00,$00,$00,$0C, ConvertTemp]  ' Send Calculate Temperature command
#CASE 06
  OWOUT OneWire, 1, [noparse][[/noparse]MatchROM,$28,$F3,$B7,$76,$00,$00,$00,$8A, ConvertTemp]  ' Send Calculate Temperature command
#CASE 05
  OWOUT OneWire, 1, [noparse][[/noparse]MatchROM,$28,$B1,$B5,$76,$00,$00,$00,$12, ConvertTemp]  ' Send Calculate Temperature command
#CASE 04
  OWOUT OneWire, 1, [noparse][[/noparse]MatchROM,$28,$01,$D6,$76,$00,$00,$00,$4A, ConvertTemp]  ' Send Calculate Temperature command
#CASE 03
  OWOUT OneWire, 1, [noparse][[/noparse]MatchROM,$28,$0F,$C1,$76,$00,$00,$00,$74, ConvertTemp]  ' Send Calculate Temperature command
#CASE 02
  OWOUT OneWire, 1, [noparse][[/noparse]MatchROM,$28,$CB,$D4,$76,$00,$00,$00,$99, ConvertTemp]  ' Send Calculate Temperature command
#CASE 01
  OWOUT OneWire, 1, [noparse][[/noparse]MatchROM,, ConvertTemp]  ' Send Calculate Temperature command
#ENDSELECT



Thanks,

Kurt

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
kk

Comments

  • GadgetmanGadgetman Posts: 2,436
    edited 2005-03-11 20:31
    I'm sorry, but you'll need to define your variables in all the slots.

    Note: Be very careful with getting thedefinitions right because the compiler assigns variable names to locations according to certain rules:
    1. Largest first.
    2. Variables of same size is taken in order.
  • KurtKurt Posts: 7
    edited 2005-03-11 22:09
    Thanks Gadgetman. But - I think you are referring to regular "memory" variables. My question is specific to Compile Time Directives. I'm not aware of any size or order limitations on these...

    I do understand the issues with preserving standard variables. Infact, I just use the scratchpad and move data inbetween slots that way.

    Any more input on Compile Time Variables?

    Anyone?

    Kurt

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    kk
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-03-11 23:18
    Each program slot is independently compiled, so you will need to copy your declarations to the other slots.

    Here's an idea that may save you some trouble: You can use READ accross program slots in the BS2p by setting the target slot with STORE. You could put the board number at address 0 of slot 0, then the table of addresses following that. You'd have to send the OW serial number in a loop, but it might simplify things -- especially if the number of boards grows.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • KurtKurt Posts: 7
    edited 2005-03-11 23:42
    Thanks Jon.

    So - Can I actually execute a loop in the middle of a OW command?· Could you give me an example based on my code above? (Pick any data location).

    I like your idea and, I already have one slot setup as a data slot supporting the data table for an ISD voice chip. I have lots of room there, and I could easily add the address strings for the OW parts, (I have both an AtoD and a temp sensor on each board).

    Thanks for your ideas and and assistance!

    Kurt

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    kk
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-03-12 13:40
    Give this a try:

    · STORE 0
    · READ 0, modNum
    · eeAddr = modNum * 8 + 1
    · OWOUT OwPin, 1, [noparse][[/noparse]MatchRom]
    · FOR idx = 0 TO 7
    ··· READ eeAddr + idx, owByte
    ··· OWOUT OwPin, 0, [noparse][[/noparse]owByte]
    · NEXT
    · OWOUT OwPin, 0, [noparse][[/noparse]ConvertTemp]

    ·

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • KurtKurt Posts: 7
    edited 2005-03-12 15:55
    Thanks Jon! Yet again you've brought a new meaning to "elegance".

    Kurt

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    kk
Sign In or Register to comment.