This is a VERY low-level library for controlling the TSI hardware module in a KL25 microcontroller. The programmer creates the TSI object passing basic parameters, and selects the active channels. Then, a scan on a given channel can be started, and the raw result can be read.
Registers.txt@1:532aa572220b, 2014-09-26 (annotated)
- Committer:
- quevedo
- Date:
- Fri Sep 26 17:25:06 2014 +0000
- Revision:
- 1:532aa572220b
- Parent:
- 0:b39f4f954a9b
Corrected to activate clock gating on PORTs A, B, and C so all electrodes can work
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
quevedo | 0:b39f4f954a9b | 1 | /* |
quevedo | 0:b39f4f954a9b | 2 | TSI REGISTERS |
quevedo | 0:b39f4f954a9b | 3 | ------------------------------------------ |
quevedo | 0:b39f4f954a9b | 4 | |
quevedo | 0:b39f4f954a9b | 5 | TSI0_GENCS: |
quevedo | 0:b39f4f954a9b | 6 | Bit 31: OUTRGF; Out-of-range flag; set if result register is out of the range given by TSI_THRESHOLD; write 1 to clear |
quevedo | 0:b39f4f954a9b | 7 | Bit 28: ESOR; Selector for End-of-scan (set) or out-of-range (clear) interrupt source |
quevedo | 0:b39f4f954a9b | 8 | Bits 27-24: MODE; defines analog mode; keep bits 25-24 to 00 |
quevedo | 0:b39f4f954a9b | 9 | 0000: capacitive sensing (non-noise detection) |
quevedo | 0:b39f4f954a9b | 10 | 0100: Single threshold noise detection mode; frequency limitation disabled |
quevedo | 0:b39f4f954a9b | 11 | 1000: Single threshold noise detection mode; frequency limitation enabled |
quevedo | 0:b39f4f954a9b | 12 | 1100: Automatic noise detection mode |
quevedo | 0:b39f4f954a9b | 13 | Bits 23-21: REFCHRG; current value for charging the reference oscillator |
quevedo | 0:b39f4f954a9b | 14 | 000: 500nA |
quevedo | 0:b39f4f954a9b | 15 | 001: 1uA |
quevedo | 0:b39f4f954a9b | 16 | 010: 2uA |
quevedo | 0:b39f4f954a9b | 17 | 011: 4uA |
quevedo | 0:b39f4f954a9b | 18 | 100: 8uA |
quevedo | 0:b39f4f954a9b | 19 | 101: 16uA |
quevedo | 0:b39f4f954a9b | 20 | 110: 32uA |
quevedo | 0:b39f4f954a9b | 21 | 111: 64uA |
quevedo | 0:b39f4f954a9b | 22 | Bits 20-19: DVOLT; oscillator's voltage rails |
quevedo | 0:b39f4f954a9b | 23 | 00: DV = 1.03V; Vp = 1.33V; Vm = 0.30V |
quevedo | 0:b39f4f954a9b | 24 | 01: DV = 0.73V; Vp = 1.18V; Vm = 0.45V |
quevedo | 0:b39f4f954a9b | 25 | 10: DV = 0.43V; Vp = 1.03V; Vm = 0.60V |
quevedo | 0:b39f4f954a9b | 26 | 11: DV = 0.29V; Vp = 0.95V; Vm = 0.67V |
quevedo | 0:b39f4f954a9b | 27 | Bits 18-16: EXTCHRG; current value for charging the electrode oscillator |
quevedo | 0:b39f4f954a9b | 28 | Same values as for REFCHRG |
quevedo | 0:b39f4f954a9b | 29 | Bits 15-13: PS; electrode oscillator prescaler |
quevedo | 0:b39f4f954a9b | 30 | Value is 2 to the power of the number given by the three bits (0-7) |
quevedo | 0:b39f4f954a9b | 31 | Bits 12-8: NSCN; Number of scans for each electrode |
quevedo | 0:b39f4f954a9b | 32 | Value is the number given by the five bits (0-31) plus 1. |
quevedo | 0:b39f4f954a9b | 33 | Bit 7: TSIEN; TSI enable; set to enable |
quevedo | 0:b39f4f954a9b | 34 | Bit 6: TSIIEN; TSI interrupt enable; set to enable |
quevedo | 0:b39f4f954a9b | 35 | Bit 5: STPE; STOP enable; set to allow TSI to run in low-power modes |
quevedo | 0:b39f4f954a9b | 36 | Bit 4: STM; Scan Trigger Mode; clear to software and set to hardware |
quevedo | 0:b39f4f954a9b | 37 | Bit 3: SCNIP; Scan In Progress status; set if there is a scan in progress |
quevedo | 0:b39f4f954a9b | 38 | Bit 2: EOSF; End of Scan Flag; set if scan complete |
quevedo | 0:b39f4f954a9b | 39 | Bit 1: CURSW; Current sources swapped; set if swapped |
quevedo | 0:b39f4f954a9b | 40 | |
quevedo | 0:b39f4f954a9b | 41 | TSI0_DATA: |
quevedo | 0:b39f4f954a9b | 42 | Bits 31-28: TSICH; current channel to be measured (4 bits, values 0 to 15) |
quevedo | 0:b39f4f954a9b | 43 | Bit 23: DMAEN; DMA enabled; set for DMA transfer instead of interrupt |
quevedo | 0:b39f4f954a9b | 44 | Bit 22: SWTS; Software Trigger Start; write 1 to start scan if software trigger was selected |
quevedo | 0:b39f4f954a9b | 45 | Bit 15-0: TSICNT; TSI Conversion Counter; record the accumulated scan counter value ticked by the reference oscillator |
quevedo | 0:b39f4f954a9b | 46 | |
quevedo | 0:b39f4f954a9b | 47 | TSI0_TSHD: |
quevedo | 0:b39f4f954a9b | 48 | Threshold value |
quevedo | 0:b39f4f954a9b | 49 | ---------------------------------------------------- |
quevedo | 0:b39f4f954a9b | 50 | |
quevedo | 0:b39f4f954a9b | 51 | */ |