AVRDragon Xmega128A1 debug issues.

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

Hallo again, gentlemen:

I'm trying to debug my first AS5 project with ASF (usually I don't use libraries), on a self designed Xmega128A1 PCB, using AVRDragon and JTAG on PORTB.

When I start debugging, I found that part of the initialization routines work fine (clksystem, CPU, power control, IOPorts), but when trying to init port peripherals like SPI, TWI, ADC, I simply can't see, neither update them.

I step the function, but no changes on the IO view on the right panels. Neither can I change bits clicking with the mouse on those peripherals, while I can change bits in the PR register set, as an example, or change the IO configuration. This only happens with port peripherals. For sure ADCA, any TWI, any SPI, any TC.

AS5 is last release, downloaded two hours ago (5.0.1163). AVRDragon firmware was updated after successful update of AS5.

Is there anything that I did wrong, or is there a problem with the SW?

May I post the whole AS5 project?

Guillem.
"Common sense is the least common of the senses" Anonymous.

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

Hi, an update:

I've checked with this two codes:

/*inline */void InitSPI_F(void)
{
	SPI_t *port;
	char aux;
	
	port = &SPIF;
	aux = (1<<SPI_ENABLE_bp)|(1<<SPI_MASTER_bp)|(0 << SPI_PRESCALER1_bp) | (1 << SPI_PRESCALER0_bp);//SPI in master mode, and enabled. Prescaler CLK/16 and mode 00
	port->CTRL = aux;
}	

and this:

/*inline */void InitSPI_F(void)
{
	SPIF.CTRL = (1<<SPI_ENABLE_bp)|(1<<SPI_MASTER_bp)|(0 << SPI_PRESCALER1_bp) | (1 << SPI_PRESCALER0_bp);
}

In both cases, there are no changes in the SPIF peripheral view in the IO View windows.

The file has also the following codes:

void init_PowerControl(void)
{
	PR.PRGEN = (1<<PR_RTC_bp);//Only RT is used by now
	PR.PRPA = (1<<PR_ADC_bp);//Only ADC in port A is used by now
	PR.PRPB = 0; //Nothing used here
	PR.PRPC = (1<<PR_USART1_bp);//The USARTC1 is used as 'debug port'
	PR.PRPD = 0;
	PR.PRPE = 0;
	PR.PRPF = (1<<PR_USART0_bp)|(1<<PR_TWI_bp)|(1<<PR_SPI_bp); //USARTF0 is used as 'USB serial link', TWI is used for some peripherals, as well as SPI
}

This code modifies the Power Control registers, and they can be modifed by clicking with the mouse.

The order is totally irrelevand: I tried to set up the power registers before init the SPIF and after, always with the same result.

The whole init sequence is:

void board_init(void)
{
	/* This function is meant to contain board-specific initialization code
	 * for, e.g., the I/O pins. The initialization can rely on application-
	 * specific board configuration, found in conf_board.h.
	 */
	
	Disable_global_interrupt();
	sysclk_init(); //Start up the system clock
	init_IOPorts(); //Let's configure the on board IO ports.
	CLK.RTCCTRL = 0x0B; //Time to start up the RTC.
	//osc_wait_ready(XOSC_TYPE_32KHZ);//Wait Ocillator startup.
	InitSPI_F();//Now it is a good moment to configure the SPI, since the PWR pin at the expansion output port might be required.
	SetExpansionOutputs(PWR|GREENLED|YELLOWLED);//Thus here we also init the Output Expansion port
	//Let's continue initializing the remaining peripherals required, starting by the TWI on port F
	init_TWI(TWIF);
	//Serial port on port F for USB comms.
	init_USART(DEBUGPORT);
	init_ADCA();//ADC setup but without starting it (intended to be used with DMA).
	//IRQ Controller setup.
	//Port F timers set up for ADC conversions and system tick(s).
	init_PowerControl();//Power control
	//CPU init (if required, not known at this stage of development).
	Enable_global_interrupt();
}

So, maybe is another stupid error of mine, but my poor neuron can barely handle breathing and typing at once, no processing power enough to find the problem.

Can some one see where lies my mistake, or is this a Bug in the debug system of AS5?

It seems to me that I couldn't finish this project by the deadtime of the ASFreview contest, but probably I will post my commens (rants) on it, just to feel better. :twisted:

I will try also soon to port this project to AS4 and try again, only the nightmare of files and folders prevented me to do before.

Ah, I forget: I've tested with two different computers, one with WinXP and another one with Win7. Damn slow on both.

Thanks in advance,

Guillem.
"Common sense is the least common of the senses" Anonymous.

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

Quote:

Can some one see where lies my mistake, or is this a Bug in the debug system of AS5?

I've seen prior threads here about IO view problems - probably worth searching out. I think it may have been faults in the defining XML files. But you have top understand that AS5 is just beta and you shouldn't be relying on it yet for anything that is mission critical.

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

Je, je, I know it is a beta, and luckily this is not a mission critical. In fact, I'm trying to turn on a nice dev board I designed and that is collecting dust. Right now I use the ASF review contest as an excuse to write the code in a short time. Probably, by october, there will be someone that will test some features of the PCB, so there are other reasons, but this is only hobby, fun and a way to remove the thick layer of corrosion on top of my uC programming skills.

I also read many posts regarding troubles debugging, debugwire and other issues with AS5, but I didn't read, neither searched, for other problems with IO view. And before I do more research regarding this issue, I need to do solve two HW problems I had yesterday with the PCB I use for development, to assure that this is a bug.

Guillem.
"Common sense is the least common of the senses" Anonymous.

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

Oh, I forget: thank you for the reply.

Guillem.
"Common sense is the least common of the senses" Anonymous.

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

Since it seems to be a problem with AS5, and the ASF Contest can be done with AS4, I'm porting it the whole project to this IDE. 65 files in 31 folders, as well as the whole setup, will require some patience and time...

Guillem.
"Common sense is the least common of the senses" Anonymous.

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

After struggling a little bit with the code, finally I gave up. I've posted the project. I write the review (generally speaking, a long and heavy rant). Now, I bet that two things will happen: more time is given to the contest, since there are only 4 projects, or that the other three will win the three prices. :cry:

After all, this is a failed project. :cry:

And now, I have many other important personal things to do in a really short time. Who knows when I will struggle again with this HW, but for sure I will begin from the very basics, AS4, and, as usuall, I will write my own libraries. :evil:

EDIT: Spelling.

Guillem.
"Common sense is the least common of the senses" Anonymous.

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

You are not setting the Power Reduction Registers correctly in your code:

void init_PowerControl(void)
{
   PR.PRGEN = (1<<PR_RTC_bp);//Only RT is used by now
   PR.PRPA = (1<<PR_ADC_bp);//Only ADC in port A is used by now
   PR.PRPB = 0; //Nothing used here
   PR.PRPC = (1<<PR_USART1_bp);//The USARTC1 is used as 'debug port'
   PR.PRPD = 0;
   PR.PRPE = 0;
   PR.PRPF = (1<<PR_USART0_bp)|(1<<PR_TWI_bp)|(1<<PR_SPI_bp); //USARTF0 is used as 'USB serial link', TWI is used for some peripherals, as well as SPI
} 

A "1" enables power reduction. I.e., it turns the clock to that module OFF.

The sysclk_init() function in the ASF sysclk module sets all the the PR registers to 0xFF, turning OFF the clock to all modules. As modules are enabled by the ASF drivers, the clocks to those modules are enabled. So, if you don't want to use the ASF drivers, change your code to this:

void init_PowerControl(void)
{
   PR.PRGEN &= ~PR_RTC_bm;
   PR.PRPA &= ~PR_ADC_bm;
   PR.PRPC &= ~PR_USART1_bm;
   PR.PRPF &= ~(PR_USART0_bm | PR_TWI_bm | PR_SPI_bm);
}

and it should work.

NOTE: There is a bug in the sysclk module that prevents the USART clocks from being enabled. See AVR Bugzilla Bug Report 1070. I will attach my version of sysclk.h that addresses this issue.

GTKNarwhal

Attachment(s): 

Gamu The Killer Narwhal
Portland, OR, US
_________________
Atmel Studio 6.2
Windows 8.1 Pro
Xplained boards mostly

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

Thank you very much for you help and clear explanation. Tomorrow, when I have the setup at hand, I will try your suggestions. They look promissing and clearly consistent with my last tries.

Guillem.
"Common sense is the least common of the senses" Anonymous.

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

Checked, and it works fine. I should change the startup sequence and start the power registers before the peripheral are set, since the ASF will stop all of them.

Thanks for your help.

Guillem.
"Common sense is the least common of the senses" Anonymous.