[HELP] Remapping Serial0 to Serial1 on ATXMEGA192

Home Forums TinyG TinyG Support [HELP] Remapping Serial0 to Serial1 on ATXMEGA192

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #7239
    Ultron
    Member

    I broke the serialport on my atxmega192 (i put 5V to input RX…).

    How i do for change serial port configuration and compile Xboot project, on AVRstudio 4?

    I would change the port0 (pinPortC 2,3) on C, with port1 (pinPortC 6, 7) still on C

    (i have AVRS 4.18 + SP3)

    Please explain step by step.

    Thanks!

    • This topic was modified 9 years, 12 months ago by Ultron.
    #7241
    cmcgrath5035
    Moderator

    Bummer
    You might want to repost this query over at

    The developers hang out in that space a lot more than here, and that’s the help source you probably need here.

    #7248
    Ultron
    Member

    In that place i have not help. Someone said that it is not the right place.

    Existing some configuration file (.H) where i can setting the serial port, first i build the project?

    #7249
    cmcgrath5035
    Moderator

    Did you, as Riley suggested, review

    And have you reviewed the schematic for your TinyG version?

    And have you verified that you can in fact get physical access to those leads on the device?
    A quick look to me sees PortC ser 1 already connects to the SPI Connector (J13), probably causing a lot of other conflicts?

    #7251
    Ultron
    Member

    Thanks for reply.

    I should study all files of the project. This is beyond my skill.

    The Hardware is simple. I not use the SPI, therefore no conflict.

    I already soldered two wires on two pin of the chip atxmega. Pin are number 22 and 23 (serial1). I must only remap the serialport on the Firmware, and compile it.

    My simple verify of the PortC pin

    #include <avr/io.h>
    #include <util/delay.h>
    
    #define BLINK_DELAY_MS 1000
    
    int main( void )
    {
      PORTC.DIRSET = 0b11111111 ; // Set pin0  to 7 to be output.
      
      while(1){ // loop forever
        PORTC.OUTSET = 0b11111111 ; // set  all output high.
        _delay_ms( BLINK_DELAY_MS ) ; // wait.
        PORTC.OUTCLR = 0b11111111 ; // set  all output low.
        _delay_ms( BLINK_DELAY_MS ) ; // wait.
      }
    }

    In this code, output portC 0,1,3,4,5,6,7 blinking well, but portC 2 not blink (the RX input). No output, either HIGH or LOW. This is broken!

    #7252
    cmcgrath5035
    Moderator

    SPI – I believe this is part of the debugger interface, so there could be internal conflicts with the tinyG code if you just hijack the leads.

    I can’t comment yes/no on your test, but it looks directionally correct.
    They appear to be shared functionality pins (PC1/XCK0), are you sure the PORTC.DIRSET is all you need (I have no experience)?

    But, I am not super surprised that your 5V oops did more damage than just that one port interface – overvoltage could have leaked back into the 3.3vBus and done random (or widespread) damage.

    Oh well

    #7253
    Ultron
    Member

    Yes, but i don’t use debugger.

    All port in chip are ok. I make some test in all pin (PortA, B, C, D, E, F) and all ok (except portC2).

    I Have check this file: xio.usart.h

    Inside this file there is pre-processor #define block:

    ————————————-
    //**** USB device configuration ****
    //NOTE: XIO_BLOCK / XIO_NOBLOCK affects reads only. Writes always block. (see xio.h)

    #define USB_BAUD XIO_BAUD_115200
    #define USB_FLAGS (XIO_BLOCK | XIO_ECHO | XIO_XOFF | XIO_LINEMODE )

    #define USB_USART USARTC0 // USB usart
    #define USB_RX_ISR_vect USARTC0_RXC_vect // (RX) reception complete IRQ
    #define USB_TX_ISR_vect USARTC0_DRE_vect // (TX) data register empty IRQ

    #define USB_PORT PORTC // port where the USART is located
    #define USB_CTS_bp (1) // CTS – bit position (pin is wired on board)
    #define USB_CTS_bm (1<<USB_CTS_bp) // CTS – bit mask
    #define USB_CTS_PINCTRL PIN1CTRL // CTS – PINxCTRL assignment
    #define USB_CTS_ISR_vect PORTC_INT0_vect // CTS – Interrupt Vector (PORTC_INT0_vect or PORTC_INT1_vect)
    #define USB_CTS_INTMSK INT0MASK // CTS – Interrupt Mask Register (INT0MASK or INT1MASK)
    #define USB_CTS_INTLVL (PORT_INT0LVL_LO_gc)

    #define USB_RTS_bp (0) // RTS – bit position (pin is wired on board)
    #define USB_RTS_bm (1<<USB_RTS_bp) // RTS – bit mask

    #define USB_RX_bm (1<<2) // RX pin bit mask
    #define USB_TX_bm (1<<3) // TX pin bit mask

    #define USB_INBITS_bm (USB_CTS_bm | USB_RX_bm) // input bits
    #define USB_OUTBITS_bm (USB_RTS_bm | USB_TX_bm) // output bits
    #define USB_OUTCLR_bm (USB_RTS_bm) // outputs init’d to 0
    #define USB_OUTSET_bm (USB_TX_bm) // outputs init’d to 1
    ————————-

    I think that this is the critical point. Can anyone confirm?

    #7256
    Ultron
    Member

    YEAAAAHHHH! It’s works!

    For anyone with my problem:

    Open the file xio_usart.h. Go down at this section: //**** USB device configuration ****

    In this section code you must change these lines:

    #define USB_USART USARTC0 // USB usart
    #define USB_RX_ISR_vect USARTC0_RXC_vect // (RX) reception complete IRQ
    #define USB_TX_ISR_vect USARTC0_DRE_vect // (TX) data register empty IRQ

    with these lines:

    #define USB_USART USARTC1 // USB usart
    #define USB_RX_ISR_vect USARTC1_RXC_vect // (RX) reception complete IRQ
    #define USB_TX_ISR_vect USARTC1_DRE_vect // (TX) data register empty IRQ
    (only change the C0 with C1 serial port)

    These lines:
    #define USB_CTS_bp (1) // CTS – bit position (pin is wired on board)
    #define USB_CTS_PINCTRL PIN1CTRL // CTS – PINxCTRL assignment

    with these lines:
    #define USB_CTS_bp (5) // CTS – bit position (pin is wired on board)
    #define USB_CTS_PINCTRL PIN5CTRL // CTS – PINxCTRL assignment
    (move the old pin1 to new pin5 for CTS signal)

    This line:
    #define USB_RTS_bp (0) // RTS – bit position (pin is wired on board)

    with line:
    #define USB_RTS_bp (4) // RTS – bit position (pin is wired on board)
    (move the old pin 0 to new pin 4 for RTS signal)

    These lines:
    #define USB_RX_bm (1<<2) // RX pin bit mask
    #define USB_TX_bm (1<<3) // TX pin bit mask

    with these lines:
    #define USB_RX_bm (1<<6) // RX pin bit mask
    #define USB_TX_bm (1<<7) // TX pin bit mask
    (move the old 2,3 RX-TX pins to new pins 6 and 7)

    In this section: //**** RS485 device configuration (no echo or CRLF) ****
    you must change the RS485-Serial pins and the Interrupts vector.

    replaced these lines:

    #define RS485_USART USARTC1 // RS485 usart
    #define RS485_RX_ISR_vect USARTC1_RXC_vect // (RX) reception complete IRQ
    #define RS485_TX_ISR_vect USARTC1_DRE_vect // (TX) data register empty IRQ
    #define RS485_TXC_ISR_vect USARTC1_TXC_vect // (TX) transmission complete IRQ

    #define RS485_PORT PORTC // port where USART is located
    #define RS485_RE_bm (1<<4) // RE (Receive Enable) pin – active lo
    #define RS485_DE_bm (1<<5) // DE (Data Enable)(TX) – active hi
    #define RS485_RX_bm (1<<6) // RX pin
    #define RS485_TX_bm (1<<7) // TX pin

    with these lines:

    #define RS485_USART USARTC0 // RS485 usart
    #define RS485_RX_ISR_vect USARTC0_RXC_vect // (RX) reception complete IRQ
    #define RS485_TX_ISR_vect USARTC0_DRE_vect // (TX) data register empty IRQ
    #define RS485_TXC_ISR_vect USARTC0_TXC_vect // (TX) transmission complete IRQ

    #define RS485_PORT PORTC // port where USART is located
    #define RS485_RE_bm (1<<0) // RE (Receive Enable) pin – active lo
    #define RS485_DE_bm (1<<1) // DE (Data Enable)(TX) – active hi
    #define RS485_RX_bm (1<<2) // RX pin
    #define RS485_TX_bm (1<<3) // TX pin
    ————————

    Basically we reversed the USB-serial with RS485-serial (not used)

    Good work…

    Guido

    #7257
    cmcgrath5035
    Moderator

    Congratulations!
    I misread this comment

    In this code, output portC 0,1,3,4,5,6,7 blinking well, but portC 2 not blink (the RX input). No output, either HIGH or LOW. This is broken!

    Missed the ” 2 “, thought you were reporting all of PortC broken.

    And thanks for the detailed summary to help out the next poor soul…..

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.