Forum: Mikrocontroller und Digitale Elektronik AT32UC3C0512 USART initialisieren


von Hecgraca (Gast)


Lesenswert?

Hallo zusammen,

Ich muss Messwerte mit Hilfe des µC AT32Uc3C0512 ablesen.
Ich versuche seit heute morgen die Baudrate des AT32UC3C0512 zu 
initialiren und gelingt mir wegen mangelnder Kenntnisse nicht. Der 
Transfer Pin habe ich schon mit folgenden Befehl eingeschaltet:
#define Funtion_TXD_SW 
gpio_enable_module_pin(AVR32_MACB_TX_EN_1_PIN,AVR32_MACB_TX_EN_1_FUNCTIO 
N);  //Enable TXD[1] from Pin PD00;

Jetzt möchte ich die Messwerte ablesen. Dafür brauche eine Baudrate von 
57600 Kbps. Bei meinem 8 bit µC sieht es so aus:
UBRR0 = (F_CPU/(8*57600UL))-1;

Jetzt möchte ich das gleiche in meinen AT32 umsetzen. Ich habe ein paar 
Funktionen beim Support von Atmel und Beispielen von AVR Studio 
gefunden, aber weiss ich nicht, wie ich anfangen soll. Es wäre sehr 
nett, wenn ihr mir ein paar Tipps geben könnte.

Grüße

Hecgraca


Anhang:
Link von Support:
http://support.atmel.no/knowledgebase/avr32studiohelp/AT32UC3B_Software_Framework/DRIVERS/USART/USART_EXAMPLE/DOC/html/a00002.html#276ad428776a25b8247762bd2c82b35b


Beispiel AVR Studio
/*#if (BOARD == UC3L_EK) || (BOARD == UC3_L0_XPLAINED) || (BOARD == 
STK600_RCUC3L4)
  // Note: on the AT32UC3L-EK board, there is no crystal/external clock 
connected
  // to the OSC0 pinout XIN0/XOUT0. We shall then program the DFLL and 
switch the
  // main clock source to the DFLL.
  pcl_configure_clocks(&pcl_dfll_freq_param);
  // Note: since it is dynamically computing the appropriate field 
values of the
  // configuration registers from the parameters structure, this 
function is not
  // optimal in terms of code size. For a code size optimal solution, it 
is better
  // to create a new function from pcl_configure_clocks_dfll0() and 
modify it
  // to use preprocessor computation from pre-defined target 
frequencies.
#else
  // Configure Osc0 in crystal mode (i.e. use of an external crystal 
source, with
  // frequency FOSC0) with an appropriate startup time then switch the 
main clock
  // source to Osc0.
  pcl_switch_to_osc(PCL_OSC0, FOSC0, OSC0_STARTUP);
#endif*/

  static const gpio_map_t USART_GPIO_MAP =
  {
    {EXAMPLE_USART_RX_PIN, EXAMPLE_USART_RX_FUNCTION},
    {EXAMPLE_USART_TX_PIN, EXAMPLE_USART_TX_FUNCTION}
  };

  // USART options.
  static const usart_options_t USART_OPTIONS =
  {
    .baudrate     = 57600,
    .charlength   = 8,
    .paritytype   = USART_NO_PARITY,
    .stopbits     = USART_1_STOPBIT,
    .channelmode  = USART_NORMAL_CHMODE
  };

  // Assign GPIO to USART.
  gpio_enable_module(USART_GPIO_MAP,
      sizeof(USART_GPIO_MAP) / sizeof(USART_GPIO_MAP[0]));

  // Initialize USART in RS232 mode.
  usart_init_rs232(EXAMPLE_USART, &USART_OPTIONS, 
EXAMPLE_TARGET_PBACLK_FREQ_HZ);

  // Hello world!
  usart_write_line(EXAMPLE_USART, "Hello, this is the AVR UC3 MCU saying 
hello! (press enter)\r\n");

  // Press enter to continue.
  while (usart_get_echo_line(EXAMPLE_USART) == USART_FAILURE);  // Get 
and echo characters until end of line.

  usart_write_line(EXAMPLE_USART, "Goodbye.\r\n");

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.