Search code examples
cusartatmelstudioatmega16

ATmega16 programing-registers mismatchs


I am programming ATmega16 and I chose that controller in device manager(atmel studio 6.2) but the registers don't match with the registers in the datasheet for ATmega16. I am using ICE 3 and I tried with the simulator but it is the same result. Register UCSRC is different, from some other controller and can't write in it, even though I set MSB to one.


Solution

  • according to datasheet of ATMEGA16, it is not required to set MSB of UCSRC as its initial value is 1. When you are working with UART you need to make sure that,

    1. You are setting proper UBRRL and UBRRH, according to controller clock using formula as below:

      FOSC/16/BAUD-1

    2. Enable RXEN and TXEN from UCSRB

    3. Set the proper bits in UCSRCaccording to your requirement of stop bit and parity bit

    Please refer following image : enter image description here