BasicMicro - Forums

www.basicmicro.com
It is currently Mon May 21, 2012 8:05 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: I2CIN problems on ARC32
PostPosted: Sat Oct 02, 2010 2:40 pm 
Offline
New User

Joined: Tue Sep 14, 2010 8:55 am
Posts: 2
I found this code online to read a CMPS03 compass but it doesn't work. Can anyone help?

SDA Con P8 ' Define Data pin
SCL Con P9 ' Define Clk pin
Compass Con 0xC0 ' Compass I2C Address
CmdReg Con 0 ' Sonar Command register
BearingReg Con 2 ' Sonar 1st Range register

Bearing Var Word ' 16 bit variable for Bearing

Main
i2cin SDA, SCL, Compass, BearingReg, [Bearing.HighByte, Bearing.LowByte]
Serout S_OUT, i9600, ["Compass Bearing ", DEC Bearing/10, " Degrees", 13] ' Use terminal window
goto main


Top
 Profile  
 
 Post subject: Re: I2CIN problems on ARC32
PostPosted: Sat Oct 02, 2010 3:21 pm 
Offline
Master

Joined: Tue Nov 21, 2006 9:34 am
Posts: 528
Hi and welcome Kevin,

I think the problem is that you are using the old syntax for I2C. You should download the latest draft version version of the updated manual from the thread: syntax-manual-f501/new-manual-t9180.html.

Also in future posts it be helpful if you included additional information, such as which version of the compiler you were using and was it that it did not compile or did it not give you the results you expected...

My guess is that the proper new syntax would probably look like:
Code:
SDA Con P8 ' Define Data pin
SCL Con P9 ' Define Clk pin
Compass Con 0xC0 ' Compass I2C Address
CmdReg Con 0 ' Sonar Command register
BearingReg Con 2 ' Sonar 1st Range register

Bearing Var Word ' 16 bit variable for Bearing

Main
   i2cout SDA, SCL, Compass, [BearingReg]
   i2cin SDA, SCL, Compass, [Bearing.HighByte, Bearing.LowByte]
   Serout S_OUT, i9600, ["Compass Bearing ", DEC Bearing/10, " Degrees", 13] ' Use terminal window
   goto main

Kurt


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


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 post attachments in this forum

Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

phpBB SEO