title: ATMEGA32 usart setup assembly
body: <p>Hi I've been trying to implement serial communication using Atmel studio 6.1
  and an ATMEGA32 mcu. 
  I read the datasheet and the post:
  <a href="https://stackoverflow.com/questions/15841050/atmega32-uart-communication">ATMEGA32 UART Communication</a></p>
  
  <p>I think I get more or less how it should be set but I'm not able to do it.
  I set the value of the URSEL to 1 in order to write to it but when I run the simulation it doesn't seem to write it and when I write a 0 to it and write to UBRRH then I can see that both the UCSRC and the UBRRH are written with the same value. </p>
  
  <p>here's a copy of the code... </p>
  
  <pre><code> jmp RESET
  
   RESET:
  
      ldi r16, $12
      out UCSRA, r16
      ldi r17, $00
      ldi r16, $47
  
      out UBRRL,  r16
      out UBRRH,  r17
      ; Enable receiver and transmitter
      ldi r16,    (1&lt;&lt;RXEN) | (1&lt;&lt;TXEN)
      out UCSRB, r16
  
      ; Set frame format: 8 data, 1 stop bit
      ldi r16, (1&lt;&lt;URSEL)|(1&lt;&lt;UCSZ0)|(1&lt;&lt;UCSZ1)
      out UCSRC, r16
      ldi r16, $80
      ldi r17, (0&lt;&lt;URSEL)
      out UBRRH,  r17
  loop:
      ldi r16, $41
      jmp TX
  
  TX:
      sbis UCSRA, UDRE
      rjmp TX
      ;move data to the buffer
      out UDR, r16
      jmp loop
  </code></pre>
  
  <p>Thanks for the help!</p>