Usart Registers are never written to

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

I am programming an xmega16a4u with a jtagice mkII in Atmel Studio 7.

I am currently trying to get the Usart to work, but the registers are never written to.

My code:

	PORTD.DIR |= (1 << 3);
	PORTD.DIR &= ~(1 << 2);

	USARTD0.BAUDCTRLA |= 0x03;
	USARTD0.BAUDCTRLB |= (0b1001 << 4 | 0x06);
	USARTD0.CTRLA |= USART_RXCINTLVL_LO_gc;
	USARTD0.CTRLB |= USART_TXEN_bm | USART_RXEN_bm;
	USARTD0.CTRLC |= USART_CHSIZE_8BIT_gc;

	while(1)
	{
		while (!( USARTC0.STATUS & USART_DREIF_bm));
		USARTC0.DATA = 0x47;
	}

After executing this code, BAUDCTRLA, for example, still is 0.

 

I am looking forward to your answers.

This topic has a solution.
Last Edited: Sat. Jul 8, 2017 - 06:35 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Note that it is not necessarily the case that a hardware register will read-back what you just wrote to it.

 

Are those registers supposed to read-back what you wrote to them?

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

Hmm...  You configure USARTD0, but in the while loop, you are checking the status of USARTC0.  What's up with that?

 

Are you using ASF?

 

Greg Muth

Portland, OR, US

Atmel Studio 7.0 on Windows 10

Xplained/Pro/Mini Boards mostly

 

 

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you for your answer. I simply forgot to reenable the module.