Shop OBEX P1 Docs P2 Docs Learn Events
Compilers: Passing constants between objects - my stupid error! — Parallax Forums

Compilers: Passing constants between objects - my stupid error!

Cluso99Cluso99 Posts: 18,069
edited 2010-02-17 04:44 in Propeller 1
I decided to remove the hardware definitions to a seperate file called hwdef.spin

However, this failed and I am at a loss to understand why. The same happens on both PropTool and bst. The problem was the lack of parenthesis (see posts below).

This is a good solution to decouple some constants into a seperate definition file.

I have attached a sample program, but here is a summary...

  'hwdef.spin contains....
 
con
  rxPin  = 31                                           'serial
  txPin  = 30
  baud   = 115200
  serPins = (_clkfreq / baud) << 16 | txPin << 8 | rxPin   'fixed: added parenthesis


'PassConst.spin contains...
 
con
  rxPin  = 31
  txPin  = 30
  baud   = 115200
  serPins = txPin << 8 | rxPin

obj
  hw    : "_hwdef"              'hardware pin definitions etc
  term  : "FullDuplexSerial"           
  
pub Main | err, p
  waitcnt(clkfreq*2 + cnt)
  
'start standard output driver...
  if term.start( rxPin, txPin, 0, baud )
    waitcnt(clkfreq*2 + cnt)
    term.tx(0)
    term.str( string("========== PassConst ==========", 13) )
    term.str( string(" serial @ pins ") )
    term.hex( serPins, 8 )
    term.str( string(13, " hwdef  @ pins ") )
    term.hex( hw#serPins, 8 )
    term.tx( 13 )


The line term.str(serPins,8) outputs the expected value $00001E1F whereas term.str(hw#serPins,8) contains $00000000 indicating the constant has not been passed between objects.
·
If this is not intended to work, is there another way to decouple the hardware definitions ???

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Links to other interesting threads:

· Home of the MultiBladeProps: TriBlade,·RamBlade,·SixBlade, website
· Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator)
· Prop Tools under Development or Completed (Index)
· Emulators: CPUs Z80 etc; Micros Altair etc;· Terminals·VT100 etc; (Index) ZiCog (Z80) , MoCog (6809)·
· Prop OS: SphinxOS·, PropDos , PropCmd··· Search the Propeller forums·(uses advanced Google search)
My cruising website is: ·www.bluemagic.biz·· MultiBlade Props: www.cluso.bluemagic.biz

Post Edited (Cluso99) : 2/17/2010 4:50:42 AM GMT

Comments

Sign In or Register to comment.