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)).
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.
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.