Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Problem with I2C (hangs with I2cwbyte)

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive
View previous topic :: View next topic  
Author Message
HolgerBri

Bascom Member



Joined: 06 May 2009
Posts: 10

germany.gif
PostPosted: Sun Mar 18, 2012 9:36 pm    Post subject: Problem with I2C (hangs with I2cwbyte) Reply with quote

Hi,

my program hangs up when trying to send data via I2C to HMC5843 Magnetometer. (whole code is attached)

Code:

...
' Konstanten für die Ansteuerung von HMC5843
Const Hmc_write = &H3C
Const Hmc_read = &H3D

' Variablen
Dim Grad As Integer
Dim Bgrad As Byte

' Hauptprogramm
Led = 1
Zeige7seg 10
I2cinit
Zeige7seg 20

' Setze IC in Continous Modus
I2cstart
Zeige7seg 30
I2cwbyte Hmc_write
Zeige7seg 40
...


The line Zeige7seg 30 is executed but not the line Zeige7seg 40 . After executing I2start Err is 0. I wonder what leads to this hang up without any error code. Do you have an idea? Btw: I also tried without I2cdelay

Best Regards
Holger
Back to top
View user's profile
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 1827

blank.gif
PostPosted: Mon Mar 19, 2012 12:20 am    Post subject: Reply with quote

I do not see anywhere in the code the required startup delay, as given by the data sheet:
Quote:
To change the measurement mode to continuous measurement mode, after the 8.3 milli-second power-up time send the three bytes

Also stack and frame settings are missing, then the setting from the IDE are used, which will not necessarily be sufficient.
Also be aware that soft-I2C needs external pullups, while hard-I2C may work with the µC's internal ones.
Back to top
View user's profile
HolgerBri

Bascom Member



Joined: 06 May 2009
Posts: 10

germany.gif
PostPosted: Mon Mar 19, 2012 6:51 pm    Post subject: Reply with quote

Thanks! the pullups were the solution. In the datasheet they mentioned that the pullups are integrated - but this seems not to be enough!

Best Regards
Holger
Back to top
View user's profile
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 1827

blank.gif
PostPosted: Mon Mar 19, 2012 8:06 pm    Post subject: Reply with quote

HolgerBri wrote:
the pullups were the solution.

Fine Very Happy
Quote:
In the datasheet they mentioned that the pullups are integrated - but this seems not to be enough!

Well it reads differently.
Quote:
Depending on the application, the internal pull-ups may be used to support slower data speeds than specified by I2C standards.

And:
Quote:
This device shall support standard and fast modes, 100kHz and 400kHz respectively, ... External pull-up resistors are required to support these standard and fast speed modes.
Back to top
View user's profile
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum