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

Subversion Repositories ssbcc

[/] [ssbcc/] [trunk/] [core/] [9x8/] [peripherals/] [tb/] [PWM_8bit/] [tb_PWM_8bit.s] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 sinclairrf
; Copyright 2012, Sinclair R.F., Inc.
2
;
3
; Test bench for PWMs peripheral.
4
 
5
.main
6
 
7
  ; Wait for a while to ensure the outputs are all zero before a non-zero PWM is
8
  ; commanded.
9
  .call(wait,${2-1})
10
 
11
  ; Issue identical commands to the singleton PWM controllers
12
  0xC0 .outport(O_PWM_SR)
13
  0xC0 .outport(O_PWM_SN)
14
  0xC0 .outport(O_PWM_SI)
15
 
16
  ; Issue a command to the triple-PWM controller using the example function
17
  ; from the peripheral help message.
18
  0xFE 0x39 0x38 O_PWM_MULTI_0 .call(set_pwm_multi,${3-1})
19
 
20
  ; Let the system run for 3 PWM cycles
21
  .call(wait,${3-1})
22
 
23
  ; Issue another set of PWM commands.  Cause runt pulses on unprotected PWMs
24
  ; for the singleton PWM channels.  Test full on and full off conditions.
25
  0x10 O_PWM_SR outport O_PWM_SN outport O_PWM_SI outport drop
26
  0xFF 0x00 0x01 O_PWM_MULTI_0 .call(set_pwm_multi,${3-1})
27
 
28
  ; Let the system run for 3 PWM cycles
29
  .call(wait,${3-1})
30
 
31
  ; Send the termination signal and then enter an infinite loop.
32
  1 .outport(O_DONE)
33
  :infinite .jump(infinite)
34
 
35
 
36
; Wait for the commanded number of complete PWM cycles
37
; Note:  The 100 MHz clock frequency, 6000 Hz PWM rate, and 3 clocks per
38
;        inner-most wait cycle means that 100e6/6000/3=5555 loop iterations
39
;        are needed.  Since 5555/256=21.7, a 22*256 loop will be
40
;        slightly longer than the desired delay and will help validate the runt
41
;        removal.
42
; ( u_wait_minus_1 - )
43
.function wait
44
  :loop_commanded
45
    ${22-1} :loop_outer
46
      ${256-1} :loop_inner .jumpc(loop_inner,1-) drop
47
    .jumpc(loop_outer,1-) drop
48
  .jumpc(loop_commanded,1-)
49
.return(drop)
50
 
51
 
52
; ( u_pwm_multi_{n-1} ... u_pwm_multi_1 u_pwm_multi_0 U_OUTPORT u_count_minus_1 - )
53
.function set_pwm_multi
54
  :loop >r swap over outport drop 1+ r> .jumpc(loop,1-) drop
55
.return(drop)

powered by: WebSVN 2.1.0

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