Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 22:01 28 Mar 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 : ELLO 1A with RTC

     Page 2 of 2    
Author Message
Frank N. Furter
Guru

Joined: 28/05/2012
Location: Germany
Posts: 812
Posted: 10:52am 01 May 2021
Copy link to clipboard 
Print this post

STRANGE! I tried it again! I removed the battery and again have the same problem with the detection of the RTC. The clock is now back to 00:00:00 and Jan 1 2000. I still can not adjust the time or date!

I will test the clocks later on my Z80-MBC2 if they behave differently there...

Frank
 
knivd

Regular Member

Joined: 07/09/2014
Location: United Kingdom
Posts: 71
Posted: 11:19am 01 May 2021
Copy link to clipboard 
Print this post

I just noticed that you are running R112a. Please try with the most recent R112c and see if that will help somehow
 
Frank N. Furter
Guru

Joined: 28/05/2012
Location: Germany
Posts: 812
Posted: 12:07pm 01 May 2021
Copy link to clipboard 
Print this post

I just flashed to the R112c version - no change!

(...it would be very advantageous if not all HEX versions were called the same or at least had a timestamp in the name...)

Frank
 
Frank N. Furter
Guru

Joined: 28/05/2012
Location: Germany
Posts: 812
Posted: 07:29pm 01 May 2021
Copy link to clipboard 
Print this post

Sorry Konit seems to be on ELLO!

At the first start with my new RTC, Z80-MBC2 said "RTC failure".
The time and date could be set without any problems and since then the two RTCs have been running without any problems.

Z80-MBC2 - A040618
IOS - I/O Subsystem - S220718-R260119

IOS: Found extended serial Rx buffer
IOS: Z80 clock set at 8MHz
IOS: Found RTC DS3231 Module (01/05/21 21:11:32)
IOS: RTC DS3231 temperature sensor: 22C
IOS: Found GPE Option
IOS: CP/M Autoexec is OFF
IOS: Current Disk Set 2 (CP/M 3.0)
IOS: Loading boot program (CPMLDR.COM)... Done
IOS: Z80 is running from now



Z80-MBC2 CPMLDR BIOS - S180918

CP/M V3.0 Loader
Copyright (C) 1982, Digital Research

BNKBIOS3 SPR  F600  0600
BNKBIOS3 SPR  5300  2D00
RESBDOS3 SPR  F000  0600
BNKBDOS3 SPR  2500  2E00

60K TPA

Z80-MBC2 128KB (Banked) CP/M V3.0
Z80-MBC2 BIOS Modules: S200918, S210918-R170319, S220918-R180319, S290918,
S170319

A>


ELLO is causing the same problems as before. First, the RTC is no longer recognised. Without keyboard and restart, then the RTC is recognised again! With ".?" the correct time and date are now displayed. However, neither the time nor the date can be adjusted...

(The same with the second RTC. This time I tried a restart WITHOUT disconnecting the keyboard. After the second start - this time WITH the keyboard - the RTC was also recognised! A third RTC - the one from Z80-MBC2 behaves the same way - I cannot set it with ELLO...)

Frank
 
knivd

Regular Member

Joined: 07/09/2014
Location: United Kingdom
Posts: 71
Posted: 07:53pm 01 May 2021
Copy link to clipboard 
Print this post

How exactly are you connecting the module? Is it directly on the expansion header or via a ribbon cable?
You could try to solder a 4.7k resistor on the module between SDA and VCC. The SCL line is driven strong by the ELLO (hence supporting only a single master mode), so a pullup there won't be needed.
I have three RTC modules and they all behave the same way just fine as they are. I have not modified them in any way.
 
Frank N. Furter
Guru

Joined: 28/05/2012
Location: Germany
Posts: 812
Posted: 08:10pm 01 May 2021
Copy link to clipboard 
Print this post

Here you can see my setup:



The only thing I notice is that you hear a soft noise from the piezo when you try to write the date or time. I will try it tomorrow with a pull-up...

Frank
 
knivd

Regular Member

Joined: 07/09/2014
Location: United Kingdom
Posts: 71
Posted: 08:51am 02 May 2021
Copy link to clipboard 
Print this post

The single soft "pop" noise from the speaker is normal. It shares the same SCL line.

PS. Try this updated version R112d on the website. I have added some additional initialisation on the I2C bus every time a transfer starts. Running it in all possible configurations and see no issues whatsoever with the RTC.
One thing I noticed - your date shows year 2000. If there is no RTC, the system time defaults to year 2021. The only way you see year 2000 according to my experiments, is when there a RTC with no battery. So, I would suggest check the battery in your module as well.
Edited 2021-05-02 20:31 by knivd
 
Frank N. Furter
Guru

Joined: 28/05/2012
Location: Germany
Posts: 812
Posted: 06:49pm 02 May 2021
Copy link to clipboard 
Print this post

Hi Kon,

I tried R112d, I tried a additional resistor (4K7) between SDA and VCC - the behavior has not changed!  

The voltage of the batteries is 3.045 and 3.295 volts (No difference between the two modules). I still can't set the date or time, but I can read them - but under Z80-MBC2 I have no problems with the clock modules...

Frank
 
zeitfest
Guru

Joined: 31/07/2019
Location: Australia
Posts: 368
Posted: 07:39pm 02 May 2021
Copy link to clipboard 
Print this post

I have had similar problems on other different systems, when the RTC battery is failing. It can have an OK resting/running voltage, but then not enough power to write changes (required to save the new settings). And then spontaneously stop running  when the voltage falls after some drain, typically caused by saving data. And once the RTC stops it has to have a re-initialise to start running as well. I would definitely put a new battery in.
 
knivd

Regular Member

Joined: 07/09/2014
Location: United Kingdom
Posts: 71
Posted: 09:57am 03 May 2021
Copy link to clipboard 
Print this post

I have made some further changes in the I2C channel as recommended in the DS3231 datasheet in case the RTC loses sync with the I2C bus. That might be happening when the system generates sound as it toggles the SCL line while the SDA is floating at the moment. The internal pullups are very weak. Now the bus is always driven with strong levels to a known state.
Updated the hex on the website.
 
Frank N. Furter
Guru

Joined: 28/05/2012
Location: Germany
Posts: 812
Posted: 02:00pm 03 May 2021
Copy link to clipboard 
Print this post

YOU NAILED IT!  

Now everything works as it should, I can set the time and date and read it back correctly. Also now the RTC was detected correctly every time!

Both ELLOS and both RTC's are now working!

Thanks Kon!

Frank
 
knivd

Regular Member

Joined: 07/09/2014
Location: United Kingdom
Posts: 71
Posted: 02:32pm 03 May 2021
Copy link to clipboard 
Print this post

That's good to hear.
As of today, I have also released the full sources of the C interpreter and everything else on Github
 
zeitfest
Guru

Joined: 31/07/2019
Location: Australia
Posts: 368
Posted: 02:20pm 06 May 2021
Copy link to clipboard 
Print this post

That is extraordinarily generous. I suspect it will be ripped off for profit by greedy net profiteers, without due credit.  

I hope Silicon Chip or Dyode  gives it a go. The members here (on average) are probably a bit too antique to try  
 
Frank N. Furter
Guru

Joined: 28/05/2012
Location: Germany
Posts: 812
Posted: 07:39pm 06 May 2021
Copy link to clipboard 
Print this post

Strange behavior of ELLO:

When I run "readrtc3.txt" first, I get the following error message:
.o readrtc3.txt
>>> Reading from file `readrtc3.txt` ...
>>> 120 lines, 2473 bytes read

.=


(ERROR 29) line 5: memory allocation failed
const char RTC_Addr  = 0x68; //RTC 7Bit-Basisadresse

121:

...but if I run "readrtc.txt" first before that and then "readrtc3.txt" the program will run without error?!? Why???

Here is my program "readrtc.txt"
#include <stdio.h>
#include <platform.h>

int BCD2BIN(int bcd) {
  return (((bcd >> 4) * 10) + (bcd & 0x0F));
}

i2cStart();
i2cSend(0xD0);  // DS3231 write
i2cSend(0x00);  // register
i2cRepStart();
i2cSend(0xD1);  // DS3231 read
char sc = i2cRecv(0);
char mn = i2cRecv(0);
char hr = i2cRecv(1);
i2cStop();
printf("It is %02d:%02d:%02d\r\n", BCD2BIN(hr), BCD2BIN(mn), BCD2BIN(sc));

...and here is "readrtc3.txt":
#include <stdio.h>
#include <platform.h>

//*** Adressenzuweisung ***
const char RTC_Addr  = 0x68; //RTC 7Bit-Basisadresse
const char RTC_Read  = ((RTC_Addr << 1) | 0x01);
const char RTC_Write = ((RTC_Addr << 1) & 0xFE);

//*** BCD Umrechnung ***
int BCD2BIN(int bcd) {
  return (((bcd >> 4) * 10) + (bcd & 0x0F));
}


//*** Temperaturumrechnung ***
float getTemp()
{
        float t
        unsigned int lowByte;
        signed   int highByte;
        lowByte  = t_lsb;
        highByte = t_msb;
        lowByte >>= 6;
        lowByte &= 0x03;
        t = ((float)lowByte);
        t *= 0.25;
        t += highByte;
        return t;
}


i2cStart();

i2cSend(RTC_Write);  // DS3231 write
i2cSend(0x00);  // register
i2cRepStart();
i2cSend(RTC_Read);  // DS3231 read
char sec    = i2cRecv(0); //warte auf mehrere Zeichen
char min    = i2cRecv(0); //warte auf mehrere Zeichen
char hour   = i2cRecv(0); //warte auf mehrere Zeichen
char day    = i2cRecv(0); //warte auf mehrere Zeichen
char date   = i2cRecv(0); //warte auf mehrere Zeichen
char month  = i2cRecv(0); //warte auf mehrere Zeichen
char year   = i2cRecv(1); //empfange letztes Zeichen

i2cSend(RTC_Write);  // DS3231 write
i2cSend(0x11);  // register (Temp)
i2cRepStart();
i2cSend(RTC_Read);  // DS3231 read
char t_msb  = i2cRecv(0); //warte auf mehrere Zeichen
char t_lsb  = i2cRecv(1); //empfange letztes Zeichen

i2cStop();

switch (BCD2BIN(day)){
 case 1  :
printf("Monday, ");
break;
 case 2  :
printf("Tuesday, ");
break;
 case 3  :
printf("Wednesday, ");
break;
 case 4  :
printf("Thursday, ");
break;
 case 5  :
printf("Friday, ");
break;
 case 6  :
printf("Saturday, ");
break;
 case 7  :
printf("Sunday, ");
break;
}
switch (BCD2BIN(month)){
 case 1  :
printf("January ");
break;
 case 2  :
printf("February ");
break;
 case 3  :
printf("March ");
break;
 case 4  :
printf("April ");
break;
 case 5  :
printf("May ");
break;
 case 6  :
printf("June ");
break;
 case 7  :
printf("July ");
break;
 case 8  :
printf("August ");
break;
 case 9  :
printf("September ");
break;
 case 10  :
printf("October ");
break;
 case 11  :
printf("November ");
break;
 case 12  :
printf("December ");
break;
}

printf("%d, 20%d", BCD2BIN(date), BCD2BIN(year));
printf(" It is %02d:%02d:%02d", BCD2BIN(hour), BCD2BIN(min), BCD2BIN(sec));
printf(" Temp = %.2f  C \r\n", getTemp());
printf("%d, 20%d", t_lsb, t_msb);


(...why does my temperature query/conversion not work and always shows 0.00 C???)

Many thanks for any help!!!

Frank

(P.S.: ...I can't really make friends with the line editor...)
 
knivd

Regular Member

Joined: 07/09/2014
Location: United Kingdom
Posts: 71
Posted: 08:35pm 06 May 2021
Copy link to clipboard 
Print this post

Just by a quick look at your source I can see that you are missing a i2cRepStart() statement right after you read the year. But that obviously doesn't solve the memory allocation error.
It is a really strange one and will need a bit more investigating, but when I swapped the places of the two #include statements in line 1 and 2, then the program worked fine.
Most likely there is a bug in the function that performs installation of a system library. I will track it down and fix for the next update.

Regarding your friendship with the editor... It is a more complex issue. One of those love or hate it things, just like console vs gui. At some point in future I may write a typical visual editor as well, but not keeping that high in my priority list for now.
Edited 2021-05-07 06:39 by knivd
 
Frank N. Furter
Guru

Joined: 28/05/2012
Location: Germany
Posts: 812
Posted: 06:46am 07 May 2021
Copy link to clipboard 
Print this post

Hi,

thank you for your investigation!
Can you tell me what I am doing wrong with the temperature conversion?
(...I will continue to try to get used to the editor....)

Frank
 
Rado
Regular Member

Joined: 27/11/2020
Location: Croatia
Posts: 59
Posted: 12:54pm 07 May 2021
Copy link to clipboard 
Print this post

I used to love TED back then in MS-DOS days. 3K in size, visual with common functions. TED+ with color support was a whopping 33% bigger - 4K. :-)

Could something like this fit?

https://texteditors.org/cgi-bin/wiki.pl?TedPlus
 
knivd

Regular Member

Joined: 07/09/2014
Location: United Kingdom
Posts: 71
Posted: 08:17am 09 May 2021
Copy link to clipboard 
Print this post

  Frank N. Furter said  Hi,

thank you for your investigation!
Can you tell me what I am doing wrong with the temperature conversion?
(...I will continue to try to get used to the editor....)

Frank


I have modified slightly your program to make it work. See the changes in the termperature function.
Regarding the memory issue, it turns out there is a bug in the memory management function which throws an allocation error eventhough there is enough memory not to. In this case, if I have the program in the memory - error. But if I run it directly from the disk with the .=<filename> command, no error.
I am fixing that for the next update.



#include <platform.h>
#include <stdio.h>

//*** Adressenzuweisung ***
const char RTC_Addr  = 0x68; //RTC 7Bit-Basisadresse
const char RTC_Read  = ((RTC_Addr << 1) | 0x01);
const char RTC_Write = ((RTC_Addr << 1) & 0xFE);

//*** BCD Umrechnung ***
int BCD2BIN(int bcd) {
 return (((bcd >> 4) * 10) + (bcd & 0x0F));
}


//*** Temperaturumrechnung ***
float getTemp(unsigned char msb, unsigned char lsb) {
   unsigned int ti = ((unsigned int) msb << 2) + ((unsigned int) lsb >> 6);
   return (float) ti * 0.25;
}


i2cStart();

i2cSend(RTC_Write);  // DS3231 write
i2cSend(0x00);  // register
i2cRepStart();
i2cSend(RTC_Read);  // DS3231 read
char sec    = i2cRecv(0); //warte auf mehrere Zeichen
char min    = i2cRecv(0); //warte auf mehrere Zeichen
char hour   = i2cRecv(0); //warte auf mehrere Zeichen
char day    = i2cRecv(0); //warte auf mehrere Zeichen
char date   = i2cRecv(0); //warte auf mehrere Zeichen
char month  = i2cRecv(0); //warte auf mehrere Zeichen
char year   = i2cRecv(1); //empfange letztes Zeichen

i2cRepStart();
i2cSend(RTC_Write);  // DS3231 write
i2cSend(0x11);  // register (Temp)
i2cRepStart();
i2cSend(RTC_Read);  // DS3231 read
char t_msb  = i2cRecv(0); //warte auf mehrere Zeichen
char t_lsb  = i2cRecv(1); //empfange letztes Zeichen

i2cStop();

switch (BCD2BIN(day)) {
case 1  : printf("Monday, "); break;
case 2  : printf("Tuesday, "); break;
case 3  : printf("Wednesday, "); break;
case 4  : printf("Thursday, "); break;
case 5  : printf("Friday, "); break;
case 6  : printf("Saturday, "); break;
case 7  : printf("Sunday, "); break;
}
switch (BCD2BIN(month)) {
case 1  : printf("January "); break;
case 2  : printf("February "); break;
case 3  : printf("March "); break;
case 4  : printf("April "); break;
case 5  : printf("May "); break;
case 6  : printf("June "); break;
case 7  : printf("July "); break;
case 8  : printf("August "); break;
case 9  : printf("September "); break;
case 10  : printf("October "); break;
case 11  : printf("November "); break;
case 12  : printf("December "); break;
}

printf("%d, 20%d", BCD2BIN(date), BCD2BIN(year));
printf(" It is %02d:%02d:%02d", BCD2BIN(hour), BCD2BIN(min), BCD2BIN(sec));
printf(" Temp = %.2f  C \r\n", getTemp(t_msb, t_lsb));
//printf("%d, 20%d", t_lsb, t_msb);

 
Frank N. Furter
Guru

Joined: 28/05/2012
Location: Germany
Posts: 812
Posted: 07:08am 10 May 2021
Copy link to clipboard 
Print this post

Hi,

thank you very much for your corrections - now I just have to understand them...

Frank
 
     Page 2 of 2    
Print this page


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

© JAQ Software 2024