Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 10:58 01 Aug 2025 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 : I2C should be easy...

Author Message
pwillard
Guru

Joined: 07/06/2022
Location: United States
Posts: 313
Posted: 06:18pm 29 Jun 2022
Copy link to clipboard 
Print this post

You know... for the uninitiated... I2C is somewhat painful.

I'm looking at the Sparkfun QWIIC MP3 Trigger. (thinking I can save some time and effort coding since it is a standalone Mp3 PLAYER from its own SDCARD)

Truth is... not so...

SO I'm reading their page... I can see the device shows up at &H37 with the I2C scanner... but the DOCS and examples say WRITES are &H6E and READS are &H6F so its using that "shifted I2C" stuff.  Ok, I can try to deal with that...


So... after I2C OPEN 100,200

I send  "I2C write &H6E,0,2,&H01,&H01" a supposedly valid command to start playing track 1  but... I only get...





And I don't know why?

When I right to &H37... I looks different... still doesn't work.



Edited 2022-06-30 04:23 by pwillard
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10310
Posted: 06:21pm 29 Jun 2022
Copy link to clipboard 
Print this post

I2C is silly in this respect the 7-bit address i.e. 37 is actually the left most 7 bits. The LSB is actually the read/write bit. In your example just use &H37 for both read and write and the H/W actually appends the correct LSB
 
pwillard
Guru

Joined: 07/06/2022
Location: United States
Posts: 313
Posted: 06:24pm 29 Jun 2022
Copy link to clipboard 
Print this post

Agree... its silly... and for me... hard to understand
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10310
Posted: 06:31pm 29 Jun 2022
Copy link to clipboard 
Print this post

Your second trace looks completely correct. The I2C command has transferred properly. There may be other initialisation you need to do (set volume?)
To confirm the command is working check MM.I2C after the write command
Edited 2022-06-30 04:32 by matherp
 
pwillard
Guru

Joined: 07/06/2022
Location: United States
Posts: 313
Posted: 06:40pm 29 Jun 2022
Copy link to clipboard 
Print this post

I'm looking at their trace on this page:

Sparkfun page

and it clearly shows they send a &H6E...  which had me scratching my head.

(Still didn't seem to work though)  More experiments are needed.
 
pwillard
Guru

Joined: 07/06/2022
Location: United States
Posts: 313
Posted: 06:50pm 29 Jun 2022
Copy link to clipboard 
Print this post

And then just like that... it actually started working.  Led astray by the examples.
And yes, apparently one of my tests set volume to 0
Edited 2022-06-30 04:56 by pwillard
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9610
Posted: 04:47am 30 Jun 2022
Copy link to clipboard 
Print this post

If it makes you feel any better, I2C confused the hell out of me when I was learning it also.  Addressing was part of it(the R/W bit issue you were having), but I was using EEPROM chips, and I kept overwriting the page boundary, which is a big no-no with those I2C memory chips, so I would corrupt data.  Once I taught myself how pages work with the help of the members here, or simply make sure that any record written to the memory ALWAYS started from byte-0 of page X, my problems went away, but I was quite lost with I2C at the beginning and thought I would never make it work.  I still do have the occasional hiccup with those devices, but once you get the hang of it, it tends to make sense and become more plain sailing.
Edited 2022-06-30 14:48 by Grogster
Smoke makes things work. When the smoke gets out, it stops!
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 5089
Posted: 07:08am 30 Jun 2022
Copy link to clipboard 
Print this post

Every connection has things that often go wrong....

I2C -> 7 -or- 8 bit addressing (or 10bit...)
RS232 -> RX/TX swaps
SPI -> clock edge, DI/DO swaps
"Chinese" I2C -> always something behaves not I2C. Some I2C LCD's, TM1637, etc...

Anyway, you solved it..
Success !
Edited 2022-06-30 17:09 by Volhout
PicomiteVGA PETSCII ROBOTS
 
pwillard
Guru

Joined: 07/06/2022
Location: United States
Posts: 313
Posted: 10:39am 30 Jun 2022
Copy link to clipboard 
Print this post

Well, this was actually the first time I encountered "shifted I2C" references... but their mention to use &H6E and &H6F was a complete red herring.  Following my gut and using the address that the I2C scanner returned was the answer.
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025