Menu

Fixed error in the ATmega328pb HWI2C instructions

Ralf Pagel
3 days ago
2 days ago
  • Ralf Pagel

    Ralf Pagel - 3 days ago

    Hi,

    If you write a BASIC program for an ATmega328pb and use the HWI2C instructions, an assembly error occurs. This happens because the register names in the ATmega328pb's chip data differ from those of other microcontrollers (e.g., ATmega328p).

    The error can be fixed by inserting a script like this into the hwi2c.h file:

    #script
        if CHIPNAME = mega328pb then
            TWBR = TWBR0
            TWCR = TWCR0
            TWSR = TWSR0
            TWDR = TWDR0
        end if
    #endscript
    

    Cheers

     
  • Anobium

    Anobium - 3 days ago

    Great change. I will add the master HWI2C.h now.

    I have added this. It is a faster method.

      // Samevars for 328PB I2C
      #samevar TWBR, TWBR0
      #samevar TWCR, TWCR0
      #samevar TWSR, TWSR0
      #samevar TWDR, TWDR0
    

    Evan

     

Log in to post a comment.