Is the ATMEGA328P's serial baud rate quantised?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












I'm using an ATMEGA328p, running from its internal oscillator (divided by 8 = 1MHz).



I've (roughly) measured the oscillator output, using my Salae logic analyser, as ranging from 960KHz to 1000KHz, so it's not awful. I did this using the "Clock output on PORTB0" fuse.



If I set the baud rate to 9,600, it outputs serial at 10,220 baud. (Is this because I'm not using a crystal, or because of quantisation?)



If I either increase F_CPU or decrease USART_BAUDRATE, gradually, the output serial baud does not decrease, until it jumps to 8,800 baud.



#define USART_BAUDRATE 9600
#define BAUD_PRESCALE (((F_CPU / (USART_BAUDRATE * 16UL))) - 1)

int main(void) {
// serial port setup
UCSR0B |= (1 << RXEN0) | (1 << TXEN0);
UCSR0C |= (1 << UCSZ00) | (1 << UCSZ01);
UBRR0H = (BAUD_PRESCALE >> 8);
UBRR0L = BAUD_PRESCALE;
...


Is there some form of quantisation affecting the output baud?



P.S. I'm using GCC on Linux to compile code, and I'm not using Arduino code/IDE.










share|improve this question



























    up vote
    1
    down vote

    favorite












    I'm using an ATMEGA328p, running from its internal oscillator (divided by 8 = 1MHz).



    I've (roughly) measured the oscillator output, using my Salae logic analyser, as ranging from 960KHz to 1000KHz, so it's not awful. I did this using the "Clock output on PORTB0" fuse.



    If I set the baud rate to 9,600, it outputs serial at 10,220 baud. (Is this because I'm not using a crystal, or because of quantisation?)



    If I either increase F_CPU or decrease USART_BAUDRATE, gradually, the output serial baud does not decrease, until it jumps to 8,800 baud.



    #define USART_BAUDRATE 9600
    #define BAUD_PRESCALE (((F_CPU / (USART_BAUDRATE * 16UL))) - 1)

    int main(void) {
    // serial port setup
    UCSR0B |= (1 << RXEN0) | (1 << TXEN0);
    UCSR0C |= (1 << UCSZ00) | (1 << UCSZ01);
    UBRR0H = (BAUD_PRESCALE >> 8);
    UBRR0L = BAUD_PRESCALE;
    ...


    Is there some form of quantisation affecting the output baud?



    P.S. I'm using GCC on Linux to compile code, and I'm not using Arduino code/IDE.










    share|improve this question

























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I'm using an ATMEGA328p, running from its internal oscillator (divided by 8 = 1MHz).



      I've (roughly) measured the oscillator output, using my Salae logic analyser, as ranging from 960KHz to 1000KHz, so it's not awful. I did this using the "Clock output on PORTB0" fuse.



      If I set the baud rate to 9,600, it outputs serial at 10,220 baud. (Is this because I'm not using a crystal, or because of quantisation?)



      If I either increase F_CPU or decrease USART_BAUDRATE, gradually, the output serial baud does not decrease, until it jumps to 8,800 baud.



      #define USART_BAUDRATE 9600
      #define BAUD_PRESCALE (((F_CPU / (USART_BAUDRATE * 16UL))) - 1)

      int main(void) {
      // serial port setup
      UCSR0B |= (1 << RXEN0) | (1 << TXEN0);
      UCSR0C |= (1 << UCSZ00) | (1 << UCSZ01);
      UBRR0H = (BAUD_PRESCALE >> 8);
      UBRR0L = BAUD_PRESCALE;
      ...


      Is there some form of quantisation affecting the output baud?



      P.S. I'm using GCC on Linux to compile code, and I'm not using Arduino code/IDE.










      share|improve this question















      I'm using an ATMEGA328p, running from its internal oscillator (divided by 8 = 1MHz).



      I've (roughly) measured the oscillator output, using my Salae logic analyser, as ranging from 960KHz to 1000KHz, so it's not awful. I did this using the "Clock output on PORTB0" fuse.



      If I set the baud rate to 9,600, it outputs serial at 10,220 baud. (Is this because I'm not using a crystal, or because of quantisation?)



      If I either increase F_CPU or decrease USART_BAUDRATE, gradually, the output serial baud does not decrease, until it jumps to 8,800 baud.



      #define USART_BAUDRATE 9600
      #define BAUD_PRESCALE (((F_CPU / (USART_BAUDRATE * 16UL))) - 1)

      int main(void) {
      // serial port setup
      UCSR0B |= (1 << RXEN0) | (1 << TXEN0);
      UCSR0C |= (1 << UCSZ00) | (1 << UCSZ01);
      UBRR0H = (BAUD_PRESCALE >> 8);
      UBRR0L = BAUD_PRESCALE;
      ...


      Is there some form of quantisation affecting the output baud?



      P.S. I'm using GCC on Linux to compile code, and I'm not using Arduino code/IDE.







      avr serial rs232 atmega328p






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 3 hours ago

























      asked 3 hours ago









      fadedbee

      493214




      493214




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          2
          down vote



          accepted










          It is a fully digital system. It must operate in discrete steps.



          This is the formula from the datasheet:
          enter image description here



          UBRR register is 16 bits wide (UBRRL + UBRRH), so it can only lead to 65536 possible baud settings.



          Look also at section "24.11. Examples of Baud Rate Setting" and table 24-4 of the datasheet.






          share|improve this answer



























            up vote
            2
            down vote













            If you own a precise logic analyzer you might want to calibrate the internal clock frequency via OSCCAL (Oscillator Calibration Register) in order to get further precision. Anyways, a crystal oscillator is almost always needed on a clean asynchronous communication.






            share|improve this answer




















              Your Answer




              StackExchange.ifUsing("editor", function ()
              return StackExchange.using("mathjaxEditing", function ()
              StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
              StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
              );
              );
              , "mathjax-editing");

              StackExchange.ifUsing("editor", function ()
              return StackExchange.using("schematics", function ()
              StackExchange.schematics.init();
              );
              , "cicuitlab");

              StackExchange.ready(function()
              var channelOptions =
              tags: "".split(" "),
              id: "135"
              ;
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function()
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled)
              StackExchange.using("snippets", function()
              createEditor();
              );

              else
              createEditor();

              );

              function createEditor()
              StackExchange.prepareEditor(
              heartbeatType: 'answer',
              convertImagesToLinks: false,
              noModals: false,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: null,
              bindNavPrevention: true,
              postfix: "",
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              );



              );













               

              draft saved


              draft discarded


















              StackExchange.ready(
              function ()
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2felectronics.stackexchange.com%2fquestions%2f402232%2fis-the-atmega328ps-serial-baud-rate-quantised%23new-answer', 'question_page');

              );

              Post as a guest






























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes








              up vote
              2
              down vote



              accepted










              It is a fully digital system. It must operate in discrete steps.



              This is the formula from the datasheet:
              enter image description here



              UBRR register is 16 bits wide (UBRRL + UBRRH), so it can only lead to 65536 possible baud settings.



              Look also at section "24.11. Examples of Baud Rate Setting" and table 24-4 of the datasheet.






              share|improve this answer
























                up vote
                2
                down vote



                accepted










                It is a fully digital system. It must operate in discrete steps.



                This is the formula from the datasheet:
                enter image description here



                UBRR register is 16 bits wide (UBRRL + UBRRH), so it can only lead to 65536 possible baud settings.



                Look also at section "24.11. Examples of Baud Rate Setting" and table 24-4 of the datasheet.






                share|improve this answer






















                  up vote
                  2
                  down vote



                  accepted







                  up vote
                  2
                  down vote



                  accepted






                  It is a fully digital system. It must operate in discrete steps.



                  This is the formula from the datasheet:
                  enter image description here



                  UBRR register is 16 bits wide (UBRRL + UBRRH), so it can only lead to 65536 possible baud settings.



                  Look also at section "24.11. Examples of Baud Rate Setting" and table 24-4 of the datasheet.






                  share|improve this answer












                  It is a fully digital system. It must operate in discrete steps.



                  This is the formula from the datasheet:
                  enter image description here



                  UBRR register is 16 bits wide (UBRRL + UBRRH), so it can only lead to 65536 possible baud settings.



                  Look also at section "24.11. Examples of Baud Rate Setting" and table 24-4 of the datasheet.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 2 hours ago









                  filo

                  5,7101930




                  5,7101930






















                      up vote
                      2
                      down vote













                      If you own a precise logic analyzer you might want to calibrate the internal clock frequency via OSCCAL (Oscillator Calibration Register) in order to get further precision. Anyways, a crystal oscillator is almost always needed on a clean asynchronous communication.






                      share|improve this answer
























                        up vote
                        2
                        down vote













                        If you own a precise logic analyzer you might want to calibrate the internal clock frequency via OSCCAL (Oscillator Calibration Register) in order to get further precision. Anyways, a crystal oscillator is almost always needed on a clean asynchronous communication.






                        share|improve this answer






















                          up vote
                          2
                          down vote










                          up vote
                          2
                          down vote









                          If you own a precise logic analyzer you might want to calibrate the internal clock frequency via OSCCAL (Oscillator Calibration Register) in order to get further precision. Anyways, a crystal oscillator is almost always needed on a clean asynchronous communication.






                          share|improve this answer












                          If you own a precise logic analyzer you might want to calibrate the internal clock frequency via OSCCAL (Oscillator Calibration Register) in order to get further precision. Anyways, a crystal oscillator is almost always needed on a clean asynchronous communication.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered 2 hours ago









                          DrPepe

                          283




                          283



























                               

                              draft saved


                              draft discarded















































                               


                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2felectronics.stackexchange.com%2fquestions%2f402232%2fis-the-atmega328ps-serial-baud-rate-quantised%23new-answer', 'question_page');

                              );

                              Post as a guest













































































                              Comments

                              Popular posts from this blog

                              Long meetings (6-7 hours a day): Being “babysat” by supervisor

                              What does second last employer means? [closed]

                              One-line joke