PDA

View Full Version : Stange behaviour of OUTA....



Joerg
01-12-2008, 05:04 AM
After some starting difficulties and some very helpful tips from forum members, here something i am wondering about:

If i put data on outa an am using a variable direct the result makes sense to me; if i use the variable via pointer the bits are reversed:

i.e. variable N := 13 Result direct: Bit0=1, Bit1=0, Bit2=1, Bit3=1, Bit4..7=0
Result via pointer Bit0..3=0, Bit4=1, Bit5=1, Bit6=0, bit7=1

Here a program with this behaviour:




'test2.spin
'

VAR byte N
long Stack[10]


PUB test2
dira[0..7]~~
N := 0
cognew(outx(@N), @Stack)

repeat
outa[7..0] := N
waitcnt(clkfreq / 1_000_000 * 10_000 + cnt)
N := ina[11..8]


PUB outx(AdrInVar)
dira[23..16]~~

repeat
outa[23..16] := long[AdrInVar]






Does anybody know why this happens?

Saluti Joerg

Phil Pilgrim (PhiPi)
01-12-2008, 05:21 AM
It shouldn't matter, but since N is a byte variable, have you tried it with byte[AdrInVar]?

-Phil

Joerg
01-12-2008, 05:43 AM
Yes i did!
I have tried to change form byte to long, thats why long[AdrInVar] shows up in the code.

Thank you Phil.

Buona notte Joerg

deSilva
01-12-2008, 05:55 AM
Ths would not change anything as the Propeller is a little endian machine...
Joerg, can it be that you are just LOOKING upside down? Pins 16..24 are at the upper side of the Prop...

Beau Schwabe
01-12-2008, 06:03 AM
Saluti Joerg,

is it because the direction you are assigning to your LED's reads...

[23..16]

...instead of...

[16..23]

... ?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe (mailto:bschwabe@parallax.com)

IC Layout Engineer
Parallax, Inc.

deSilva
01-12-2008, 06:08 AM
No, as he used the inverted form for
OUTA[7..0] := N
as well..

Phil Pilgrim (PhiPi)
01-12-2008, 01:17 PM
I tried the following, slightly modified version of your program (skipped reading the pins) and didn't see any bit inversion happening:




CON

_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000

'test2.spin
'

VAR byte N
long Stack[10]


PUB test2
dira[0..7]~~
N := 0
cognew(outx(@N), @Stack)

repeat
outa[7..0] := N
waitcnt(clkfreq / 1_000_000 * 10_000 + cnt)
N := 13


PUB outx(AdrInVar)
dira[23..16]~~

repeat
outa[23..16] := long[AdrInVar]





-Phil

Peter Jakacki
01-12-2008, 02:40 PM
Joerg,

I haven't really read this thread properly but isn't it a problem if you declare a byte variable before a long as the longs need to be word aligned. What would happen I think is that the stack would use the same address as the byte. Declare longs, then words, then bytes and you won't get any alignment problems.

*Peter*

stevenmess2004
01-12-2008, 06:19 PM
Shouldn't be. The spin compiler automatically aligns variables correctly. And long variables need to be long aligned not word aligned.

Steven

deSilva
01-12-2008, 08:14 PM
Peter is fundamentally right; but teh compiler sorts this out outomatically in exactly that way. And it should not be a problem in the case of the posted code with just one byte only in it.


VAR byte N
long Stack[10]



This here will give you more issues:


VAR byte X, Y, N
long Stack[10]




I still suspect - as yesterday - Joerg was just looking upside down http://forums.parallax.com/images/smilies/smile.gif

Post Edited (deSilva) : 1/12/2008 12:19:23 PM GMT

Joerg
01-12-2008, 09:41 PM
And deSilva is right!

I simply messed up P16..P23 -> PC7..PC0 and P24..P31 -> PD7..PD0

Thanks anyway for all the tips!

I will modify my MCU module for UMDL right now!


Saluti Joerg

Joerg
01-13-2008, 11:02 PM
Here the new Propeller module for UMDL.

The doc can be found here: www.systech-gmbh.ch (http://www.systech-gmbh.ch) -> UMDL -> Parallax -> P8X32A-D40

Saluti Joerg

deSilva
01-14-2008, 01:16 AM
Joerg, do I see it right that the main difference between this board and the Parallax Proto Board is a DIN 41622 connector?

Joerg
01-14-2008, 02:07 AM
Dear deSilva

No! The UMDL system (formerly called HC(S)08 system) uses a simple 2x36pin header (72pol, 0.1"). This is enough for 8 8bit ports (as most other MCU's are using a port nomenclature). The MCU modules are fitting on base plate (with 10 pin headers and additional stuff). The original idea was to create a system for different MCU's (different families and different manufacturers).
So i can change the MCU if for some reason the chosen one does not fit anymore. The system is totally modular and based on the 10 pin header philosophy. So i have developed RS232 interfaces as well as stepper motor drivers and a lot more modules (and also a lot more in mind). But this is only one part of the story: Each module (if once tested!!!!!!!!!) has the schematics ready for being used in the final design. And this is true for the software also: My EBS08 (Einfaches Betriebs System 08) is also modular, consisting on a TIC generator for controlling simple tasks and a lot of modules around. They are (at the time being) written in ASM or C for the Freescale HC(S)08 MCU's, but step by step i will write these modules for the Propeller chip.
In fact i have realized a lot of my projects using UMDL and EBS08 for hardware and software development and i have used the basic modules to make the final design. This is a fast and secure approach and i just LOVE it.

Saluti Joerg

PS. If somebody is interested have a look here: www.systech-gmbh.ch (http://www.systech-gmbh.ch) -> UMDL