Compilers: Passing constants between objects - my stupid error!
Cluso99
Posts: 18,069
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...
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
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
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.mikronauts.com E-mail: mikronauts _at_ gmail _dot_ com 5.0" VGA LCD in stock!
Morpheus dual Prop SBC w/ 512KB kit $119.95, Mem+2MB memory/IO kit $89.95, both kits $189.95 SerPlug $9.95
Propteus and Proteus for Propeller prototyping 6.250MHz custom Crystals run Propellers at 100MHz
Las - Large model assembler Largos - upcoming nano operating system
Operator precedence is <<, | then /. Try this:
serPins = (_clkfreq / baud) << 16 | txPin << 8 | rxPin
and it will work. As it was, it was being interpreted as
serPins = _clkfreq / (baud << 16 | txPin << 8 | rxPin)
-Phil
I didn't see that one coming. Thanks kuroneko & Phil - fixed
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
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