Mark Bresler
09-08-09, 10:27 AM
hi,
I have a very curious problem when I run the driver I am writing for the compass module. I have it DUP the data bytes as they come in the SPI port. I print one copy, and save the other to the stack, when I print out the stack, the numbers are not the same. What the heck is going on?
Thanks,
Mark
: 2COMPASS-DATA ( 2,3,4,5 AJR, Puts Compass Module data on stack )
CR
5C B028 C! ( Set SPI for Compass )
DF B008 MAND ( Enable Compass )
1 SENDSPI ( Start Measurement )
20 B008 MOR ( Disable Compass )
8 LONGDELAY C! ( Delay for measurement )
LONGDELAYTIME
DF B008 MAND ( Enable Compass )
3 SENDRECEIVESPI ( Read Compass Data)
DUP C@ ." Compass Data is " . CR
1 SENDRECEIVESPI ( Read Compass Data)
DUP C@ ." Compass Data is " . CR
1 SENDRECEIVESPI ( Read Compass Data)
DUP C@ ." Compass Data is " . CR
( read 3 bytes of Compass data
( seperate into X and Y )
( perform 2's complement, store )
20 B008 MOR ( Disable Compass )
50 B028 C! ( Set SPI for 5450 )
;
2COMPASS-DATA
Compass Data is F6
Compass Data is 1D
Compass Data is D0
OK
. BF OK
. FA OK
. F0 OK
I have a very curious problem when I run the driver I am writing for the compass module. I have it DUP the data bytes as they come in the SPI port. I print one copy, and save the other to the stack, when I print out the stack, the numbers are not the same. What the heck is going on?
Thanks,
Mark
: 2COMPASS-DATA ( 2,3,4,5 AJR, Puts Compass Module data on stack )
CR
5C B028 C! ( Set SPI for Compass )
DF B008 MAND ( Enable Compass )
1 SENDSPI ( Start Measurement )
20 B008 MOR ( Disable Compass )
8 LONGDELAY C! ( Delay for measurement )
LONGDELAYTIME
DF B008 MAND ( Enable Compass )
3 SENDRECEIVESPI ( Read Compass Data)
DUP C@ ." Compass Data is " . CR
1 SENDRECEIVESPI ( Read Compass Data)
DUP C@ ." Compass Data is " . CR
1 SENDRECEIVESPI ( Read Compass Data)
DUP C@ ." Compass Data is " . CR
( read 3 bytes of Compass data
( seperate into X and Y )
( perform 2's complement, store )
20 B008 MOR ( Disable Compass )
50 B028 C! ( Set SPI for 5450 )
;
2COMPASS-DATA
Compass Data is F6
Compass Data is 1D
Compass Data is D0
OK
. BF OK
. FA OK
. F0 OK