Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 10:34 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 : I did it again

     Page 1 of 2    
Author Message
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1702
Posted: 01:45pm 24 Aug 2022
Copy link to clipboard 
Print this post

After not using mmbasic for a while I've forgotten everything "again" and have to teach myself how to use it again
My brain is fuzzled
Could someone look over the circuit below and tell me if this is the right settings please?



I tried this with OPTION LCDPANEL SSD1331, RL, gp20,gp19,gp13 and the disply just flashed once so I then tried after resetting the options with my 2.5inch ILI9341 display and am getting nothing at all

 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2566
Posted: 05:05pm 24 Aug 2022
Copy link to clipboard 
Print this post

I don't think option system I2C is valid using spi.
I used the manual wiring diagram and
OPTION SYSTEM SPI GP18, GP19, GP16
OPTION SDCARD GP22
OPTION LCDPANEL ILI9341, L, GP15, GP14, GP13
OPTION TOUCH GP12, GP11
Page 47 in the manual
I think you want to run 2 displays hence I2C. There are 2 spi /I2C channels and the ili display only could work with spi1 and ssd13xx could use other channel as I2C but like you say how to set it up.
Edited 2022-08-25 03:13 by stanleyella
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2566
Posted: 06:04pm 24 Aug 2022
Copy link to clipboard 
Print this post

I will find the same problem when I try adding an I2C port expander. I will have to just use the display but think touch is shared so maybe just 1 channel and set the other for I2C.
Anyone wrote an I2C address finder?
 
twofingers

Guru

Joined: 02/06/2014
Location: Germany
Posts: 1593
Posted: 06:13pm 24 Aug 2022
Copy link to clipboard 
Print this post

  stanleyella said  Anyone wrote an I2C address finder?

'**********************************
'           I2C-Scanner
' scans I2C-Bus for I2C addresses
' MM-Basic 4.5 / Maximite/Duinomite
' by twofingers 21-08-2014 on TBS
'**********************************
Sub I2CScanner
Local found, i

found=0
Cls
Print "I2C-Scanner from Adr. 8-119":Print:Print

For i = &h08 To &h77 ' gueltige I2C-Adressen von 8-119
I2C open 100, 1000  ' i2c enable 100kHz, 1000ms timeout
I2C read i, 0, 1, temp

Print i;">"; MM.I2C " ";
If MM.I2C = 0 Then
  Print:Print:Print "Found I2C-Address at ";  i; " ("dec2hex$(i)+")"
  found=1
EndIf
I2C close            ' i2c disable

Next i
If found = 0 Then Print:Print:Print "NO I2C-Address found!"
End Sub

There should be also code for the Picomite here

Regards
Michae
causality ≠ correlation ≠ coincidence
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3378
Posted: 06:16pm 24 Aug 2022
Copy link to clipboard 
Print this post

  stanleyella said  Anyone wrote an I2C address finder?


From twofingers, 2014:
'**********************************
'           I2C-Scanner
' scans I2C-Bus for I2C addresses
' MM-Basic 4.5 / Maximite/Duinomite
' by twofingers 21-08-2014 on TBS
' modified for picomite with I2C on 1,2
'**********************************
'option system i2c 1,2 ' SDA,SCL (run from prompt)
I2CScanner
end

Sub I2CScanner
Local found, i

found=0
' Cls
Print "I2C-Scanner from Adr. 8-119":Print:Print

' I2C open 100, 1000  ' i2c enable 100kHz, 1000ms timeout (not for Picomite)
For i = &h08 To &h77 ' gueltige I2C-Adressen von 8-119
I2C read i, 0, 1, temp

Print i;">"; MM.I2C " ";
If MM.I2C = 0 Then
  Print:Print:Print "Found I2C-Address at ";  i; " ("dec2hex$(i)+")"
  found=1
EndIf

Next i
' I2C close            ' i2c disable (not for picomite)
If found = 0 Then Print:Print:Print "NO I2C-Address found!"
End Sub

Function dec2hex$(number) ' uused by I2C-Scanner
 dec2hex$ = "&H"+ Hex$(number)
End Function

'***********************************************************


This is if you have OPTION SYSTEM I2C set up. If you don't, you'll need to modify the code to uncomment the "I2C OPEN" and "I2C CLOSE" lines, and set up the proper I2C pins with SETPIN sda, scl, I2C (or I2C2).

~
Edited 2022-08-25 04:17 by lizby
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
twofingers

Guru

Joined: 02/06/2014
Location: Germany
Posts: 1593
Posted: 06:17pm 24 Aug 2022
Copy link to clipboard 
Print this post

And for the Picomite:
https://www.thebackshed.com/forum/ViewTopic.php?FID=16&TID=14959

@lizby
Thanks!
Edited 2022-08-25 04:18 by twofingers
causality ≠ correlation ≠ coincidence
 
pwillard
Guru

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

And I've used it with Picomite and it was super helpful to validate I had properly connected my break-out board.
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2566
Posted: 06:32pm 24 Aug 2022
Copy link to clipboard 
Print this post

Wow! Thanks for I2C address finders. I got some ssd1306 and they are 7bit address and 2 addresses. I got to use the I2C port expander soon as I am running out of GPIO pins.
Please help @lew247 and you will be helping others with I2c. It may be easy but I have not got around to I2C yet.
 
twofingers

Guru

Joined: 02/06/2014
Location: Germany
Posts: 1593
Posted: 06:51pm 24 Aug 2022
Copy link to clipboard 
Print this post

I would think the displays are SPI.
causality ≠ correlation ≠ coincidence
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2566
Posted: 06:54pm 24 Aug 2022
Copy link to clipboard 
Print this post

  twofingers said  I would think the displays are SPI.

true- circuit looks spi for both devices.
so not use sda,scl
Edited 2022-08-25 04:57 by stanleyella
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1702
Posted: 07:34am 25 Aug 2022
Copy link to clipboard 
Print this post

apologies, I should have said only one display would be connected at a time, not both
The i2c pins are not for the display, they are for something else.
as far as the display SPI  
OPTION SYSTEM SPI GP18, GP19, GP16
OPTION LCDPANEL ILI9341, LANDSCAPE, GP20, GP14, GP13
Is that correct for the circuit I have shown?
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 5089
Posted: 09:15am 25 Aug 2022
Copy link to clipboard 
Print this post

I think it should be
OPTION LCDPANEL ILI9341, LANDSCAPE, GP15, GP14, GP13

PicomiteVGA PETSCII ROBOTS
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1702
Posted: 11:40am 25 Aug 2022
Copy link to clipboard 
Print this post

Thanks
the display still isn't working

This is a better circuit

The only thing I have connected at the moment is the GPS unit and I've run the i2c detect program listed above
the results are:
run
I2C-Scanner from Adr. 8-119

8> 1  9> 1  10> 1  11> 1  12> 1  13> 1  14> 1  15> 1  16> 1  17> 1  18> 1  19> 1  20> 1  21> 1  22> 1  23> 1  24> 1  25> 1  26> 1  27> 1  28> 1  29> 1  30> 1  31> 1  32> 1  33> 1  34> 1  35> 1  36> 1  37> 1  38> 1  39> 1  40> 1  41> 1  42> 1  43> 1  44> 1  45> 1  46> 1  47> 1  48> 1  49> 1  50> 1  51> 1  52> 1  53> 1  54> 1  55> 1  56> 1  57> 1  58> 1  59> 1  60> 1  61> 1  62> 1  63> 1  64> 1  65> 1  66> 1  67> 1  68> 1  69> 1  70> 1  71> 1  72> 1  73> 1  74> 1  75> 1  76> 1  77> 1  78> 1  79> 1  80> 1  81> 1  82> 1  83> 1  84> 1  85> 1  86> 1  87> 1  88> 1  89> 1  90> 1  91> 1  92> 1  93> 1  94> 1  95> 1  96> 1  97> 1  98> 1  99> 1  100> 1  101> 1  102> 1  103> 1  104> 1  105> 1  106> 1  107> 1  108> 1  109> 1  110> 1  111> 1  112> 1  113> 1  114> 1  115> 1  116> 1  117> 1  118> 1  119> 1

NO I2C-Address found!

I've also run the i2c compass test from here and got
> run
Initialising...
Error : NACK

Is there a simple code I can use to open com1 and print everything it receives so I can test that the pico itself isn't broken even though I'm now on my 3rd Pico with this

I'm not certain my "logic converter" for the I2C pins actually works, it might have fried the tuner or the pico

 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2640
Posted: 12:08pm 25 Aug 2022
Copy link to clipboard 
Print this post

"The only thing I have connected at the moment is the GPS unit and I've run the i2c detect program listed above
.....
NO I2C-Address found!"

The GPS appears to be TTL serial so that would be correct, or am I having a "seniors moment"?
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1702
Posted: 12:12pm 25 Aug 2022
Copy link to clipboard 
Print this post

I should have said "the I2C section" of the GPS unit which is actually a
QMC5883L compass module

I can't get anything out of the serial bit of the GPS which is why I asked Is there a simple code I can use to open com1 and print everything it receives so I can test that the pico itself isn't broken
Edited 2022-08-25 22:12 by lew247
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2640
Posted: 12:42pm 25 Aug 2022
Copy link to clipboard 
Print this post

The datasheet for the QMC5883L shows 2 x 2k2 pullups on the I2C pins. I don't see them in your circuit. Could be worth a try.
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1702
Posted: 12:50pm 25 Aug 2022
Copy link to clipboard 
Print this post

The qmc5883L works without the pullups, I had it working on a different board
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4311
Posted: 01:05pm 25 Aug 2022
Copy link to clipboard 
Print this post

Hi Lewis,

Like you I have slept since we last did this dance, but if memory serves then this will dump all the GPS traffic to the console. Obviously you need to set the correct GP pins and baudrate for it to work.

SetPin GP0, GP1, COM1
Open "COM1:115200" As Gps, 0, 1
Do
Loop


Also if you do "blow" your GPS remember that you loaned me one of the same model which I will be happy to return.

Best wishes,

Tom
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4311
Posted: 01:14pm 25 Aug 2022
Copy link to clipboard 
Print this post

Addendum:

My notes suggest you may have configured the GPS as 460800 baud.

Best wishes,

Tom
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 5089
Posted: 05:11pm 25 Aug 2022
Copy link to clipboard 
Print this post

Hi Lewis,

Touch and LCD share the SPI bus. It is possible that the touch controller (OPTION TOUCH) when not configured correctly, blocks the SPI bus so the LCD wont work.

The LDR will not work. You need to put 1 side to ground, and measure the voltage at the connection between the LDR and the 10k resistor.

Volhout
Edited 2022-08-26 03:15 by Volhout
PicomiteVGA PETSCII ROBOTS
 
     Page 1 of 2    
Print this page
The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025