When I run the code for a moment, it all stop at delay_ms(50). Why? and how to debug the error.
If that is a debugger with a PDI/JTAG link to the Xmega then why don't you simply step IN to the call to delay_ms()?
But what have you done about porting to Xmega anyway? The port layer basically consists of setting up a timer interrupt? Have you done that and have you verified it is getting the interrupts at the period you expect?
EDIT: I just googled and found this...
Are you using something like that? As you can see the timer setup is something like:
static void prvSetupTimerInterrupt(void)
// disable global interrupt for a moment
//enable TC0 clock source, high resolution
PR.PRPC &= ~(PR_TC0_bm | PR_HIRES_bm);
//set period of counter
TCC0.PER = (configCPU_CLOCK_HZ / configTICK_RATE_HZ / 1) - 1;
//enable interrupt and set low level
TCC0.INTCTRLA = TC_OVFINTLVL_LO_gc;
//enable low-level interrupt
PMIC.CTRL |= PMIC_LOLVLEN_bm;
//select (start) the clock source
TCC0.CTRLA = TC_CLKSEL_DIV1_gc;
// enable global interrupt
© 2021 Microchip Technology Inc.