Skip to content

Commit 525170b

Browse files
committed
Fix incorrect TWBR register in twi1.c
Closes #244
1 parent 9556589 commit 525170b

File tree

1 file changed

+2
-2
lines changed
  • avr/libraries/Wire1/src/utility

1 file changed

+2
-2
lines changed

avr/libraries/Wire1/src/utility/twi1.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ void twi_init1(void)
8383

8484
/* twi bit rate formula from atmega128 manual pg 204
8585
SCL Frequency = CPU Clock Frequency / (16 + (2 * TWBR))
86-
note: TWBR should be 10 or higher for master mode
86+
note: TWBR1 should be 10 or higher for master mode
8787
It is 72 for a 16mhz Wiring board with 100kHz TWI */
8888

8989
// enable twi module, acks, and twi interrupt
@@ -126,7 +126,7 @@ void twi_setAddress1(uint8_t address)
126126
*/
127127
void twi_setFrequency1(uint32_t frequency)
128128
{
129-
TWBR = ((F_CPU / frequency) - 16) / 2;
129+
TWBR1 = ((F_CPU / frequency) - 16) / 2;
130130

131131
/* twi bit rate formula from atmega128 manual pg 204
132132
SCL Frequency = CPU Clock Frequency / (16 + (2 * TWBR1))

0 commit comments

Comments
 (0)