BasicMicroUK - Forums

www.basicmicro.co.uk
It is currently Sun Apr 22, 2018 5:05 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: I2Cin issue with ATOM28
PostPosted: Sun May 02, 2010 1:41 am 
Offline
Citizen

Joined: Fri Apr 02, 2010 6:22 pm
Posts: 6
Anyone out there? I really need some help on this issue.
here is my code:
'Get_Type'
i2cin P3,P2,162,176,[Port_Type]
I2CIN P3,P2,162,177,[Type_LSB]
Port_Type = Port_Type*256 + Type_LSB

This worked with the ATOM24 using BasicMicro IDE 05.3.1.0., but it seems with my new ATOM28 using the Studio version 1.0.0.24 the I2C command does not support a starting address (ie. 176 and 177 in the above example). When I try to, I get a compile error: token 176. I don't know why you wouldn't always want to read from a particular address offset??

Thanks,
JP


Top
 Profile  
 
 Post subject: Re: I2Cin issue with ATOM28
PostPosted: Sun May 02, 2010 2:13 am 
Offline
Master

Joined: Tue Nov 21, 2006 5:34 pm
Posts: 662
The I2cin/out commands have changed with the new studio. There have been a few threads on this.

The manual is in the state of being updated. You can find the latest draft up on this thread: viewtopic.php?f=501&t=9180&p=42025&sid=61332e8d83e9ba1f09262c00ec503096#p42025

Kurt


Top
 Profile  
 
 Post subject: Re: I2Cin issue with ATOM28
PostPosted: Sun May 02, 2010 2:41 pm 
Offline
Citizen

Joined: Fri Apr 02, 2010 6:22 pm
Posts: 6
OK, so I looked at the new manual and still don't see where you can read from a start address using the I2Cin cmd. Does this mean if I want byte 176 from device A2 that I need to read one byte at a time and loop for 176 times? This seems crazy. Why would Basic Micro remove functionallity from this command? Like I said before the old I2Cin cmd had the option of a start address. Am I missing something? Thanks for the help,
Jay


Top
 Profile  
 
 Post subject: Re: I2Cin issue with ATOM28
PostPosted: Sun May 02, 2010 3:08 pm 
Offline
Master

Joined: Tue Nov 21, 2006 5:34 pm
Posts: 662
You need to break up the command into two parts. You use the I2COut to output the address and the I2cIn to do the actual read. There is a little more information up on the Lynxmotion site in the thread: http://www.lynxmotion.net/viewtopic.php ... ilit=i2cin

I have not done any I2C for awhile so I am rusty. The newer syntax is closer to what is normally done with I2C commands... Looking at your code, the new stuff would be something like:
Code:
'Get_Type'
    i2cout p3, p2, 162, [176]
    i2cin P3,P2,162,[Port_Type.highbyte]
    I2CIN P3,P2,162,[Port_Type.lowbyte]

But to be sure I would need to test it. A couple other variations may be needed. You may need to have to output a second I2cOut with the 177 as an address...

Also if it were me I would also see if the I2cIn command actually allowed multiple bytes to be read and write it like:
Code:
'Get_Type'
    i2cout p3, p2, 162, [176]
    i2cin P3,P2,162,[Port_Type.highbyte, Port_Type.lowbyte]

Maybe soon I will drag out one of my SRF08 sensors and try it out...

Kurt


Top
 Profile  
 
 Post subject: Re: I2Cin issue with ATOM28
PostPosted: Sun May 02, 2010 7:37 pm 
Offline
Master

Joined: Mon Aug 18, 2008 1:26 am
Posts: 799
Location: CA bay Area
We have a sticky app note about using I2C EEPROMs with the Atom/ Nano:
http://forums.basicmicro.net/viewtopic.php?f=485&t=9235&sid=0431e4bc67d3585ef51893b0b2628e59
See if that helps any.

_________________
kenjj
http://blog.basicmicro.com/
http://kjennejohn.wordpress.com/


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 0 guests


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