Sensoray 526 User Manual
Page 10
10
RegisterWrite (0x14, 0x0001); //load Preload Register high word
RegisterWrite (0x12, 0x3C68); //load Preload Register low word
Step 2. Reset the counter (to clear RTGL), load the counter from Preload Register 0.
RegisterWrite (0x18, 0x8000); //reset the counter
RegisterWrite (0x18, 0x4000); //load the counter from PR0
Step 3. Reset RCAP (fires one-shot).
RegisterWrite (0x18, 0x8);
One-shot (hardware trigger)
The following example shows how to fire the one-shot on the positive edge of external
trigger. The trigger signal is connected to the INDEX input of the counter.
Step 1. Load both preload registers PR0 and PR1 with 0x13C68. First, set the Counter Mode
register.
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
0
0
0
0
1
1
1
0
1
0
1
1
1
0
0
1
0
X
PR0
X
Soft
count
direction
control
Count
direction:
down
Clock
source:
internal
Count
enable:
hardware
NOT
RCAP
Auto load and
reset RCAP:
INDEX
↑
Polarity:
inverted
Out:
RCAP
// select PR0 as a target for Preload register access
// do not enable autoload (bit 4) yet
RegisterWrite (0x16, 0x1D62); //load Counter Mode register
RegisterWrite (0x14, 0x0001); //load Preload Register 0 high word
RegisterWrite (0x12, 0x3C68); //load Preload Register 0 low word
// select PR1 as a target for Preload register access
RegisterWrite (0x16, 0x5D62); //load Counter Mode register
RegisterWrite (0x14, 0x0001); //load Preload Register 1 high word
RegisterWrite (0x12, 0x3C68); //load Preload Register 1 low word
Step 2.
// enable autoload
RegisterWrite (0x16, 0x3D72); //load Counter Mode register
Pulse Width Modulation
Let’s assume the following requirements:
Period = 10 ms; “high” state = 2 ms; “low” state = 8 ms. Then the “high” length in periods of
the 27 MHz clock is 2 ms x 27 MHz = 54000 = 0xD2F0, the “low” length is 8 ms x 27 MHz =
216000 = 0x34BC0.
Step 1. Load Preload Register 0.
// select PR0 as a target for Preload register access, load PR0
RegisterWrite (0x16, 0x1C85); //load Counter Mode register
RegisterWrite (0x14, 0x0003); //load Preload Register 0 high word
RegisterWrite (0x12, 0x4BC0); //load Preload Register 0 low word
Step 2. Load Preload Register 1.
// select PR1 as a target for Preload register access, load PR1
RegisterWrite (0x16, 0x5C85); //load Counter Mode register
RegisterWrite (0x14, 0x0000); //load Preload Register 0 high word
RegisterWrite (0x12, 0xD2F0); //load Preload Register 0 low word