Address instead of contents
Tapperman
Posts: 321
3_Phase_Motor_v3c.spin
Sin Table Generator for Motor Table.xls
I get the address of the long in COG Ram (I think) instead of the contents of the table location.
Any ideas what I could be messing up on?
... Tim

_Set3Phase rdlong temp2, ARG_0 ' get X position in table
mov temp, #Mtr_Table ' get address of Mtr_Table
add temp, temp2 ' point at x entry
mov T_On__Ch + 10, temp ' set OnTime from Table <-- Bug
wrlong temp, ARG_0 ' debug line
mov temp1, Max_Duty ' get max duty
sub temp1, temp ' get difference
mov T_Off_Ch + 10, temp1 ' write the off time
wrlong temp1, ARG_1 ' debug line
I get the address of the long in COG Ram (I think) instead of the contents of the table location.
Any ideas what I could be messing up on?
... Tim


Comments
_Set3Phase rdlong temp2, ARG_0 ' get X position in table mov temp, #Mtr_Table ' get address of Mtr_Table add temp, temp2 ' point at x entry movd wr_it, temp mov T_On__Ch + 10, temp ' set OnTime from Table <-- Bug wr_it wrlong 0-0, ARG_0 ' debug lineBTW, there always needs to be at least one instruction between a statement that modifies another instruction and the instruction that it modifies.
-Phil
Thanks ... that did the trick!
[video=youtube_share;F5uWjCAjpfQ]
... Tim
... Tim
The wealth of experience around here really paves the way for others to quickly use the Propeller. Thanks Phil for the help, too.
Ken Gracey
DAT Mtr_Drv_Asm org mov src, par ' ram buffer add mov dst, MV_Tbl ' get cog targ add mov x_tmp, 12 ' read 12 longs '------------------------------------------------------------- get_data rdlong dst, src add dst, #1 ' adv target register add src, #4 ' adv hub address djnz x_tmp, #get_data nop ' rest of code, table should be loaded? ''-------------------------Defined variables--------------------------------- MV_Tbl Long 0,0,0,0,0,0,0,0,0,0,0,0 x_tmp Long 0 src Long 0 dst Long 0Mtr_Drv_Asm org mov src, par ' ram buffer add [color=red]movd get_data,#MX_Tbl[/color] mov x_tmp, [color=red]#[/color]12 ' read 12 longs get_data rdlong [color=blue][b]0-0[/b][/color], src [color=red]add get_data,_512 ' adv target address[/color] add src, #4 ' adv hub address djnz x_tmp, #get_data ... [color=red]_512 long 512[/color]-Phil
Thanks for responding so quick! If you don't mind ...I have a follow-up question:
Ok, I have to adjust the destination add in the RDLONG instruction. But, why do you add 512 to the code pointer, and not add 1 to the DST address?
-Phil
So the MOVD modifies the field bids 17..9 of any long (in COG ram). In this case it happens to be an instruction code.
So you were actually combining two steps into one. And that’s what I did not see. Thank you for clearing that up for me.
Had I coded it my way, I would have added one to the destination address, followed by another MOVD op-code.
So by adding 512 to the op-code, do you also have the pipelining issue that exists for the MOVD op-code?