Professional Documents
Culture Documents
Input event detection Output event generation Pulse-rate sensing Pulse-rate modulation Pulse-width modulation
TPU
Serial Comm
ADC
IMB
ADC
RCPU
SRAM
SRAM
L-bus
TPU
Controls 16 channels (available as pins).
TPU
Memory-mapped interface IMB3 16-bit counters
channels
Chan 0 Chan 1
MicroEngine
Chan 15
TPU Timers
Two timers: TCR1 & TCR2 -- 16 bits each
TPU Registers
TPU Module Configuration Register: TPUMCR 0x30 4000
0 1:2 TCR1P 8 9
supvpsck
Clock prescalar 0: 32 1: 4
0:4
5:7
8:9
CIRL
Channel interrupt request level: 0-7.
ILBS
0 Ch 15
1 Ch 14
2 Ch 13
14 Ch 1
15 Ch 0
14 Ch 1
15 Ch 0
Channel Programming
16 predefined functions. Input Capture: capture one or multiple transitions on an input pin.
Channel 0
Channel Programming
Program as an output channel.
Output Compare: generate an event on the output: a single output transition, a single pulse, or a continuous 50% duty cycle pulse train.
REF_TIME1 offset
Channel Initialization
Choose channel function: Code for IC: 0xA Channel function code for OC: 0x4
0x30 400c: Channel Function Select Register 0 (CFSR0)
Ch 15
Ch 14
Ch 13
Ch 12
Ch 11
Ch 10
Ch 9
Ch 8
Ch 7
Ch 6
Ch 5
Ch 4
Ch 3
Ch 2
Ch 1
Ch 0
TRANS_COUNT
FINAL_TRANS_TIME LAST_TRANS_TIME
0x3041Wa
Ch 0 Ch 1 Ch 2
P1
10 P1 20 P1
P2
12 P2
P3
14 P3
P4
16 P4
P5
08 P5
P6
1a P6
P7
1c P7
P8
1e P8
22
P2
24
P3
26
P4
28
P5
2a
P6
2c
P7
2e
P8
f0
f2 P2
f4 P3
f6 P4
f8 P5
fa P6
fc P7
fe P8
Ch 15
P1
TBS
PAC
PSC
11:do not force any state input pin 01: force high 10: force low
000:do not detect trans. 001:detect rising edge 010:detect falling edge 011:detect either edge 1xx:do not change PAC
Channel Priority
Choose channel priority: 0:disable; 1:low; 2: medium; 3: high
0x30 401c: Channel Priority Register 0 (CPR0)
Ch 15 Ch 14 Ch 13 Ch 12 Ch 11 Ch 10
Ch 9
Ch 8
Ch 7
Ch 6
Ch 5
Ch 4
Ch 3
Ch 2
Ch 1
Ch 0
Ch 15 Ch 14 Ch 13 Ch 12 Ch 11 Ch 10
Ch 9
Ch 8
Ch 7
Ch 6
Ch 5
Ch 4
Ch 3
Ch 2
Ch 1
Ch 0
Host Sequence
0x30 4014: Host Sequence Register 0 (HSQR0)
Ch 15 Ch 14 Ch 13 Ch 12 Ch 11 Ch 10
Ch 9
Ch 8
Ch 7
Ch 6
Ch 5
Ch 4
Ch 3
Ch 2
Ch 1
Ch 0
Ch 7
Ch 6
Ch 5
Ch 4
Ch 3
Ch 2
Ch 1
Ch 0
00: Host service complete by TPU channel 01: Initialize TCR mode by CPU Program
Modification of HSRR involves read-modify-write: lhz r6, 0x401a(r5) //read andi r6, r6, 0xfffc // modify (write %01 to HSRR[ch0]) ori r6, r6, 0x1 sh r6, 0x401a(r5) // write
00
00
10
00
00
11
01
00
andi r6, r6, 0xfffc // modify (write %01 to HSRR[ch0]) ori r6, r6, 0x1
00
00
00
00
10
10
00
00
00
00
11
11
01
00
01
00
We dont really know what happens to ch 1-7 fields while we modify ch 0 field.
00 is written by only the TPU, no CPU program should legitimately write that value.
li r6, 0x1 //00 00 00 00 00 00 01 sth r6, 0x401a(r5) Ch 7 00 Ch 6 00 Ch 5 10 Ch 4 00 Ch 3 00 Ch 2 11 Ch 1 00 Ch 0 00 01
Function code: 0xC Channel control: TBS: 0000 (capture, match TCR1) ; PAC: 001 rising edge or 010 falling edge; PSC: 11 input. Host Sequence (HSQR): 00 begin with falling edge, single shot; 01 begin with falling edge continual mode; 10 begin with rising edge, single shot; 11 begin with rising edge continual mode. Host service (HSRR): 10 initialize, 00 reset
FQM Parameters
TPU Programming in C
struct TPU3_tag { union { } TPUMCR; . union { VUINT16 R; struct { VUINT16:5; VUINT16 CIRL:3; VUINT16 ILBS:2; VUINT16:6; } B; } TICR; union { VUINT16 R; struct { VUINT16 CH15:1; VUINT16 CH0:1; } B; } CIER;
};
TPU programming in C
void tpu_fqm_init(struct TPU3_tag *tpu, UINT8 channel, UINT8 priority, UINT8 mode, UINT8 edge, UINT8 timer, UINT16 wind_sz);
void
UINT16
OC Programming
(REF_ADDR1) OFFSET
Point REF_ADDR1 to 0x3041 ec (TCR1 value captured at this parameter address). OFFSET = 0x1000 with TCR1 resolution at 1 micro-s: 4.096 milli-s. Channel function code for OC: 0x4 CFSR[ch] 0x4
Output Compare
OC initialization (host service request of 01 -- host initiated pulse mode) writes the current value: TCR1 0x3041 ec; TCR2 0x3041ee
(REF_ADDR1)
OFFSET
PAC
PSC
11: do not force any state 01: force high 10: force low
000: do not change pin state on match 001: high on match 010: low on match 011: toggle on match 1xx: do not change PAC
OC Channel Control
(REF_ADDR1) OFFSET
Toggle on match
OC Channel Control
(REF_ADDR1) OFFSET REF_TIME = (REF_ADDR1) + OFFSET
Low on match
Other OC Parameters
Channel W
0x3041W0 0x3041W2 0x3041W4 0x3041W6 0x3041W8
Channel Control (9 bits) OFFSET RATIO REF_ADDR2 0 REF_ADDR1 REF_ADDR3 REF_TIME ACTUAL_MATCH_TIME 0 0
0x3041Wa
OC Output Parameters
When a channel is initialized for OC through a service request of 01, REF_TIME is computed as (REF_ADDR1) + OFFSET and placed in parameter REF_TIME. REF_TIME is the next time instant when an event would occur (and an interrupt is raised). This is the match event: compare TCR1/2 with REF_TIME for a match.
ACTUAL_MATCH_TIME is updated with the TCR1/2 time when the match is serviced (by raising an interrupt, and changing the level of the output channel).