XMEGA event system-timer hardware problem

1 post / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Initial setup is as follows:

 

TCD1 serves as a prescaler, that clocks TCC0 via EVENT SYSTEM channel 4.

Everything works perfect except the only moment: if you stop prescaling timer EXACTLY when TCD1_CNT == 1, event will be generated every clock cycle infinitely.

Writing any value to any TCD1 register solves the problem.

 

Problem confirmed for XMEGA32A4U and XMEGA128A1U chips.

Problem confirmed for all timers and all event system channels.

 

Test code

PORTC_DIRSET  = 1<<0;

TCC0_CTRLC    = 0;
TCC0_CTRLB    = 0x10 | TC_WGMODE_SINGLESLOPE_gc;
TCC0_CTRLD    = 0;
TCC0_CTRLE    = 0;
TCC0_PER      = 24;
TCC0_CCA      = 10;
TCC0_CCB      = 10;
TCC0_CTRLA    = TC_CLKSEL_EVCH4_gc;

EVSYS_CH4MUX  = EVSYS_CHMUX_TCD1_OVF_gc;
EVSYS_CH4CTRL = 0;

TCD1_CTRLC = 0;
TCD1_CTRLB = 0x30 | TC_WGMODE_SINGLESLOPE_gc;
TCD1_CTRLD = 0;
TCD1_CTRLE = 0;
TCD1_PER = 24;
TCD1_CCA = 10;
TCD1_CCB = 10;
// start prescaler
TCD1_CTRLA    = TC_CLKSEL_DIV1_gc;

// wait for 1 full period...
	asm ("nop");
	asm ("nop");
	asm ("nop");
	asm ("nop");
	asm ("nop");

	asm ("nop");
	asm ("nop");
	asm ("nop");
	asm ("nop");
	asm ("nop");

	asm ("nop");
	asm ("nop");
	asm ("nop");
	asm ("nop");
	asm ("nop");

	asm ("nop");
	asm ("nop");
	asm ("nop");
	asm ("nop");
	asm ("nop");

	asm ("nop");
	asm ("nop");
	asm ("nop");
	asm ("nop");

// ..and stop prescaler
TCD1_CTRLA    = TC_CLKSEL_OFF_gc;

// if TCD1_CNT is equal to 1, you will see TCC0 running forever

// possible workarounds
//TCD1_CTRLA    = TC_CLKSEL_OFF_gc;
//TCD1_CNT      = 1;

asm ("nop");

while(1);

 

Last Edited: Fri. Jul 22, 2022 - 05:46 PM