AT32UC3C USART on custom user board

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

Hello, Freaks !

 

I am starting to configure peripherals on my custom board. It implements an AT32UC3C0512C MCU.

From AT32UC3C-EK board, I manage to configure some pin interrupt, TC compare interrupt, and USART as well.

But when porting it to my custom board, I am stuck with the USART2.

All I need is the USART2 Tx sending bytes when I need it to do so.

I use ASF. I load the binary with ATMEL ICE. I develop on AS7.

 

// USART2 options
static const usart_options_t USART2_OPTIONS =
{
    .baudrate     = 19200,
    .charlength   = 8,
    .paritytype   = USART_NO_PARITY,
    .stopbits     = USART_1_STOPBIT,
    .channelmode  = USART_NORMAL_CHMODE
};
int main (void)
{
    sysclk_init();
    board_init();
    
    gpio_enable_module_pin(AVR32_USART2_TXD_1_PIN, AVR32_USART2_TXD_1_FUNCTION);
    sysclk_enable_peripheral_clock(&AVR32_USART2);
    usart_init_rs232_tx_only(&AVR32_USART2, &USART2_OPTIONS, sysclk_get_pba_hz());

    usart_write_line(&AVR32_USART2, "Hello, this is the AVR UC3 MCU sending you bytes !\r\n");
    
    /* Boucle principale */
    while (1);
}

Actually, all I know is the usart_init_rs232_tx_only is returning 0 and on an Arduino, I can read something but absolutely non sense.

This topic has a solution.
Last Edited: Tue. May 23, 2017 - 11:51 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

gnull wrote:
But when porting it to my custom board, I am stuck with the USART2

So did you ever get that working on the AT32UC3C-EK board?

 

Always good to start by prototyping on standard, known-good hardware!

 

Actually, all I know is the usart_init_rs232_tx_only is returning 0

Is that good? What does the documentation say?

 

and on an Arduino, I can read something but absolutely non sense.

What about on a terminal?

 

At least 98% of UART "garbage received" problems are due to the baud rate being wrong - so what have you done to confirm it?

 

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

Hi @awneil, thank you for considering my post.

 

I did get it working on the AT32UC3C-EK board. I was able to send a char from the arduino serial monitor to the AT32UC3C-EK board, and echo it back to the Arduino serial monitor from the AT32UC3C-EK board.

 

The 0 returned value of the "usart_init_rs232_tx_only" function if fine (in usart.h : #define USART_SUCCESS 0).

 

Actually, my arduino UNO is my terminal...As i don't have the tools to wire it to my computer.indecision

 

I tried to visualize my data on an oscilloscope, replaced usart_write_line("...") by usart_putchar('A'). Expecting (1/19200) 52µs to transmit a bit, but I got something like 70µs for 1 bit. I have to dig..

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

gnull wrote:
i don't have the tools to wire it to my computer.

Seriously?!

 

just get a USB-to-UART converter!

 

usart_putchar('A'). 

A 'U' will give an easier-to-view pattern on the scope ...

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

The 'U' tip is really useful, thank you.

 

So I investigate on my baud rate issue, that led me to........the wrong external oscillator frequency value. The code cas fine, my head wasn't.

 

Thank you @aweneil, you put me on the right track.

 

Have a good day !