Confused regarding use of remap port for SPI/USART

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

Would someone please help me understand how to use the remap register properly.

The 128A3U processor has 2 USARTs and 1 SPI port on Port C.

USART0 on lower nibble

USART1 & SPIC on upper nibble.

 

Scenario 1

If I enable SPIC and disable USART1 then set the SPI pin swap bit in the remap register:

      MOSI/SCK (PC5/PC7) is now MOSI/SCK (PC7/PC5)?

 

Scenario 2

If I disable SPIC and enable USART1in SPI master mode then set the SPI pin swap bit in the remap register:

     XCK/TXD (PC5/PC7) is now TXD/XCK (PC7/PC5)? 

     or does the SPI bit swap have no effect for this senario?

 

 

The reason I ask is because I have existing hardware that is wired for the standard SPI pinout and want to

use the USART in SPI mode instead.  I was hoping that I could use the pin swap bit to eliminate having to

change the wiring on the XCK and TXD lines.

 

 Why do they actually have the XCK and TXD reversed from SCK and MOSI in the first place?  Backwards compatibility?

Would someone please help me understand? 

 

Thanks

Jim

Largo, Florida

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

AFAIK, the SPI remap swaps the SPI pins, not the USART pins, regardless of what mode the USART is in.  For scenario 1, yes, MOSI and SCK are swapped for SPIC.  In scenario 2 you are using a USARTC1, so the SPI remap would have no effect.

 

As to why the SPI and USART signals weren't laid out so MOSI & TX, MISO & RX, SCK & CLK, were on the same pins, respectively, is a question only Atmel can answer.

 

Greg Muth

Portland, OR, US

Xplained/Pro/Mini Boards mostly

 

Make Xmega Great Again!

 

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

Yes - Based on my tests your explanation appears correct. 

It just *seems* to me the pin swap on the SPI would be more useful on the USART pins instead. Maybe even on both.

 

Thanks for the response.

Jim

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

I just ran across this trying to upgrade an existing device (with an XMega32A4U) from normal SPI to USART in SPI master mode. I can't for the *life* of me understand why the SPI bit in REMAP doesn't apply to the USART0 pins as well or that there isn't another bit in the register to align USART0 to the SPI pinout.

 

It's not often I call shenanigans on Atmel, but this is definitely one time.