Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Need help with programming in ICC AVR

Status
Not open for further replies.

kaze

Newbie level 5
Joined
Oct 13, 2005
Messages
9
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,383
Hi there, I was using ATMEGA8535 and want to use it I2C, programming using ICC AVR. But I have a problem that I couldn't resolve. Help me pls..

Here is a part of my I2c program to send data I've made 3 sample program at the first time the number1, the number 2 and number 3 was the modification.

void twi_init(void)
{
TWCR= 0X00; //disable twi
TWBR= 0x7C; //set bit rate
TWSR= 0x02; //set prescale
TWAR= 0x9E; //set slave address
TWCR= 0x44; //enable twi
}

number1:
void send(unsigned char data)
{
TWDR = data;
TWCR = (1<<TWINT) | (1<<TWEN);
}

number2:
void send_data(unsigned char DATA)
{
while (!(TWCR & (1<<TWINT)))
{
TWDR = DATA;
TWCR = (1<<TWINT) | (1<<TWEN);
}
}

number3:
void send_data1()
{
do
{
TWCR = 0xC4;
if(TWSR==0x1A)
{
TWDR = 0x9E; //instruction
TWCR = (1<<TWINT) | (1<<TWEN);
}
}while(!(TWCR & (1<<TWINT)));
}

Is all of my program is wrong or my slave IC was damage? I really dunno know how to test it. I really out of idea...

I wanna ask is when we set TWINT to 1 then the TWINT flag = 0, or the TWINT and TWINT flag is the same?

Thank for u're feedback.

my regrads.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top