AT32UC USART Selection not working

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

I have been working on getting the USARTs working on an AT32UC3A processor, with a few problems.  I got it to work for USART 1, non-interrupt mode.  So I decided to try USARTs 0, 2,3 to make sure everything was working, but no matter what USART I select, the output is USART1 Pin A06.  I am sure it is something simple I am over looking, but would someone give it a peek and see if they see the obvious?  Thanks, David

In an include file:

    #define USART3_RX_PIN            AVR32_USART3_RXD_0_0_PIN                  //change &AVR32_USARTx to select USART
    #define USART3_TX_PIN            AVR32_USART3_TXD_0_0_PIN                   //change &AVR32_USARTx to select USART

    // FUNCTIONS
    #define USART3_RX_FUNCTION        AVR32_USART3_RXD_0_0_FUNCTION      //change &AVR32_USARTx to select USART
    #define USART3_TX_FUNCTION        AVR32_USART3_TXD_0_0_FUNCTION     //change &AVR32_USARTx to select USART

    // OPTIONS
    #define USART3                    (&AVR32_USART3)                                           //change &AVR32_USARTx to select USART
    #define USART_BAUD_RATE            57600
    #define USART_PARITY            USART_NO_PARITY
    #define USART_STOPBITS            USART_STOPBITS
    #define USART_MODE                USART_NORMAL_CHMODE
    #define USART_CHARLENGTH        8
    #define USART_CLOCK_MASK        AVR32_USART3_CLK_PBA                          //change &AVR32_USARTx to select USART
    #define USART_IRQ                AVR32_USART3_IRQ                                       //change &AVR32_USARTx to select USART

 

In main.c:

int main (void)
{
    /* Insert system clock initialization code here (sysclk_init()). */

    board_init();
    static const gpio_map_t USART_GPIO_MAP =
    {
        {USART3_RX_PIN, USART3_RX_FUNCTION},
        {USART3_TX_PIN, USART3_TX_FUNCTION}
    };

        static const usart_options_t USART3_OPTIONS =
    {
        .baudrate        = USART_BAUD_RATE,
        .charlength        = USART_CHARLENGTH,
        .paritytype        = USART_PARITY,
        .stopbits        = USART_STOPBITS,
        .channelmode   = USART_MODE
     };

//    gpio_enable_gpio_pin(7);
//    gpio_clr_gpio_pin(7);
    
//    genclk_enable_config(GCLK_ID, GCLK_SOURCE, GCLK_DIV);
//    gpio_enable_module_pin(GCLK_PIN, GCLK_FUNCION);
    
    
    // ASSIGN GPIO TO USART
    gpio_enable_module(USART_GPIO_MAP, sizeof(USART_GPIO_MAP) / sizeof(USART_GPIO_MAP[0]));
    
    // USART init in rs232 mode
    usart_init_rs232(USART3, &USART3_OPTIONS, CLOCK_PBA_FREQ);
    

    
    while (1)
    {
        usart_write_line(USART3, "Hello, world!\r\n");
//        gpio_local_set_gpio_pin(Test_A00);
        delay_ms(100);
//        gpio_local_clr_gpio_pin(Test_A00);
    }
}

Last Edited: Sun. Dec 18, 2016 - 07:53 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Does your code compile with #define USART_STOPBITS USART_STOPBITS ?



What is inside board_init() ?
What values does Studio show you for USART3_RX_PIN, USART3_TX_PIN, USART3_RX_FUNCTION and USART3_TX_FUNCTION?



I always become confused with Atmels' remapping of pins and functions and find it simpler to just use the pins and the gpio-multiplexing code directly,
eg, for USART3 using PB10 and PB11
#define USART3_RX_PIN AVR32_PIN_PB10
#define USART3_TX_PIN AVR32_PIN_PB11
#define USART3_RX_FUNCTION 1
#define USART3_TX_FUNCTION 1