Forum Index
HomeZBasic Home   Forum RulesForum Rules   Forum FAQForum FAQ   MemberlistMemberlist   UsergroupsUsergroups   RSS FeedRSS Feed
Site SearchSite Search   LinksLinks   DownloadDownload   Digests and SubscriptionsDigests and Subscriptions
ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in   RegisterRegister
I2C woes (native devices)

 
Post new topic   Reply to topic    Forum Index -> ZBasic Native Mode
Author Message
sturgessb



Joined: 25 Apr 2008
Posts: 246
Location: Norwich, UK

Posted: 14 July 2008, 17:51 PM    Post subject: I2C woes (native devices) Reply with quote

Something strange is going on guys....

I had some i2c sensors hooked up to my zx-24n and zx-128ne. All was working fine, then at some point with no wiring or software changes they stopped working, i2c commands were not being sent and no data was being received.

After checking over the wiring, and code again and again, I thought that something must have happened to the sensors or the zx devices.

Today I received a replacement i2c sensor, so I hooked it up to the zx-128ne, still no joy, tried the zx-24n, no joy, tried another out of the box 24n, still nothing. I then tried a standard zx-24 (vm version), and hey presto it works.

So I either have 3 faulty native devices (which i doubt, as they are working in all other ways) or something else is going on. The only thing I do seem to remember is upgrading the IDE to version 1.62.

Could there be some problem with 1.62, I2C, and native devices?

Here is my test code

Code:
'I2C
PUBLIC i2c_Result as INTEGER
PUBLIC i2c_OutData(1 to 3) as BYTE
PUBLIC i2c_InData(1 to 3) as BYTE
'I2C Channels and Sensors
PUBLIC Const i2c_Adr_Sonar as BYTE = &HE0
PUBLIC Const i2c_Chan as BYTE = 0
PUBLIC sonar_altitude(1 to 2) as INTEGER


Sub Main()
   Call Putpin(11, zxInputPullUp)
   Call Putpin(12, zxInputPullUp)
   Call OpenI2C(0, 0, 0)
   
   Do
      Call Get_sonar_altitude()
      Call Delay(0.50)
   Loop

End Sub


PUBLIC SUB Get_sonar_altitude()
   i2c_OutData(1) = &H00
   i2c_OutData(2) = &H51
   i2c_Result = I2CCmd(i2c_Chan, &He0, 2, i2c_OutData(1), 0, i2c_InData(1))   
   i2c_OutData(1) = &H03
   i2c_Result = I2CCmd(i2c_Chan, &He0, 1, i2c_OutData(1), 1, i2c_InData(1))
   sonar_altitude(1) = Cint(i2c_InData(1))
   DEBUG.PRINT sonar_altitude(1)
END SUB


Any ideas?

Ben
Back to top
dkinzer
Site Admin


Joined: 03 Sep 2005
Posts: 2499
Location: Portland, OR

Posted: 14 July 2008, 20:03 PM    Post subject: Re: I2C woes (native devices) Reply with quote

sturgessb wrote:
Could there be some problem with 1.62, I2C, and native devices?
Well, it took a while to reproduce the problem but we finally got it to happen here. The recent changes to support slave mode contained an error that could cause cmdSPI() to fail. We've devised a solution and, so far, it appears to have solved the problem.

An experimental version of the ZX Library v2.5.4 is available that should resolve the problem. The contents of the .zip file should be extracted to the zxlib subdirectory of the ZBasic installation directory.
Back to top
sturgessb



Joined: 25 Apr 2008
Posts: 246
Location: Norwich, UK

Posted: 14 July 2008, 20:46 PM    Post subject: Reply with quote

Hurrah I'm not mad, that's fixed it!

It's nice for me to make a post that actually useful for a change Smile

Ben
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Forum Index -> ZBasic Native Mode Time synchro. with the server - Timezone/DST with your computer
Page 1 of 1

 


All content Copyright © 2005-2012 Elba Corp. All Rights Reserved.
Opinions expressed in posts are those of the author and not necessarily those of Elba Corp.
Powered by phpBB © 2001, 2005 phpBB Group