Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 14:26 26 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 : pi picomite board 3

Author Message
dpcons
Newbie

Joined: 20/05/2022
Location: United States
Posts: 8
Posted: 01:23am 30 Jan 2024
Copy link to clipboard 
Print this post

I'm using a PiPicoMite03 board from Land Boards.  I'm using the MMBasicVGA latest version from Geoff's site.  Everything is working well except RTC.
I configured 'option system i2c gp14,gp15' which resets the board.  There was a note to use 'option system i2c2 gp14,gp15' in the PiPicoMite03 documentation but I get an error when I try that.  
The issue is the RTC doesn't respond.  I've tried two rtc boards and neither one responds.  Am I setting up something wrong?  The module is getting power, ground and the SDA and SCK lines show activity on the scope when I send 'rtc gettime'.  Both modules are DS1307 devices.  What is gp5 (DS) used for?  It's connected to the module but doesn't show any activity.  I'm probably missing something but not sure what.  What's the I2C address MMBasic is putting out there, if anyone knows.
Thanks.
Dan Powell
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3150
Posted: 01:43am 30 Jan 2024
Copy link to clipboard 
Print this post

Here is an older I2C-Detect.bas program which searches for I2C devices. Since you're setting up I2C with an OPTION, you need to comment out the SETPIN and I2C OPEN lines. You can change I2C to I2C2 to check that setup.

' i2cdetect like program

' Set Pins!
SetPin gp0, gp1, I2C

' Open first I2C
I2C open 100, 200


' Prep table
Print "     0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F"

' loop col/row
For y=0 To 7
Print Hex$(y,2);": ";
For x=0 To 15
 addr = y*16+x               ' calc address
 I2C write addr, 0, 1, &H00  ' write zero to that address
 If MM.I2C=0 Then            ' check for errors
   Print Hex$(addr,2);" ";   ' found one!
Else
  Print "-- ";               ' nothing here..
EndIf
Next x
Print
Next y

PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
dpcons
Newbie

Joined: 20/05/2022
Location: United States
Posts: 8
Posted: 06:03pm 31 Jan 2024
Copy link to clipboard 
Print this post

lizby, thanks for the test app.  It appears I have two DS1307 boards that aren't functioning.  I find a ds3231 board is working well, although it's form factor won't work as well as the tiny I2C 1307 boards.  I've ordered two more boards from Amazon and will try again.
Again, thanks for the useful app.  I tried it but it doesn't work
in I2c write line, error : Pin not set for I2C
Edited 2024-02-01 04:46 by dpcons
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3150
Posted: 06:49pm 31 Jan 2024
Copy link to clipboard 
Print this post

Here's a small DS3231 RTC module that I have used successfully.

~
Edited 2024-02-01 04:50 by lizby
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2135
Posted: 08:56pm 31 Jan 2024
Copy link to clipboard 
Print this post

  dpcons said   useful app.  I tried it but it doesn't work

If you have set OPTION SYSTEM I2C connect the module to the pins specified there (option List) and don't set I2C in the program.
Eg. change the start to this:-
' i2cdetect like program

' Set Pins!
' SetPin gp0, gp1, I2C

' Open first I2C
' I2C open 100, 200
 
dpcons
Newbie

Joined: 20/05/2022
Location: United States
Posts: 8
Posted: 11:08pm 01 Feb 2024
Copy link to clipboard 
Print this post

Phil99 and Lizby: I've done as you said.  I commented out the SetPin and I2C open calls.  Still doesn't work for me.  Error returned on the write.  I'm using the PicomiteVGA code, very latest. I also tried it on another Pico with Webmite software installed.  Tried it with the code you supplied. Setpin gp0, gp1, I2C returns illegal configuration.  I then used Option System I2C gp14, gp15.  System rebooted.  Tried same code except commented out the two first lines.  Same error on write as with the picomiteVGA code.

Everything on the board works now.  I've tried 4 different DS1307 tiny I2C RTC

modules and none of them work. I think there's an issue.  All the DS3231 modules work fine.  Beats me. Any, thanks for your responses.



Lizby.  Thanks I'll try one of the little DS3231 modules
 
mozzie
Regular Member

Joined: 15/06/2020
Location: Australia
Posts: 68
Posted: 05:42am 02 Feb 2024
Copy link to clipboard 
Print this post

G'day Dpcons,
The DS1307 can be a tricky little blighter, has caused me some grief in the past.

On checking the schematic, the PiPicomite03 board feeds the DS1307 from 3V3 (should be 5V)
If VCC is below 1.25 x Vbatt the DS1307 disables its I2C port, you might like to try a used battery (approx 2.5V) or remove it and see if the DS1307 responds.
The DS1307 will work with 3v3 I2C pullups and 5V VCC ok.

GP14/GP15 are I2C2 and I think need to be accessed as such from within MMbasic, try changing:
I2C write addr,0,1, &h00 TO I2C2 write addr,0,1, &h00
Someone will chime in if this is incorrect.

It looks like GP5 connects to the optional temp sensor that can be fitted to the RTC board.

Hope this helps.

Regards,
Lyle.
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2135
Posted: 07:25am 02 Feb 2024
Copy link to clipboard 
Print this post

Option System I2C works on both I2C and I2C2.
  Quote  If VCC is below 1.25 x Vbatt the DS1307 disables its I2C port,
Yet another issue with this chip to deal with! I did find that when I removed the 1.5MΩ resistor across the VBAT pin (to improve accuracy when the power is off) that it no longer ran at 3.3V.
There is more about this module on @dpcons other thread.
 
mozzie
Regular Member

Joined: 15/06/2020
Location: Australia
Posts: 68
Posted: 09:05am 02 Feb 2024
Copy link to clipboard 
Print this post

G'day all,
Whilst system I2C will work on I2C or I2C2 pins, I'm pretty sure the program above won't work because from MMBasic you still have to specify the correct port, if Dpcons is specifying GP14/GP15 as system I2C then he will need to specify I2C2 to access the port in a program. Been caught out by this in the past...
Now where is that DS1307...

@ Phil99
Cheers Phil, I'll post anything further on the new thread  

Regards,
Lyle.
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 6787
Posted: 10:40am 02 Feb 2024
Copy link to clipboard 
Print this post

It doesn't matter which I2C port you are using.

If you want it to be the system one then the command is:
OPTION SYSTEM I2C sdapin, sclpin
The "I2C" doesn't change to "I2C2".

In order to use the RTC commands in MMBasic the RTC has to be on System I2C. The DS1307, DS3231 and PCF8563 are supported.

Once System I2C has been specified you don't use I2C OPEN or I2C2 OPEN on that port as it's already open.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
mozzie
Regular Member

Joined: 15/06/2020
Location: Australia
Posts: 68
Posted: 01:50pm 02 Feb 2024
Copy link to clipboard 
Print this post

G'day Mick,
Agreed that to use the standard RTC commands you are correct, option system I2C can use I2C or I2C2 pins and no need to specify which.  

However, if you want to access the system I2C port from MMBasic, the correct port needs to be addressed. As you mention, no need to open the port as it's already open, but if you use I2C2 pins as system I2C, you'll need to access it as I2C2.

As the PiPicomite03 uses GP14/GP15 for the RTC I2C, the above program will only work if the line I2C write addr,0,1,&h00 is changed to I2C2 write addr,0,1,&h00

Just tried this on a DS1307 on V05.08.00 and it is still the same as previous versions.

Regards,
Lyle.
 
dpcons
Newbie

Joined: 20/05/2022
Location: United States
Posts: 8
Posted: 05:38pm 02 Feb 2024
Copy link to clipboard 
Print this post

Mozzie, you are correct on the I2C2 modification.  App now works.
Thanks much.

Another oddity, If I remove the batteries, all my DS1307 devices work fine on 3.3V.

What I don't understand is why 3 I2C addresses are responding. 50,58 and 68.  It's not the board, my Arduino I2C tester also reports the same addresses. What's the deal?
Edited 2024-02-03 06:40 by dpcons
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2135
Posted: 12:51am 03 Feb 2024
Copy link to clipboard 
Print this post

  Quote  Mozzie, you are correct on the I2C2 modification.  App now works.
Here is a version that works for both I2C and I2C2 pins.
As a bonus it names known devices.
Print "PicoMite System I2C or I2C2 Address Scanner "
Dim integer x, y, addr, device, found
' Prep table
Print "     0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F"
' loop col/row
For y=0 To 7
 Print Hex$(y,2);": ";
 For x=0 To 15
   addr = y*16+x               ' calc address
   On error skip 2
   I2C write addr, 0, 1, &H00  ' write zero to that adress
   I2C2 write addr, 0, 1, &H00  'write zero to that adress
   If MM.I2C=0 Then            ' check for errors
   Print Hex$(addr,2);" ";     ' found one!
   Dev.addr=addr
   Inc found
  Else
   Print "-- ";               ' nothing here..
  EndIf
 Next x
 'Add any new devices to this list
 Select Case Dev.addr
  Case &H68 :Print "RTC DS3232, DS1307 etc";
  Case &H50 To &H57 :Print "24Cxx EEPROM";
  Case &H3C :Print "LCD SSD1306";
  Case &H38,  &H39 :Print "AHT10 humid & temp";
  Case &H29 :Print "VL53LOX laser distance";
  Case &H20 :Print "MPC23017 port expander";
 End Select
 Dev.addr=0
 Print
Next y
Print
Print "Found "found" devices. If more than one on a line only the last is named."
End

  Quote  Another oddity, If I remove the batteries, all my DS1307 devices work fine on 3.3V
Yes, @mozzie explained that a few posts up.
  mozzie said  If VCC is below 1.25 x Vbatt the DS1307 disables its I2C port
There is a voltage divider between the cell and the Vbatt pin on the chip. R6 = 510kΩ (from cell to Vbatt) and R4 = 1.5MΩ (from Vbatt to ⏚). This is normally enough to allow the chip to work with a 3.3V supply. Check the value of R4 on your RTC.

From your other thread.
  phil said  Address &H68 is the DS1307 and &H50 is a 24C32 EEPROM on the RTC module.
I don't know what address &H58 is for.
Edited 2024-02-03 10:54 by phil99

Footnote added 2024-02-03 12:39 by phil99
Change this line in the program above:-
Dim integer x, y, addr, device, found
To this:-
Dim integer x, y, addr, dev.addr, found

Since the command BITBANG was replaced with DEVICE using "device" as a variable causes confusion. I changed all all other instances but overlooked that one.

Footnote added 2024-02-03 12:59 by phil99
Here is the circuit for the DS1307 module.DS1307 module circuit

Footnote added 2024-02-03 15:40 by phil99
Minor tweaks.
PicoMite Sys I2C1&2 Address Scanner.zip
 
mozzie
Regular Member

Joined: 15/06/2020
Location: Australia
Posts: 68
Posted: 01:58am 03 Feb 2024
Copy link to clipboard 
Print this post

G'day dpcons,
Hmmmm.... &h68 RTC, &h50 EEPROM, &h58 ????  

Can I suggest you try slowing the I2C to 100khz, the DS1307 is only rated to 100khz
and the 24C32 is only rated to 400khz @ 5V, the default is 400khz.

Try  OPTION SYSTEM I2C DISABLE
Then OPTION SYSTEM I2C GP14,GP15,SLOW

Hopefully this works.

@ Phil99
Nice program, saved to my "utilities" folder  

Regards,
Lyle.
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2135
Posted: 02:25am 09 Feb 2024
Copy link to clipboard 
Print this post

Yet another I2C scanner.
This one is aimed at those new to MMBasic so provides hints and prompts to setup I2C.
It detects most pin selection errors and allows re-entering them.

It won't detect every problem as it is already getting a bit bloated.
If System I2C has been set it will accept any pin numbers on the same channel but ignore them and use the System settings.
The other channel can be independenty set as usual.

'  "PicoMite I2C 1&2 and System Address Scanner v6.bas"
Print :Print "PicoMite SystemI2C or I2C or I2C2 Address Scanner ":Print
Dim integer channel, addr, found, vacant, SDA, SCL
Dim string I2Csda$, I2Cscl$, I2Cch$
Print "Check if SYSTEM I2C has been set. Note the GP numbers":Print
Option List

 Print :Print "Type SDA pin GP number (even numbers starting with 0)"
 Print :Print "Or type both SDA and, SCL pin GP numbers (SDA, SCL)":Print
 Do
  Input "Omit GP, just the number(s):- ", SDA, SCL

  If SDA Mod 2 = 0 Then
    If sda Mod 4 = 0 Then channel = 1
    If channel Then I2Cch$ = "I2C - the first I2C channel" Else I2Cch$ = "I2C2 - the second I2C channel"
    addr = 1
    Print :Print "You are using ";I2Cch$ :Print
   Else
    Print :Print "Not a valid SDA pin, try again"
  EndIf
 Loop Until addr = 1

 Do
  If scl=0 Then
    Print "Choose SCL pin from these GP numbers"
    If channel Then
      Print "1,  5,  9, 13,  17,  21"
     Else
      Print "3,  7,  11,  15,  19,  27"
    EndIf

    Print :Print "Type SCL pin"
    Input "Omit GP, just the number:- ", scl
  EndIf

  If (SCL-2*(1-channel)) Mod 4 = 1 Then
    addr = 0
   Else
    scl = 0
    Print :Print "Not a valid SCL pin, try again"
  EndIf

 Loop Until addr = 0

 Print :Print "SDA pin = GP";SDA; " and SCL pin = GP";SCL

 On error skip 2
 SDA=MM.Info(pinno "GP"+Str$(SDA))
 SCL=MM.Info(pinno "GP"+Str$(SCL))
 Print "SDA = Pico pin";SDA; " and SCL = Pico pin";SCL :Print

 Print "start ";Left$(I2Cch$,4);" scan":Print
 If channel Then
   On error skip 2
   SetPin SDA,SCL,I2C
   I2C open 100,500
  Else
   On error skip 2
   SetPin SDA,SCL,I2C2
   I2C2 open 100,500
  EndIf
  For addr = 0 To 127
   On error skip
   If channel Then I2C write addr, 0, 1, 0 Else I2C2 write addr, 0, 1, 0
   ' write zero to that adress

   If Not MM.I2C Then              ' check for errors
     Inc found
     Print :Print :Print "&h"Hex$(addr,2),       ' found one!
     'Add any new devices to this list
     Select Case addr
      Case &H20 :Print "MPC23017 port expander ";
      Case &H29 :Print "VL53LOX laser distance ";
      Case &H38, &H39 :Print "AHT10 humid & temp ";
      Case &H3C :Print "LCD SSD1306 ";
      Case &H50 To &H57 :Print "24Cxx EEPROM ";
      Case &H68 :Print "RTC DS3232, DS1307, M41T11 ";
      Case &HA2 :Print "RTC PCF8563 ";

      Case Else :Print "unknown device ";
     End Select

     Print "@ &h"Hex$(addr,2) " ("Str$(addr)" decimal)"
     vacant = 0
    Else
     Print ".";
     Inc vacant
     If vacant Mod 32 = 0 Then Print
  EndIf

 Next addr
 Print :Print :Print "Found"found" devices ('.' = vacant address)" : Print

End


Instead you can use minimalist method at the console command line.
Edit to suit then copy & paste the relevant lines to the command line.
> 'SDA pin = GP 4 and SCL pin = GP 5 on channel 1
> setpin gp4,gp5,I2C : I2C open 100,200
> for addr=0 to 127: I2C write addr,0,1,0:If not MM.I2C Then :?addr,"&h"hex$(addr):endif:next
81     &h51
87     &h57
> 'Using System I2C on channel 2
> for addr=0 to 127: I2C2 write addr,0,1,0:If not MM.I2C Then :?addr,"&h"hex$(addr):endif:next
41     &h29
56     &h38
83     &h53
104    &h68
>

Edited 2024-02-09 12:37 by phil99
 
Print this page


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

© JAQ Software 2024