I2C with ATMEGA2560

General discussion on mikroBasic PRO for AVR.
Post Reply
Author
Message
steve@asc
Posts: 6
Joined: 18 May 2011 18:29

I2C with ATMEGA2560

#1 Post by steve@asc » 06 Jun 2011 21:21

Hello Everyone,

I am trying to use the I2C bus on the Atmega2560 to use with the NHD-C0216CiZ-FSW-FBW-3V3 display form new haven display, and i am having no luck. I choose the atmega2560 since it has a I2C port on the chip but it is on PORT D so does this mean i can not use the TWI library? Also when using the soft_i2c library nothing is working, here is my code i am just trying to print a single character, with no luck at all.

Vdd=3.3 Volts, 2K pull up resistors on scl and sda lines

Please help.


program display_test

' Declarations section
dim Soft_I2C_Scl_Output as sbit at PORTD.0
dim Soft_I2C_Sda_Output as sbit at PORTD.1
dim Soft_I2C_Scl_Input as sbit at PORTD.0
dim Soft_I2C_Sda_Input as sbit at PORTD.1
dim Soft_I2C_Scl_Direction as sbit at DDRD.0
dim Soft_I2C_Sda_Direction as sbit at DDRD.1


main:
Soft_I2C_Init()
Soft_I2C_Write(0x7C)
Soft_I2C_Write(0x00)
Soft_I2C_Write(0x41)
Soft_I2C_Stop

end.

User avatar
slavisa.zlatanovic
mikroElektronika team
Posts: 1321
Joined: 07 Apr 2009 09:39

Re: I2C with ATMEGA2560

#2 Post by slavisa.zlatanovic » 07 Jun 2011 10:05

Hi!

I think that you're missing the Soft_I2C_Start() command to issue a start signal.
I choose the atmega2560 since it has a I2C port on the chip but it is on PORT D so does this mean i can not use the TWI library?
I don't see the reason why you shouldn't be able to use it.
Best regards
Slavisa

steve@asc
Posts: 6
Joined: 18 May 2011 18:29

Re: I2C with ATMEGA2560

#3 Post by steve@asc » 07 Jun 2011 14:43

Thanks for the reply, even with the start signal sent i still have nothing, I am using an o scope to monitor the output of the I2C bus and its solid at 3 volts, I do not see any clock pulse or anything. Also in the manual under TWI_Init it states that the library requires MSSP module on portB or PortC.

Post Reply

Return to “mikroBasic PRO for AVR General”