Object running stand-alone, but not when called???
I have a project in which a 'Main' contains objects. Each object has a function in it that starts a new cog and runs some assembly in that cog.
For some reason the objects work fine when they are compiled and ran by themselves...but when I call them from the Main object, only the first PASM routine functions. I thought I had everything right, but I guess not. When I get to the second object, the SPIN code (turning on an LED) works, however the PASM doesn't work...Again, it works fine when I compile and run it alone.
Is there something I am doing wrong here to prevent a cog from running assembly correctly?
-I have gone back and made sure that all of my labels are unique...But alas...Still no worky. Am I passing something wrong?
...In the below code, the Main object runs, PC_UART runs, and the GPS_UART object runs (makes OUTA[9] go high), but the PASM in the GPS_UART object does not run...or any other PASM in other objects....
Main Object:
PC_UART:
GPS Uart:
For some reason the objects work fine when they are compiled and ran by themselves...but when I call them from the Main object, only the first PASM routine functions. I thought I had everything right, but I guess not. When I get to the second object, the SPIN code (turning on an LED) works, however the PASM doesn't work...Again, it works fine when I compile and run it alone.
Is there something I am doing wrong here to prevent a cog from running assembly correctly?
-I have gone back and made sure that all of my labels are unique...But alas...Still no worky. Am I passing something wrong?
...In the below code, the Main object runs, PC_UART runs, and the GPS_UART object runs (makes OUTA[9] go high), but the PASM in the GPS_UART object does not run...or any other PASM in other objects....
Main Object:
OBJ PC_UART : "PC_UART.spin" GPS_UART : "GPS_UART.spin" RADIO_UART : "RADIO_UART.spin" LANC_UART : "LANC_UART.spin" MATH : "Float32Full.spin" BOARD_INTERFACE : "BS2_Functions.spin" Debug : "Simple_Serial.spin" CON _CLKMODE = XTAL2 + PLL4X _XINFREQ = 20_000_000 VAR BYTE PC_SIZE BYTE PC_BUFFER[100] BYTE GPS_SIZE BYTE GPS_BUFFER[100] BYTE RADIO_SIZE BYTE RADIO_BUFFER[100] BYTE LANC_SIZE BYTE LANC_BUFFER[100] BYTE TESTBYTE[25] BYTE COGNUMBER PUB MAIN 'SET PIN DIRECTION DIRA[31..0] := %00111111_11000110_10001111_01111111 'SET PIN STATE OUTA[31..0] := %10000000_11110011_11111001_10010000 'START MATH Math.Start 'Start PC Interface PC_UART.Run(@PC_SIZE) 'Start GPS GPS_UART.Run(@GPS_SIZE) 'Start Radio RADIO_UART.Run(@RADIO_SIZE) 'Start Lanc LANC_UART.Run(@LANC_SIZE) 'START SERVO cognumber := cognew(Servo_output, @COG1STACK[0]) repeat
PC_UART:
PUB Run(MemoryPointer)
cognew(@Start_PC,MemoryPointer)
OUTA[9]~~
DAT
org 0
Start_PC
or dira, PC_txpin
or outa, PC_txpin
mov PC_pointer, PAR
add PC_pointer, #2
RUN_PCSerial
mov PC_txbyte, #$AA
call #PC_uart_tx_9600
jmp #RUN_PCSerial
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PC_uart_rx_115200
mov PC_rxbyte, #0
PC_Wait_for_signal115200
mov PC_B, INA
and PC_B, PC_rxpin
TJNZ PC_B, #PC_Wait_for_signal115200
'Start bit found
mov PC_time, cnt
add PC_time, #$f
waitcnt PC_time, PC_delay115200Half
waitcnt PC_time, PC_delay115200Half
'Datafield
waitcnt PC_time, PC_delay115200Half
waitcnt PC_time, PC_delay115200Half
mov PC_B, INA
AND PC_B, PC_rxpin
or PC_rxbyte, PC_B
ror PC_rxbyte, #1
waitcnt PC_time, PC_delay115200Half
waitcnt PC_time, PC_delay115200
mov PC_B, INA
AND PC_B, PC_rxpin
or PC_rxbyte, PC_B
ror PC_rxbyte, #1
mov PC_bits, #6
PC_ReadLoop_115200
waitcnt PC_time, PC_delay115200
mov PC_B, INA
AND PC_B, PC_rxpin
or PC_rxbyte, PC_B
ror PC_rxbyte, #1
DJNZ PC_bits, #PC_ReadLoop_115200
ror PC_rxbyte, #23
PC_uart_rx_115200_ret
ret
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PC_uart_rx_9600
mov PC_rxbyte, #0
PC_Wait_for_signal9600
mov PC_B, INA
and PC_B, PC_rxpin
TJNZ PC_B, #PC_Wait_for_signal9600
'Start bit found
mov PC_time, cnt
add PC_time, #$f
waitcnt PC_time, PC_delay9600Half
waitcnt PC_time, PC_delay9600Half
'Datafield
waitcnt PC_time, PC_delay9600Half
waitcnt PC_time, PC_delay9600Half
mov PC_B, INA
AND PC_B, PC_rxpin
or PC_rxbyte, PC_B
ror PC_rxbyte, #1
waitcnt PC_time, PC_delay9600Half
waitcnt PC_time, PC_delay9600
mov PC_B, INA
AND PC_B, PC_rxpin
or PC_rxbyte, PC_B
ror PC_rxbyte, #1
mov PC_bits, 6
PC_ReadLoop_9600
waitcnt PC_time, PC_delay9600
mov PC_B, INA
AND PC_B, PC_rxpin
or PC_rxbyte, PC_B
ror PC_rxbyte, #1
DJNZ PC_bits, #PC_ReadLoop_9600
ror PC_rxbyte, #23
PC_uart_rx_9600_ret
ret
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PC_uart_tx_9600
mov PC_time, cnt
add PC_time, #$f
' startbit
'and outa, txpinnot
and outa, PC_txpinnot
waitcnt PC_time, PC_delay9600
waitcnt PC_time, PC_delay9600
' prepare_data
mov PC_bits, #8
' mov A, #$AA
ror PC_txbyte, #1
PC_Datafield9600
ror PC_txbyte, #1
mov PC_B, PC_txbyte
AND PC_B, PC_txpin
MOV OUTA, PC_B
waitcnt PC_time, PC_delay9600
DJNZ PC_bits, #PC_Datafield9600
' parity
or outa, PC_txpin
waitcnt PC_time, PC_delay9600
' stopbit
waitcnt PC_time, PC_delay9600
waitcnt PC_time, PC_delay9600
PC_uart_tx_9600_ret
ret
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PC_uart_tx_115200
mov PC_time, cnt
add PC_time, #$f
' startbit
'and outa, txpinnot
and outa, PC_txpinnot
waitcnt PC_time, PC_delay115200
waitcnt PC_time, PC_delay115200
' prepare_data
mov PC_bits, #8
' mov A, #$AA
ror PC_txbyte, #1
PC_Datafield115200
' or outa, txpin
' and outa, txpinnot
ror PC_txbyte, #1
mov PC_B, PC_txbyte
AND PC_B, PC_txpin
MOV OUTA, PC_B
waitcnt PC_time, PC_delay115200
DJNZ PC_bits, #PC_datafield115200
' parity
or outa, PC_txpin
waitcnt PC_time, PC_delay115200
' stopbit
waitcnt PC_time, PC_delay115200
waitcnt PC_time, PC_delay115200
waitcnt PC_time, PC_delay115200
PC_uart_tx_115200_ret
ret
PC_delay9600 long 6099
PC_delay9600Half long 3049
PC_delay115200 long 516
PC_delay115200Half long 258
PC_rxpin long $80_00_00_00
PC_rxpinnot long $7F_FF_FF_FF
PC_txpin long $40_00_00_00
PC_txpinnot long $BF_FF_FF_FF
PC_rxbyte res 1
PC_txbyte res 1
PC_B res 1
PC_time res 1
PC_bits res 1
PC_pointer res 1
GPS Uart:
PUB Run(MemoryPointer)
cognew(@Start_GPS,MemoryPointer)
OUTA[10]~~
DAT
org 0
Start_GPS
or dira, txpin
or outa, txpin
mov pointer, PAR
add pointer, #2
RUN_GPS
mov txbyte, #$AA
call #uart_tx_9600
jmp #RUN_GPS
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
uart_rx_115200
mov rxbyte, #0
Wait_for_signal115200
mov B, INA
and B, rxpin
TJNZ B, #Wait_for_signal115200
'Start bit found
mov time, cnt
add time, #$f
waitcnt time, delay115200Half
waitcnt time, delay115200Half
'Datafield
waitcnt time, delay115200Half
waitcnt time, delay115200Half
mov B, INA
AND B, rxpin
or rxbyte, B
ror rxbyte, #1
waitcnt time, delay115200Half
waitcnt time, delay115200
mov B, INA
AND B, rxpin
or rxbyte, B
ror rxbyte, #1
mov bits, #6
ReadLoop_115200
waitcnt time, delay115200
mov B, INA
AND B, rxpin
or rxbyte, B
ror rxbyte, #1
DJNZ bits, #ReadLoop_115200
ror rxbyte, #13
uart_rx_115200_ret
ret
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
uart_rx_9600
mov rxbyte, #0
Wait_for_signal9600
mov B, INA
and B, rxpin
TJNZ B, #Wait_for_signal9600
'Start bit found
mov time, cnt
add time, #$f
waitcnt time, delay9600Half
waitcnt time, delay9600Half
'Datafield
waitcnt time, delay9600Half
waitcnt time, delay9600Half
mov B, INA
AND B, rxpin
or rxbyte, B
ror rxbyte, #1
waitcnt time, delay9600Half
waitcnt time, delay9600
mov B, INA
AND B, rxpin
or rxbyte, B
ror rxbyte, #1
mov bits, 6
ReadLoop_9600
waitcnt time, delay9600
mov B, INA
AND B, rxpin
or rxbyte, B
ror rxbyte, #1
DJNZ bits, #ReadLoop_9600
ror rxbyte, #13
uart_rx_9600_ret
ret
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
uart_tx_9600
mov time, cnt
add time, #$f
' startbit
'and outa, txpinnot
and outa, txpinnot
waitcnt time, delay9600
waitcnt time, delay9600
' prepare_data
mov bits, #8
' mov A, #$AA
ror txbyte, #9
Datafield9600
ror txbyte, #1
mov B, txbyte
AND B, txpin
MOV OUTA, B
waitcnt time, delay9600
DJNZ bits, #Datafield9600
' parity
or outa, txpin
waitcnt time, delay9600
' stopbit
waitcnt time, delay9600
waitcnt time, delay9600
uart_tx_9600_ret
ret
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
uart_tx_115200
mov time, cnt
add time, #$f
' startbit
'and outa, txpinnot
and outa, txpinnot
waitcnt time, delay115200
waitcnt time, delay115200
' prepare_data
mov bits, #8
' mov A, #$AA
ror txbyte, #9
Datafield115200
' or outa, txpin
' and outa, txpinnot
ror txbyte, #1
mov B, txbyte
AND B, txpin
MOV OUTA, B
waitcnt time, delay115200
DJNZ bits, #datafield115200
' parity
or outa, txpin
waitcnt time, delay115200
' stopbit
waitcnt time, delay115200
waitcnt time, delay115200
waitcnt time, delay115200
uart_tx_115200_ret
ret
delay9600 long 6099
delay9600Half long 3049
delay115200 long 516
delay115200Half long 258
rxpin long $00_20_00_00
rxpinnot long $FF_DF_FF_FF
txpin long $00_40_00_00 '0000_0000_0x00_0000_0000_0000_0000_0000
txpinnot long $FF_BF_FF_FF
rxbyte res 1
txbyte res 1
B res 1
time res 1
bits res 1
pointer res 1

Comments
That's way out of spec and may be responsible for the effect you're seeing. PLL clock input should be kept within 4..8MHz (Hydra being slightly off with 10MHz but still OK). Grab a 5MHz crystal and see if it makes a difference.
Also, your par address parameters are still unaligned (everything from 4n to 4n+3), they are not used yet in the code you posted but presumably will be later.