here is the listing for my table write/read and Manchster Encoding to show how I (with help from friends) managed to get it working.
At the moment it just transmits 1 byte ($00a) over and over again to test the routines but will eventually be incorporated into the video capture program and transmit 8 longs (so far) during the frame capture period.
Thanks for all your help.
Rob
CON
_CLKMODE = XTAL1 + PLL16X
_XINFREQ = 6_000_000
PUB main
cognew(@telemetry, 0) ' launch cog to send telemetry to surface during frame capture
DAT
telemetry
org 0
mov dira, tel_mask ' set the pin directions
mov outa, tel_init
t_loop mov tsys_cnt, cnt ' get the value of the system counter
add tsys_cnt, break_delay
waitcnt tsys_cnt, #01
mov wr_offset, #0 ' reset the offset to the table to (first location)
mov rd_offset, #0
mov tbyte_cnt, #08
mov tbit_cnt, #012
mov table_wr, #look_up
mov table_rd, #look_up ' set up variables
mov tel_data, #$00a ' dummy data
call #write_table ' store the data in the table
call #read_table ' get the data from the table
tel_dat_out ror tel_data, #01 wc
if_c call #out_one
if_nc call #out_zero
djnz tbit_cnt, #tel_dat_out
andn outa, tel_out ' make sure data line is lo after telemetry is sent
jmp #t_loop
djnz tbyte_cnt, tel_dat_out
andn outa, tel_out ' make sure data line is lo after telemetry is sent
mov tsys_cnt, cnt ' get the value of the system counter
add tsys_cnt, break_delay
waitcnt tsys_cnt, #01
look_up mov tel_data, all_ones
mov tel_data, acc_x_val
mov tel_data, acc_y_val
mov tel_data, acc_z_val
mov tel_data, temp_val
mov tel_data, adc1_val
mov tel_data, adc2_val
mov tel_data, adc3_val
mov tel_data, adc4_val
'#######################################################################
'##################### Subroutines for timing etc.######################
'#######################################################################
' subroutine to write a byte to the look_up table
' on entry tel_data contains the data to write and wr_offset is the position in the table
' on exit wr_offset points to the next location in the table
write_table add table_wr, wr_offset
movd dest, table_wr
nop
dest mov 0-0, tel_data
add wr_offset, #01
write_table_ret ret
' subroutine to read a byte from the look_up table
' on entry rd_offset is the position in the table to read
' on exit tel_data contains the data
read_table add table_rd, rd_offset
movs srce, table_rd
nop
srce mov tel_data, 0-0
add rd_offset, #01
read_table_ret ret
' subroutine to send a Manchester Encoded 1 bit
out_one or outa, tel_out
mov ttime, cnt
add ttime, tbit_val
waitcnt ttime, #01
andn outa, tel_out
mov ttime, cnt
add ttime, tbit_val
waitcnt ttime, #01
out_one_ret ret
' subroutine to send a Manchester Encoded 1 bit
out_zero andn outa, tel_out
mov ttime, cnt
add ttime, tbit_val
waitcnt ttime, #01
or outa, tel_out
mov ttime, cnt
add ttime, tbit_val
waitcnt ttime, #01
out_zero_ret ret
'#######################################################################
'############################# definitions #############################
'#######################################################################
tel_mask long %0000_0000_0010_0000_1000_0000_0000_0000
tel_init long %0000_0000_0000_0000_0000_0000_0000_0000
tel_out long |<21
tbit_cnt long 8
tbyte_cnt long 8
tbit_val long 2100
tgap_flag long 0
ttone_stpd long 0
break_delay long 18_000
tone_zero long 0
tone_one long 1
all_ones long $0fff
tsys_cnt long 0
wr_offset long 0
rd_offset long 0
acc_x_val res
acc_y_val res
acc_z_val res
temp_val res
adc1_val res
adc2_val res
adc3_val res
adc4_val res
table_rd res
table_wr res
tel_data res
tbyte_val res
t1 res
t2 res
ttime res
Comments
FYI if you surround your code with code tags then it will look even better on the forum
[noparse][[/noparse]code ]
your code
[noparse][[/noparse]/code ]
But you have to remove the spaces from within the square brackets (I had to add them or it just shows an empty box).
Graham
here is the listing for my table write/read and Manchster Encoding to show how I (with help from friends) managed to get it working.
At the moment it just transmits 1 byte ($00a) over and over again to test the routines but will eventually be incorporated into the video capture program and transmit 8 longs (so far) during the frame capture period.
Thanks for all your help.
Rob