I2C Address Problem with Micromite


Author Message
Frank N. Furter
Guru

Joined: 28/05/2012
Location: Germany
Posts: 946
Posted: 01:37pm 14 Jan 2022      

Hi to all!

I have a sensor with this address which I want to read out with a Micromite V5.05.05:
  Quote  7-bit slave address of this device is 1111000b (0x78).

But I get always this error:
[26] I2C READ &H78, 0, 4, temp()
Error : Invalid address

It seems that all addresses from &H77 generate this error...

What's going on here? Can anybody help me?

THANKS!

Frank

matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10180
Posted: 01:53pm 14 Jan 2022      

It is what is coded in the Micromite firmware, as to why?......

The PicoMite doesn't have the limitation
Edited 2022-01-14 23:53 by matherp

robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2428
Posted: 03:26pm 14 Jan 2022      

typing "i2c reserved addresses" (without quote marks) into google reveals:

"A seven bit wide address space theoretically allows 128 I2C addresses - however, some addresses are reserved for special purposes. Thus, only 112 addresses are available with the 7 bit address scheme. To get rid of this a special method for using 10 bit addresses is defined.

The following table shows I2C addresses reserved for special purposes:

0000000 0      General Call
0000000 1      Start Byte
0000001 X      CBUS Addresses
0000010 X      Reserved for Different Bus Formats
0000011 X      Reserved for future purposes
00001XX X      High-Speed Master Code
...
11110XX X      10-bit Slave Addressing
11111XX X      Reserved for future purposes"

from:
https://www.i2c-bus.org/addressing/


what exactly is the device you have that has address 0x78?


cheers,
rob   :-)
Edited 2022-01-15 01:37 by robert.rozee

Frank N. Furter
Guru

Joined: 28/05/2012
Location: Germany
Posts: 946
Posted: 07:11pm 14 Jan 2022      

@robert.rozee:

It's a pressure Sensor from Wuerth Elektronik:
Wuerth pressure sensor

THANKS! I had forgotten that there are "i2c reserved addresses"...

What was Wuerth Elektronik thinking???

Frank

Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1638
Posted: 08:03pm 14 Jan 2022      

  Quote  7-bit slave address of this device is 1111000b (0x78).


Shouldn't that address be &HF1 (write) Hex not Octal?

Bill

phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2579
Posted: 09:36pm 14 Jan 2022      

At which end is the extra "0" meant to go? MSB or LSB?
> ? hex$(&B01111000)
78
> ? hex$(&B11110000)
F0
>

Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1638
Posted: 09:41pm 14 Jan 2022      

From the data sheet the extra bit is the LSB '1' for read.

  Quote  A slave address is 7 bits long followed by a Read/Write bit.


Bill

TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6264
Posted: 09:42pm 14 Jan 2022      

  phil99 said  At which end is the extra "0" meant to go? MSB or LSB?
> ? hex$(&B01111000)
78
> ? hex$(&B11110000)
F0
>

From the MMBasic manuals:
  Quote  7-Bit Addressing
The standard 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 during 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 for reading from the slave. In
these situations you should 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).
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 greater than this range then
probably your vendor has provided an 8-bit address.

The MMBasic manuals don't describe the "reserved" range which this device seems to use.

Jim

JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 4032
Posted: 10:08pm 14 Jan 2022      

The PDF is clear: 7-bit address 78 (hex).

Rather odd.

John

Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1638
Posted: 10:19pm 14 Jan 2022      



This tells me 7 bit plus LSB. I still read it as &HF1.

Am I mis-reading it somehow?

Bill

Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 7815
Posted: 10:28pm 14 Jan 2022      

I wonder if they are using old silicon that predates the introduction of 10-bit addressing? They wouldn't want to change it later as anything designed to work with the old one would break - you couldn't use a new unit as a spare for an old one. They almost certainly wouldn't use that address now.

In a word, yes. You're misreading it.
111 1000 is the address, followed by an extra 0 for write or 1 for read IIRC. 7-bit addressing. Unfortunately 111 10xx is the reserved code to introduce a 10-bit address so that 10-bit units will work on a 7-bit system.
Edited 2022-01-15 08:44 by Mixtel90

Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1638
Posted: 10:43pm 14 Jan 2022      

OK, it's a seven bit ADDRESS followed by a '1' bit for 'read'. Does that mean that you DON'T send it '11110001' to issue a read command for that address?

Bill

Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 7815
Posted: 10:47pm 14 Jan 2022      

Yes, you do. You are then supposed to tag on the *actual* 10-bit address.

Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 7815
Posted: 10:55pm 14 Jan 2022      

This might help.

Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1638
Posted: 10:58pm 14 Jan 2022      

Thanks, reading Jim's quote from the manual shows I need to read up on the subject a bit more. Sorry if I added to any confusion.

Bill

TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6264
Posted: 11:09pm 14 Jan 2022      

There was discussion about this some years ago when another device appeared to use a "reserved" address.
If I remember correctly (a dangerous assumption), that device had a pin to change the address which did allow it to use valid address, just only one such device on the same data lines.

I think Arduino code allows the bad addresses.

Jim

Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1638
Posted: 11:25pm 14 Jan 2022      

Any chance that the CFunction I2CPort might work?

Bill

robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2428
Posted: 04:22am 15 Jan 2022      

the wuerth datasheet links to a philips datasheet, which reads:

"Assignment of addresses within a local system is up to the system architect who must take into account the devices being used on the bus and any future interaction with other conventional I2C-buses. For example, a device with seven user-assignable address pins allows all 128 addresses to be assigned. If it is known that the reserved address is never going to be used for its intended purpose, a reserved address can be used for a target address." (page 16, my highlighting)
from:
https://www.nxp.com/docs/en/user-guide/UM10204.pdf

so wuerth should have been aware that they were using a reserved address, as well as being aware that if they really wanted to they could make use of it at the cost of being 10-bit addressing incompatible.

it may be worth asking Geoff if it is possible to extend the range of allowed addresses on the MX170 et al versions of MMbasic. i do not fully know how this may affect the support of 10-bit addressing in the firmware, but i suspect that the presence of an 8/10-bit flag in the function calls precludes major problems.

i do note that the pico version of MMbasic seems to have had reference to 10-bit addressing removed from the user guide at least. Peter may care to comment about the availability of 10-bit addressing here. note that it does appears that 10-bit addressing never really took off within the industry, so its absence may be of little concern.


cheers,
rob   :-)
Edited 2022-01-15 14:26 by robert.rozee

Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3281
Posted: 05:57am 15 Jan 2022      

  robert.rozee said  It may be worth asking Geoff if it is possible to extend the range of allowed addresses on the MX170 et al versions of MMbasic.

OK, I will do that in the next release (it does not affect anything else).

Note that the CRoutines library in the Micromite distribution ZIP contains the CFunction I2CPort() which will create additional I2C ports and that does not have any limitations on the address range.

Geoff

Frank N. Furter
Guru

Joined: 28/05/2012
Location: Germany
Posts: 946
Posted: 01:48pm 16 Jan 2022      

Thank you so much to all!!!

I will try CFunction I2CPort...

Frank