Trouble using port R as GPIO on Xplained Pro for ATxmega128A1U

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

Hello group,

 

I hate to ask this, but is there a trick to using port R bits 1-0 as GPIO on the Xplained Pro for the ATxmega128A1U?

 

Looking at the Xplained Pro schematic, it appears PR0 & PR1 are not used by any circuitry on the board, and are directly available on one of the external connectors.  I can see the port R0 & R1 pins coming off of the MCU on pins 91 & 92, labeled PR0_GPIO and PR1_GPIO.  They go into a bus structure, and exit in a group of signals that go to connector EXT1, where they are renamed to PIN9_IRQ/GPIO and PIN10_SPI_SS_B/GPIO.  A couple pages down the EXT1 signals are wired to a physical connector, J200.  As you would expect, the signals are indeed on pins 9 and 10.

 

I tried writing to the PORTR_DIR and PORTR_OUT registers - I can see the DIR and OUT bits being set in the debugger under the PORTR tab, but the actual port pins do not change - they remain high impedance.  I verified this by directly probing the MCU pins 91 & 92.  It's as if there is some other function that is preventing the use of port R.  Coming out of reset, I initialize the stack pointer and then configure the ports, so it doesn't appear to be anything I am doing.

 

I really need the port R bits to be outputs.  If anyone has resolved this, I would love to hear about it.  Thank you!

 

Altazi

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

I used the following in main and had both signals toggling just fine

	PORTR.DIR = PIN0_bm | PIN1_bm;

	while (1)
	{
		PORTR.OUTTGL = PIN0_bm | PIN1_bm;
	}

Show your code and I might be able to spot what the problem is.

"I may make you feel but I can't make you think" - Jethro Tull - Thick As A Brick

"void transmigratus(void) {transmigratus();} // recursio infinitus" - larryvc

"It's much more practical to rely on the processing powers of the real debugger, i.e. the one between the keyboard and chair." - JW wek3

"When you arise in the morning think of what a privilege it is to be alive: to breathe, to think, to enjoy, to love." -  Marcus Aurelius

Last Edited: Wed. Feb 28, 2018 - 07:26 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello Larry,

 

Here are the snippets of code relating to port R

 

At this point in the power-up initialization, I have already configured all ports in alphabetic sequence.  All ports configure properly except for port R.

 

    LDI        R16,$00                ; port data output register (LED off)
    LDI        R17,$01                ; port data direction register (bit 0=input, 1=output)
    LDI        R29,HIGH(PORTR)        ; Y points to base address for selected port
    LDI        R28,LOW(PORTR)        ;
    CALL    CFG_PORT            ; configure port with specified settings

 

Here is the port configuration subroutine.  I use this to avoid a lot of duplication.  It works just fine on everything except port R.

 

; Upon entry:    Y contains port base (Y supports indirect + displacement)
;                R16 contains port output value
;                R17 contains data direction register (bit 0=in, 1=out)
;
    .EQU        PORTA    =    $0600    ; port A base address
    .EQU        PORTB    =    $0620    ; port B base address
    .EQU        PORTC    =    $0640    ; port C base address
    .EQU        PORTD    =    $0660    ; port D base address
    .EQU        PORTE    =    $0680    ; port E base address
    .EQU        PORTF    =    $06A0    ; port F base address
    .EQU        PORTH    =    $06E0    ; port H base address
    .EQU        PORTJ    =    $0700    ; port J base address
    .EQU        PORTK    =    $0720    ; port K base address
    .EQU        PORTQ    =    $07C0    ; port Q base address
    .EQU        PORTR    =    $07E0    ; port R base address

CFG_PORT:
    PUSH        R18                ; save R18

    STD            Y+$04,R16        ; write R16 as port output value (PORTx_OUT)
    STD            Y+$00,R17        ; write R17 as port direction (PORTx_DIR)

    CLR            R18                ; clear port interrupt settings
    STD            Y+$09,R18        ; PORTx_INTCTRL
    STD            Y+$0A,R18        ; PORTx_INT0MASK
    STD            Y+$0B,R18        ; PORTx_INT1MASK

    POP            R18                ; restore R18
    RET                            ; done

 

As I mentioned previously, viewing I/O window in the debugger, I can see the bits in the PORTR_DIR and PORTR_OUT registers being configured properly.  it's just that the actual port pins do not reflect the port configuration.  I am mystified.  It reminds me of trying to use all pins on port B, but having forgotten to disable JTAG.

 

Altazi

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

I assume that you have tested the other ports to verify that you can change the pin states, is that correct?

 

Oh, are you by chance using the external crystal?  That is an alternate function for PORTR.  See page 62 of the XMEGA A1U datasheet.  Switch to an internal clock and see if it works.

 

EDIT: Disregard that second line.

"I may make you feel but I can't make you think" - Jethro Tull - Thick As A Brick

"void transmigratus(void) {transmigratus();} // recursio infinitus" - larryvc

"It's much more practical to rely on the processing powers of the real debugger, i.e. the one between the keyboard and chair." - JW wek3

"When you arise in the morning think of what a privilege it is to be alive: to breathe, to think, to enjoy, to love." -  Marcus Aurelius

Last Edited: Wed. Feb 28, 2018 - 08:29 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

New information.  To make a long story short, everything works fine on another Xplained Pro.