[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] ATMega128 TWI problems
From: |
Clemens Buchacher |
Subject: |
Re: [avr-gcc-list] ATMega128 TWI problems |
Date: |
Fri, 4 Jun 2004 17:33:16 +0200 |
User-agent: |
Mutt/1.5.6i |
Hi,
On Sun, May 30, 2004 at 10:35:28AM -0700, Nick Brent wrote:
> asm volatile ("cli"); //Turn off all interrupt sources
cli()/sei() are defined in <avr/interrupt.h>
> DDRD=0x00; //set portD to all input
> PORTD=0x02; //Turn on internal pullups on PORTD
No pull-up for SCL?
> /*------->START TWI Initialization<----------*/
> /* set the I2C bit rate generator to 100 kb/s (see pg. 202 & 206 in Mega128
> datasheet)*/
> TWSR = TWSR & 0xFC; //TWPS = 0
> TWBR = 18; //TWBR = 18
> //SCL Frequency = (CPU Clock Frequency)/(16+2(TWBR)*4^TWPS)
> //CPU Clock Frequency = 16Mhz for MyRobot Brainboard
Set TWPS to 1 (or TWBR to 72) to generate a 100 kHz SCL clock frequency.
In addition, I agree to everything Rune mentioned.
Regards,
Clemens
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [avr-gcc-list] ATMega128 TWI problems,
Clemens Buchacher <=