Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

Re: ATxmega64A3 Capture TCD0.CCA problem

2011-07-27 by warm38spl

--- In AVR-Chat@yahoogroups.com, "Don Kinzer" <dkinzer@...> wrote:
>
> --- In AVR-Chat@yahoogroups.com, "warm38spl" <warm38@> wrote:
> >  TDC0.CNT = 0x0000;
> >  TCD0.CCA = 0x0000;
> >  TCD0.PER = 0x065F;
> >  TCD0.CTRLA = TC_CLKSEL_DIV1_gc;
> 
> Either you didn't show us all of your initialization or you're missing something.  You also need something like shown below (insert prior to the write to CTRLA), assuming the use of event channel 0.
> 
> TCD0.CTRLB = TC0_CCAEN_bm;
> TCD0.CTRLD = TC_EVACT_CAPT_gc | TC_EVSEL_CH0_gc | 0x0002;

At the startup that stuff is handled by the code generated by the CodeVisionAVR Wizard.  The code I was showing was my own which was added to do the job.  OK here is the CVAVR startup code snippets:

For TDC0:
    TCD0.CTRLA=(TCD0.CTRLA & (~TC0_CLKSEL_gm)) | TC_CLKSEL_DIV1_gc;
    // Mode: Normal Operation, Overflow Int./Event on TOP
    // Compare/Capture on channel A: On
    // Compare/Capture on channel B: Off
    // Compare/Capture on channel C: Off
    // Compare/Capture on channel D: Off
    TCD0.CTRLB=(TCD0.CTRLB & (~(TC0_CCAEN_bm | TC0_CCBEN_bm | TC0_CCCEN_bm | TC0_CCDEN_bm | TC0_WGMODE_gm))) |
        TC0_CCAEN_bm |
        TC_WGMODE_NORMAL_gc;

    // Capture event source: Event Channel 0
    // Capture event action: Input Capture
    TCD0.CTRLD=(TCD0.CTRLD & (~(TC0_EVACT_gm | TC0_EVSEL_gm))) |
        TC_EVACT_CAPT_gc | TC_EVSEL_CH0_gc;

For Events:

    // Event System Channel 0 source: Port B, Pin1
    EVSYS.CH0MUX=EVSYS_CHMUX_PORTB_PIN1_gc;

For PortB Pin 1:

    PORTB.PIN1CTRL=PORT_OPC_TOTEM_gc | PORT_ISC_RISING_gc;

Now back to my original questions...
I took out the overflow from TDC0, but that didn't help, it still shows 0x8...  I did notice when I used an inverter to generate the signal and CCA held CNT+0x8000.  Exactly.

Before (on the 16A4) the testing that the other guy did showed about 1056 (0x0420) plus/minus a little in CCA.  Why is mine 0x8000 over?
Did the processor hear my negative spoken comments about its ancestry and decide to go negative to get back at me?


> You also didn't show your event channel configuration or the configuration of the pin for event generation so there could be something wrong with those, too.
> 
> Don Kinzer
> ZBasic Microcontrollers
> http://www.zbasic.net
>

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.