1 / 23

XC878 Product Presentation

XC878 Product Presentation. Capture Compare Unit T2CCU. Table of contents. Introduction into T2CCU. Basic Operation of T2CCU. Practical Usage of T2CCU – Software Examples. Introduction into T2CCU – Overview. T2CCU is a simplified Capture/Compare Unit

rey
Download Presentation

XC878 Product Presentation

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. XC878 Product Presentation Capture Compare Unit T2CCU

  2. Table of contents Introduction into T2CCU Basic Operation of T2CCU Practical Usage of T2CCU – Software Examples

  3. Introduction into T2CCU – Overview • T2CCU is a simplified Capture/Compare Unit • one 16bit autoreload timer which counts up • programmable reload value • interrupt on overflow • 6 independent capcom channels interrupt • two selectable time base units: CCT or T2 • clock prescaler options up to ft2ccu = 2x fcpu (48MHz) • synchronize features for CCT & T2 • ADC trigger features

  4. Introduction into T2CCU – Applications • T2CCU can be used for • stepper motor control (full-/half-/microstep) • 6 channel PWM generation (e.g. LED control) • 3 phase PWM with deadtime (motor control, PFC, lampballast) • multiple trigger pulses (e.g. for valve control) • capturing external events

  5. Introduction into T2CCU – SFR view • SFR view of T2CCU and paging working page of T2 working pages of T2CCU

  6. Table of contents Introduction into T2CCU Basic Operation of T2CCU Practical Usage of T2CCU – Software Examples

  7. Basic Operation of T2CCU – Compare Mode 0 PWM Generation • Compare Mode 0: • output change (set / reset) on • compare and overflow • up to 6 channels • 2 can be combined with PolA/B and deadtime for 3 phase halfbridge control • shadow transfer mechanism for compare value update • update compare channels • set TXOF • clear TXOF • compare value is active with next timer overflow • note: compare value must not be smaller than reload value Example: 3 phase sine wave generation with deadtime EX: T2CCU_1

  8. Basic Operation of T2CCU – Compare Mode 1 Pulse Pattern Generation • Compare Mode 1: • output latch is updated by hardware on compare event • timing of the update is dependent on channel individual compare • level of the output latch can be programmed to COOUTx register • output change (set / reset) on • compare only (not on overflow) • two shadow transfer mechanism for • compare and COOUTx update • use TXOF for timer synch. update • use ENSHDW for immediate update • note: compare value must not be smaller than reload value • note: take care for update in realtime

  9. Basic Operation of T2CCU – Compare Mode 1 Pulse Pattern Generation • Compare Mode 1: • use this mode for flexible pulse pattern generation • use TXOF for timer synchronous update for shadow transfer of all compare values Example: Overlapping pulse pattern with variable distance EX: T2CCU_2

  10. Basic Operation of T2CCU – Concurrent Compare Mode Stepper Motor Control • Concurrent Compare Mode: • similar to Compare Mode 1 • but only Compare 0 register has to be written • Stepper Motor Control • fullstep / halfstep mode • timer period refers to speed • equidistant compare values • use ENSHDW to update next compare value • pattern & time schedule table can be used • note: realtime update is mandatory Example: Stepper motor pattern for fullstep mode EX: T2CCU_3

  11. Basic Operation of T2CCU – Capture Mode Capturing External Events • Capture Modes : • capture external events on • rising / falling / both edges • soft-capture – read actual timervalue • individual interrupt flags for every capture event • note: take care on timer overflow while capturing Example: T2CC0-Capturing a sawtooth signal from T13 EX: T2CCU_4

  12. Table of contents Introduction into T2CCU Basic Operation of T2CCU Practical Usage of T2CCU – Software Examples

  13. T2CCU together with DAvE v11 • Note: DAvE version V1.1 needs some manual adaptations in initialization file CCU.C • This is necessary in case of usage of immediate shadow transfer request via ENSHDW

  14. Practical Usage of T2CCU – Example 13 phase sine wave generation with deadtime • Use Excel Spreadsheet for SineTab.c • Motor Control example for 3 phase halfbridge • Sine-Generation very much simplified • T2CCU Settings • compare mode 0 • PolA/PolB with deadtime • update compare value inside CCT overflow interrupt (TXOV) • used pins • P30/32/34/35/P06/07 • CCT runs at 48MHz • 12bit res.@20kHz PWM What does the example do? • Add SineTab.c to project

  15. Practical Usage of T2CCU – Example 13 phase sine wave generation with deadtime • CCT overflow interrupt • update duty cycle from table • request shadow transfer (using TXOV) • Copy following code • shared_int.c if (T2CCU_CCTCON & 0x08) { // a Capture/Compare Timer (CCT) Overflow has occured T2CCU_CCTCON &= ~(ubyte)0x08; // clear CCTOVF // USER CODE BEGIN (SHINT_XINTR5Isr,5) SFR_PAGE(_t2_2, SST1); TXOV = 0; // clr TXOV to ensure simultaneous // update of all channels SFR_PAGE(_t2_0, RST1); idxA++; if (idxA > 119) idxA=0; i= SineTab[idxA]; CCU_vLoadChannelCapCompRegister_0(SineTab[idxA]); CCU_vLoadChannelCapCompRegister_1(SineTab[idxA]); idxB++; if (idxB > 119) idxB=0; CCU_vLoadChannelCapCompRegister_2(SineTab[idxB]); CCU_vLoadChannelCapCompRegister_3(SineTab[idxB]); idxC++; if (idxC > 119) idxC=0; CCU_vLoadChannelCapCompRegister_4(SineTab[idxC]); CCU_vLoadChannelCapCompRegister_5(SineTab[idxC]); SFR_PAGE(_t2_2, SST1); TXOV = 1; // request shadow transfer // with next overflow SFR_PAGE(_t2_0, RST1); // USER CODE END } What to do in software?

  16. Practical Usage of T2CCU – Example 13 phase sine wave generation with deadtime • Scope Screenshots Scope Screenshot back

  17. Practical Usage of T2CCU – Example 2Overlapping pulse pattern with variable distance • Pulse Pattern Example • generate signals with accurate timing to each other • variable delta between the signals, constant period • T2CCU Settings • compare mode 1 • 4 channels – T2CC0/1/2/3 • update compare values at CCT overflow using TXOF • used pins • P30/32/34/35 What does the example do?

  18. Practical Usage of T2CCU – Example 2Overlapping pulse pattern with variable distance • CCT overflow interrupt • update next compare value • request shadow transfer using TXOV • Copy following code • shared_int.c if (T2CCU_CCTCON & 0x08) { // a Capture/Compare Timer (CCT) Overflow has occured T2CCU_CCTCON &= ~(ubyte)0x08; // clear CCTOVF // USER CODE BEGIN (SHINT_XINTR5Isr,5) P3_DATA ^= 0x80; // trigger synch delta += 0x400; if (delta == 0x4000) delta = 0; ch0 = 0x4000; ch1 = ch0 + 0x8000 + delta; ch2 = ch0 + 0xA000 - delta; ch3 = 0xA000 + delta; SFR_PAGE(_t2_2, SST0); T2CCU_COSHDW &= ~0x40; // clear TXOV because it is sticky CCU_vLoadChannelCapCompRegister_0(ch0); CCU_vLoadChannelCapCompRegister_1(ch1); CCU_vLoadChannelCapCompRegister_2(ch2); CCU_vLoadChannelCapCompRegister_3(ch3); T2CCU_COSHDW ^= 0x0F; // clr T2CCU.1 T2CCU_COSHDW |= 0x40; // shadow transfer request on next TXOV // USER CODE END } What to do in software?

  19. Practical Usage of T2CCU – Example 2Overlapping pulse pattern with variable distance • Scope Screenshots Scope Screenshot back

  20. Practical Usage of T2CCU – Example 3Stepper motor pattern for fullstep mode • Stepper Motor Example • Full Step Mode • T2CCU Settings • concurrent compare mode • 4 channels – T2CC0/1/2/3 • update compare values inside T2CCU0 channel interrupt (using ENSHDW) • used pins • P30/32/34/35 • Note: shadow transfer request needs concurrent write to ENSHDW and COOUT0 What does the example do?

  21. Practical Usage of T2CCU – Example 3Stepper motor pattern for fullstep mode • T2CCU Channel 0 interrupt • update next compare value • request shadow transfer using • ENSHDW together with CCOUT0 • T2CCU_COSHDW = 0x81; • Copy following code • shared_int.c • Copy following code • ccu.c • because of Dave v11 malfunction if (IRCON0 & 0x08) { IRCON0 &= ~(ubyte)0x08; // clear EXINT3 // USER CODE BEGIN (SHINT_XINTR9Isr ,3) for (i=0x40; i>0; i--); switch (c) { case 0: CCU_vLoadChannelCapCompRegister_0(0xBFFF); CCU_vEnableCompareChannelOutput(0x01); SFR_PAGE(_t2_2, SST1); T2CCU_COSHDW = 0x81; SFR_PAGE(_t2_0, RST1); c++; break; case 1: CCU_vLoadChannelCapCompRegister_0(0xCFFF); CCU_vEnableCompareChannelOutput(0x02); SFR_PAGE(_t2_2, SST1); T2CCU_COSHDW = 0x81; SFR_PAGE(_t2_0, RST1); c++; break; etc.... } /// ---------------------------------------------- /// Configuration of Peripheral Input Selection: /// ---------------------------------------------- // USER CODE BEGIN (T2CCU_Init,3) // ENSHDW must be enabled together with COOUTx bits // Dave malfunction SFR_PAGE(_t2_2, noSST); // switch to page 2 T2CCU_COSHDW = 0xBF; // load Compare // Shadow register // USER CODE END What to do in software?

  22. Practical Usage of T2CCU – Example 3Stepper motor pattern for fullstep mode • Scope Screenshots Scope Screenshot? back

More Related