Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 10:35 30 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Beta Testers Wanted

     Page 13 of 26    
Author Message
BobD

Guru

Joined: 07/12/2011
Location: Australia
Posts: 935
Posted: 08:11am 25 Jan 2014
Copy link to clipboard 
Print this post

Not sure how it is done in the Micromite but the Maximite had a variable you could test for I2C completion. It was MM.I2C and the valid values are:
[quote]Is set to indicate the result of an I2C operation.
0 = The command completed without error.
1 = Received a NACK response
2 = Command timed out
4 = Received a general call address (when in slave mode) [/quote]

 
atmega8

Guru

Joined: 19/11/2013
Location: Germany
Posts: 722
Posted: 08:54am 25 Jan 2014
Copy link to clipboard 
Print this post

Hallo Bobd,

you where right with this hint, 100000 thanks!!!
But i must say this is very, very confusing.
It is nowhere documented in the micromite documentation (maybe in mmbasic??)
and if you follow the "international Standards" for handling/addressing i2c devices, we think it is not a good idea to change them in such a strange way ( just our opinion).

This is really "down under", sorry ;-).

@Geoff
please put this in the documentation of the micromite to avoid hours of lost time for guys like us (2 experienced electro engineers).
Is there a reason for handling addressing in i2c in this way?


Thank you very much, in the meantime we drank some bottles of PILS beer....


Dietmar&Rüdiger
 
atmega8

Guru

Joined: 19/11/2013
Location: Germany
Posts: 722
Posted: 08:56am 25 Jan 2014
Copy link to clipboard 
Print this post

  BobD said   Not sure how it is done in the Micromite but the Maximite had a variable you could test for I2C completion. It was MM.I2C and the valid values are:
[quote]Is set to indicate the result of an I2C operation.
0 = The command completed without error.
1 = Received a NACK response
2 = Command timed out
4 = Received a general call address (when in slave mode) [/quote]



it seems to me that the Routine fail before it can set the variable.
I asked Geoff in my beginning thread

Dietmar
 
BobD

Guru

Joined: 07/12/2011
Location: Australia
Posts: 935
Posted: 11:50am 25 Jan 2014
Copy link to clipboard 
Print this post

  atmega8 said  
it seems to me that the Routine fail before it can set the variable.
I asked Geoff in my beginning thread

Dietmar


In this case, the command had invalid parameters and probably was never executed and so it would not have been able to set the MM.I2C variable.
 
jman

Guru

Joined: 12/06/2011
Location: New Zealand
Posts: 711
Posted: 12:14pm 25 Jan 2014
Copy link to clipboard 
Print this post

  atmega8 said  
if you follow the "international Standards" for handling/addressing i2c devices, we think it is not a good idea to change them in such a strange way ( just our opinion).

Dietmar&Rüdiger


I think if you take a look you will see this is the International Standard

"The I2C specification from NXP (formerly Philips) actually specifies two different slave addressing schemes. Standard Mode I2C makes use of 7-bit addressing. 10-bit addressing was later added as an extension to standard mode I2C.

7-bit Addressing

In 7-bit addressing procedure, the slave address is transferred in the first byte after the Start condition. The first seven bits of the byte comprise the slave address. The eighth bit is the read/write flag where 0 indicates a write and 1 indicates a read."


"8-bit Addresses

Some vendors incorrectly provide 8-bit addresses which include the read/write bit. Often times, you can determine if this is the case because they will provide one address for writing to the slave device and another to reading from the slave. In this situations. please only use the top seven bits of the address."


Regards
Jman

 
BobD

Guru

Joined: 07/12/2011
Location: Australia
Posts: 935
Posted: 12:25pm 25 Jan 2014
Copy link to clipboard 
Print this post

Attached is a document which shows almost exactly what jman said in the previous post.
2014-01-25_222416_I2C_Slave_Addressing.pdf

See this link to the standard document issued by NXP in 2012 http://www.nxp.com/documents/user_manual/UM10204.pdf
Edited by BobD 2014-01-26
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6104
Posted: 12:48pm 25 Jan 2014
Copy link to clipboard 
Print this post

To make life interesting, the data sheets for the I2C devices are rarely clear about which addressing scheme they are talking about.
I usually go by :
If the address is higher than 7F, they have included the 8th bit so divide by two.

Jim
VK7JH
MMedit   MMBasic Help
 
atmega8

Guru

Joined: 19/11/2013
Location: Germany
Posts: 722
Posted: 01:11pm 25 Jan 2014
Copy link to clipboard 
Print this post

Shame over me, you guys are absolutely right!
To be honest, we had some Beer before beginning programming;-).

Before mmbasic i programmed some routines for this RTC in Bascom and had some strange effects.
Tomorrow i will try this out with the addresses divided by 2 (shift right).

to all
for me

Dietmar
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9311
Posted: 01:15pm 25 Jan 2014
Copy link to clipboard 
Print this post

Yeah, I have to agree with all the above. Welcome to the wonderful world of I2C on microcontrollers!

Not sure how you were interfacing before, being that you are engineers, but perhaps you were using raw machine-code or something, to talk to your I2C stuff, which would require that YOUR code manage the read/write bit.

PICAXE does the same thing - you specify the I2C address using 8 bits, but the read/write bit can be either 1 or 0 - PICAXE will ignore it and change it as it needs to. This is a good thing - one less thing to complicate matters in your BASIC code.

I agree though, it would be a good idea if this was hammered home more in the MM manual, as unless you already know that MM is managing the read/write bit for you, you can get into a hell of a confusing state, as evidenced by you too chaps.

Hope the beer helped.
Smoke makes things work. When the smoke gets out, it stops!
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3200
Posted: 02:03pm 25 Jan 2014
Copy link to clipboard 
Print this post

Thanks fellows. While I was asleep a question was raised and very competently answered by others.

To my mind this illustrates why I2C is often regarded as complicated and difficult.

I don't know if your pdf is copyright BobD or in the public domain but I propose to add the following to the MMBasic manual (it borrows heavily from your document). Please tell me if it is in error (I am no I2C expert):

  Quote  7 and 8 Bit Addressing

The addresses used in these commands are 7-bit addresses (without the read/write bit). MMBasic will add the read/write bit and manipulate it accordingly for read/write transfers.

Some vendors provide 8-bit addresses which include the read/write bit. You can determine if this is the case because they will provide one address for writing to the slave device and another to reading from the slave. In these situations you should use only use the top seven bits of the address.

For example: If the read address is 9B (hex) and the write address is 9A (hex) then using only the top seven bits will give you an address of 4D (hex). The simple way of doing this is to take the 8 bit write address and divide it by 2.

Another indicator that a vendor is using 8-bit addresses instead of 7-bit addresses is to check the address range. All 7-bit addresses should be in the range of 08 to 77 (hex). If your slave address is outside this range then probably your vendor has specified an 8-bit address.

10 Bit Addressing

10-bit addressing was designed to be compatible with 7-bit addresses, allowing developers to mix the two types of devices on a single bus. MMBasic supports 10-bit addressing with the 'option' parameter.

In 10-bit addressing the slave address is sent in two bytes. The first byte begins with the special bit pattern of 11110 which indicates that 10 bit addressing is being used. The first two bits of the address are encoded in the last 2 bits of the first byte and the remaining bits are in the second byte. The 8th bit of the second byte remains the read/write flag.


Geoff
Edited by Geoffg 2014-01-27
Geoff Graham - http://geoffg.net
 
BobD

Guru

Joined: 07/12/2011
Location: Australia
Posts: 935
Posted: 02:19pm 25 Jan 2014
Copy link to clipboard 
Print this post

Geoff
I am no expert either. I practice lots of RTFM. The document that I provided is a composite of information generally available. I have had it for a while so I don't recall the sources except for the NXP standards document that I also referenced. I did check the document over and make minor changes for clarity before I posted it today.

If there was any copyright then it would be hard for me to tell you where it was and the info is so generalised that it would be hard to make a claim. FWIW you have my OK to use it in your MMBasic manual.

I think the last sentence should be omitted. I have to go out now so I cannot look into it today. I will check the standards doc unless someone else beats me to it (please).Edited by BobD 2014-01-27
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3200
Posted: 02:48pm 25 Jan 2014
Copy link to clipboard 
Print this post

Yes, the last sentence is wrong.

On reflection I believe that the last paragraph should read:

  Quote  In 10-bit addressing the slave address is sent in two bytes. The first byte begins with the special bit pattern of 11110 which indicates that 10 bit addressing is being used, the next two bits are the top two bits of the address and the final bit is the read/write address. The second byte contains the lower eight bits of the address. This detail is automatically managed by MMBasic when the 'option' argument is set for 10-bit addressing.

10-bit addresses can be in the range of 0 to 3FF (hex).


Anyone else care to comment?

Geoff
Geoff Graham - http://geoffg.net
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6104
Posted: 03:58pm 25 Jan 2014
Copy link to clipboard 
Print this post

Sounds good to me.

By the time we add a few more real life example programs, it should be easier to decipher the data sheets of new devices.

Jim
VK7JH
MMedit   MMBasic Help
 
jman

Guru

Joined: 12/06/2011
Location: New Zealand
Posts: 711
Posted: 04:38pm 25 Jan 2014
Copy link to clipboard 
Print this post

Yip looks ok to me
Geoff's 10 bit rewrite looks spot on

Jman
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9311
Posted: 05:08pm 25 Jan 2014
Copy link to clipboard 
Print this post

OK, finally got my MM talking to me - YAY!

I get the command prompt, but if I try to enter the editor, strange things happen.
This is still all at the 38k4 speed.

I seem to remember someone else here talking about the [ bracket thing being an issue too, so here are a couple of photos:



and I have to scroll down the terminal screen to get to the bottom, which looks like this:



I'm getting the welcome screen though, and if I type a command such as HELP, MM responds with an Unknown Command message, which I would expect.

I will keep playing....


Edited by Grogster 2014-01-27
Smoke makes things work. When the smoke gets out, it stops!
 
vasi

Guru

Joined: 23/03/2007
Location: Romania
Posts: 1697
Posted: 05:16pm 25 Jan 2014
Copy link to clipboard 
Print this post

That terminal use the Borland's Turbo Vision text user interface - the best ever.
Hobbit name: Togo Toadfoot of Frogmorton
Elvish name: Mablung Miriel
Beyound Arduino Lang
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9311
Posted: 05:24pm 25 Jan 2014
Copy link to clipboard 
Print this post

It's a terminal called TERMINAL PLUS by Scott Lightsey, written 2001.
Yes, perhaps the best terminal program I have ever used, and I have used lots, but this is my favourite. Can do daily log files too, which is really handy if you need to monitor something that only does odd things in the middle of the night, and only on certain days!
Smoke makes things work. When the smoke gets out, it stops!
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9311
Posted: 05:39pm 25 Jan 2014
Copy link to clipboard 
Print this post

I just set the baudrate of the console to 9600 to test if it was something to do with TPLUS and or the laptop(it's older) being unable to keep up at 38k8 baud.

Not really that likely, but I tried it, and get EXACTLY the same result on the screen.

Perhaps TPLUS is not 100% VT100 compatible?

I will now try TerraTerm - Only used TPLUS, as it was the first laptop I came across at the time.

EDIT: Cranked up the throttle to 57k6, then 115k2 - same issue, so not a case of the laptop not being fast enough. Get the startup message and the > prompt just fine even at 115k2. Probably is TPLUS not being VT100 compatible - I don't know if it is or not, you see...

...more tinkering...Edited by Grogster 2014-01-27
Smoke makes things work. When the smoke gets out, it stops!
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6104
Posted: 05:50pm 25 Jan 2014
Copy link to clipboard 
Print this post

What you are seeing are the VT100 escape codes which means that the terminal program is not capable or more likely, it needs configuring.

If the laptop is really old and you are using built in serial ports, there might be problems with a lack of FIFO buffers.

If you are running Windows 95 or newer, it is not really old.

Jim

VK7JH
MMedit   MMBasic Help
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9311
Posted: 06:01pm 25 Jan 2014
Copy link to clipboard 
Print this post

It WAS TPLUS, and yes you are right Jim.

TPLUS was running on an old Win98 laptop, in DOS mode.

I have downloaded TeraTerm and installed it on this Win8 machine, connected to COM1, set baudrate etc, and it away now happy as Larry.

I took the RPM's back to 38k400 for this test, now I will ramp up the RPM to 115k2...

Smoke makes things work. When the smoke gets out, it stops!
 
     Page 13 of 26    
Print this page
© JAQ Software 2024