Continue to Site

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.

Problem with ATmega2560 I2C (Software Module)

Status
Not open for further replies.

djnik1362

Full Member level 2
Joined
Aug 9, 2010
Messages
136
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,298
Location
IRAN
Activity points
2,374
hi
I have a board that include a Spartan II FPGA.
In this FPGA there is a Slave I2C receiver that i wrote it.
When i connect ATmega16 I2C output (note : software I2C not 2-Wire)
to board it work successfully. (Note : I set 2-Wire Pins for I2C (PORTC)).
But there is another board that have ATmega2560 that have same software as
ATmega16 but the FPGA can't receive data from it. (Note : I set 2-wire pins for I2C (PORTD)).

Can you suggest some idea to solve this problem ?

Thanks.
 

If you are using software delays ( like _delay_ms() ) then I can suggest you to check clock speed and, if needed, to adjust F_CPU.
Also check which clock source you are using, and check fuses to verify if you have div8 fuse activated or not.
 
If you are using software delays ( like _delay_ms() ) then I can suggest you to check clock speed and, if needed, to adjust F_CPU.
Also check which clock source you are using, and check fuses to verify if you have div8 fuse activated or not.

How adjust F_CPU and what is it ?
I check with div8 fuse set and clear and in both there is no ACK in receiver .
My FPGA code is sensitive to positive edge of SCL and seems work with all I2C frequency truly.
My wonder is same program in ATmega16 works but don't work on ATmega2560.
I must mention ATmega16 is on a simple evaluate board but ATmega2560 is on
a complex board with many peripherals such a FPGA, PROM, Buffers, D/a.

I'm going crazy !
 

If you use GCC to write your code, then you (or your Makefile) need to define F_CPU symbol. This is the clock speed in Hertz, so you could write something like -DF_CPU=8000000
In AVR Studio, there is a project option where you define the clock speed - this has the effect of defining that symbol.
Unfortunately I don't know how is in IAR, but I am quite sure there is something like that.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top