OpenCores
URL https://opencores.org/ocsvn/ssbcc/ssbcc/trunk

Subversion Repositories ssbcc

[/] [ssbcc/] [trunk/] [core/] [9x8/] [peripherals/] [tb/] [stepper_motor/] [tb_stepper_motor.s] - Blame information for rev 9

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 9 sinclairrf
; Copyright 2015, Sinclair R.F., Inc.
2
;
3
; Test bench for stepper_motor peripheral.
4
 
5
.macro push16
6
.macro push24
7
 
8
.main
9
 
10
  ; Forward acceleration.
11
  .push24(${10-1})      ; 10 steps
12
  .push16(3436)         ; 50_000 step/sec^2 (50e3*2**34/F**2 where F=5.e5)
13
  .push16(0)            ; initial rate = 0
14
  .call(push_command)
15
 
16
  ; Continue uniform motion.
17
  .push24(${10-1})      ; 10 steps
18
  .push16(0)            ; no acceleration
19
  .push16(131)          ; 1000 step/sec (1.e3*2**16/F)
20
  .call(push_command)
21
 
22
  ; Decelerate to stop motion.
23
  .push24(${10-1})      ; 10 steps
24
  .push16(-3432)        ; -50_000 step/sec^2 (actual -v**2/(2*10) ==> 3432.2)
25
  .push16(131)          ; 1000 step/sec
26
  .call(push_command)
27
 
28
  ; Accelerate in negative direction.
29
  .push24(${10-1})      ; 10 steps
30
  .push16(-3436)        ; -50_000 step/sec^2
31
  .push16(-1)           ; ~0 step/sec
32
  .call(push_command)
33
 
34
  ; Continue uniform motion.
35
  .push24(${10-1})      ; 10 steps
36
  .push16(0)            ; no acceleration
37
  .push16(-131)         ; 1000 step/sec (1.e3*2**23/F)
38
  .call(push_command)
39
 
40
  ; Decelerate to stop motion.
41
  .push24(${10-1})      ; 10 steps
42
  .push16(3432)         ; -50_000 step/sec^2
43
  .push16(-131)         ; 1000 step/sec (1.e3*2**23/F)
44
  .call(push_command)
45
 
46
  ; Command the motion profile to run.
47
  .outstrobe(O_GO)
48
 
49
  ; Wait for the profile to finish.
50
  :loop_wait .inport(I_DONE) 0= .jumpc(loop_wait)
51
 
52
  ; Wait about 10 usec
53
  ${(10*8)/3} :wait_done .jumpc(wait_done,1-) drop
54
 
55
  ; Indicate termination to the test bench.
56
  1 .outport(O_DONE)
57
 
58
  ; Wait forever
59
  :infinite .jump(infinite)
60
 
61
 
62
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
63
;
64
; Stepper motor utilities.
65
;
66
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
67
 
68
.constant       C_RATE_WIDTH    ${C_RATE_RES-C_RATE_SCALE+1}
69
.constant       C_ACCEL_WIDTH   ${1+C_ACCEL_RES-C_ACCEL_SCALE}
70
.constant       C_NBYTES        ${int((C_RATE_WIDTH+7)/8)+int((C_ACCEL_WIDTH+7)/8)+int((C_COUNT_WIDTH+7)/8)}
71
 
72
; Send the control word on the stack to the stepper motor peripheral and record it in the FIFO.
73
; ( u_count_LSB ... u_accel_LSB ... u_rate_MSB - )
74
.function push_command
75
  ${C_NBYTES-1} :loop swap .outport(O_CONTROLWORD) .jumpc(loop,1-) drop
76
  .outstrobe(O_CONTROLWORD_WR)
77
  .return

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.