a port from atmega323 to atxmega128a1,but why error?

Go To Last Post
2 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

When I run the code for a moment, it all stop at delay_ms(50). Why? and how to debug the error.

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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...

 

https://github.com/win-t/FreeRTO...

 

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
    cli();

    {
        //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
    sei();

}

 

Last Edited: Tue. May 18, 2021 - 12:04 PM