Address Passing
SRLM
Posts: 5,045
I'm trying to debug a problem with addresses on the Propeller. Given the code below, I expect the addresses to match on all three outputs. But they don't! Somehow, the value is getting modified when it is passed to the imu.add_register function.
What's going on here?
IMU Object:
Output:
I'd expect to see the address of F3C for hub_address, but instead it's the address of something else. What is going on here?
I've attached the original source, although it is a bit messy. What is above is what is run.
What's going on here?
{ main object } CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 CON 'IO Pins DEBUG_TX_PIN = 30 DEBUG_RX_PIN = 31 IMU_RX_PIN = 0 'Note: direction is from Propeller IO port IMU_TX_PIN = 1 'Note: direction is form Propeller IO port 'Settings VAR byte um6_packet[20] 'Note: should require only 18 bytes, but extra just in case... long gyro_proc_xy long accel_proc_xy long mag_proc_xy long euler_phi_theta OBJ debug : "FullDuplexSerialPlus.spin" imu : "um6.spin" PUB Main | i, t1, addr, roll, pitch addr := @euler_phi_theta debug.start(DEBUG_RX_PIN, DEBUG_TX_PIN, 0, 230400) waitcnt(clkfreq + cnt) debug.str(string("Starting", 10, 13)) t1 := imu.add_register($62, addr) debug.str(string("hub_address: ")) debug.hex(t1, 8) debug.tx(10) debug.tx(13) debug.str(string("addr: ")) debug.hex(addr, 8) debug.tx(10) debug.tx(13) debug.str(string("@euler_phi_theta: ")) debug.hex(@euler_phi_theta, 8) debug.tx(10) debug.tx(13)
IMU Object:
{ imu object } PUB add_register(register, hub_address) return hub_address
Output:
Starting hub_address: 33E883C4 addr: 00000F3C @euler_phi_theta: 00000F3C
I'd expect to see the address of F3C for hub_address, but instead it's the address of something else. What is going on here?
I've attached the original source, although it is a bit messy. What is above is what is run.
Comments
That was it! Thank you!
The problem here is that it compiles under BSTC (but I assume not the Prop Tool?). As soon as I changed it so the parameter and pasm_label have different names I get the correct result.
I'm curious what happened though.
Where $1 is the filename. Even when I remove the -f -p0 and -l options it will compile.
Thanks for the explanation.