[SOLVED – FAULTY HARDWARE] RTC not work

pokemon99
Fri Aug 04, 2017 4:23 pm
Good afternoon. They sent a blue board without quartz 32.768. I tried to put a quartz from an old motherboard, but the RTC clock does not work. Tell me what could be the problem.

ahull
Fri Aug 04, 2017 4:24 pm
Do you have a picture of the board?
Are the crystal load capacitors fitted?

pokemon99
Fri Aug 04, 2017 4:34 pm
Yes there is. Bottom of the board. Blue pill board

ahull
Fri Aug 04, 2017 5:17 pm
[pokemon99 – Fri Aug 04, 2017 4:34 pm] –
Yes there is. Bottom of the board. Blue pill board

Do you have any way of measuring the load capacitors, since it is rather odd that the crystal is missing, so there is a chance that there are other issues with the board. Can you post a couple of pictures of your board, as modified with your crystal, both the front and back.


pokemon99
Fri Aug 04, 2017 5:30 pm
Now there is no way. But I read that there should be quartz with an internal capacitance of 6pf
and the quartz of the motherboard has a capacity of 12pf

ahull
Sat Aug 05, 2017 7:59 am
You might also like to read through this thread -> http://www.stm32duino.com/viewtopic.php?f=15&t=132

.. and this one -> http://www.stm32duino.com/viewtopic.php?t=594

.. one other thing to consider, these small crystals are pretty delicate easily damaged when soldering, so it may not have survived the “transplant operation”.

They are extremely cheap however, and you can easily pick up a replacement for a few cents for example -> https://www.ebay.co.uk/sch/sis.html?_nk … 2749.l2658

If you have access to an oscilloscope, you can check to see if the oscillator is oscillating, by scoping the pins of the RTC crystal.

If you don’t have an oscilloscope then you might enjoy these links.
http://www.stm32duino.com/viewtopic.php?t=107
https://github.com/pingumacpenguin/STM32-O-Scope/wiki

One other trick, try placing your finger on top of each of the load capacitors in turn and see if the oscillator starts. The small change in capacitance and a little bit of interference induced by your finger may be enough to start it.


pokemon99
Sun Aug 06, 2017 12:03 pm
Ok. For my project the exact time is not so important, I need a clock timer. I can use the internal crystal 40khz, I understand that time will be in a hurry. How will it be calibrated before 1 minute?

RogerClark
Sun Aug 06, 2017 12:16 pm
I would check the manual for the STM32F103C8T, to see if 40Khz is supported as a RTC crystal

I know on some MCU’s they are tuned to only work with a 32kHz crystal and you can’t use any other values, because the oscillator circuit inside the MCU will not run.


pokemon99
Sun Aug 06, 2017 4:27 pm
On another forum I read what works, but hours per day rush for 6 minutes. I did not exactly check, but I did a sketch with blink, it works. I’ll find out more precisely tomorrow.

RogerClark
Sun Aug 06, 2017 10:23 pm
Ok..

pokemon99
Mon Aug 07, 2017 7:25 am
RTCSEL_LSI works fine even it loads faster, but when the power from the chip is lost, that time stops, but for me it’s not so important I need a longer hour timer than clock
RTCSEL_HSE does not work, at least I did not succeed

RogerClark
Mon Aug 07, 2017 7:35 am
RTC cant possibly run when power is removed.

You need to power from a battery to maintain the RTC and also put the MCU into the appropriate low power mode


pokemon99
Mon Aug 07, 2017 8:04 am
I know it, I have a CR2032 battery,
The pruned power is saved but does not go, I understand that the chip does not supply power and time does not go, and the backup domain is also saved. That’s enough for me

pokemon99
Mon Aug 07, 2017 8:09 am
Bluepill come across with a bad watch crystal, 20 ordered and all came with an improperly soldered crystal, and I can not check the quality of the crystals

ag123
Wed Aug 09, 2017 7:16 pm
[ahull – Sat Aug 05, 2017 7:59 am] –

If you don’t have an oscilloscope then you might enjoy these links.
http://www.stm32duino.com/viewtopic.php?t=107
https://github.com/pingumacpenguin/STM32-O-Scope/wiki

One other trick, try placing your finger on top of each of the load capacitors in turn and see if the oscillator starts. The small change in capacitance and a little bit of interference induced by your finger may be enough to start it.

i’m half way wondering if it is after all quite feasible to patch that 32khz XTAL pin into the ADC pin on the same MM/BP to troubleshoot the 32khz crystal
:lol:


ahull
Wed Aug 09, 2017 10:42 pm
[ag123 – Wed Aug 09, 2017 7:16 pm] –

[ahull – Sat Aug 05, 2017 7:59 am] –

If you don’t have an oscilloscope then you might enjoy these links.
http://www.stm32duino.com/viewtopic.php?t=107
https://github.com/pingumacpenguin/STM32-O-Scope/wiki

One other trick, try placing your finger on top of each of the load capacitors in turn and see if the oscillator starts. The small change in capacitance and a little bit of interference induced by your finger may be enough to start it.

i’m half way wondering if it is after all quite feasible to patch that 32khz XTAL pin into the ADC pin on the same MM/BP to troubleshoot the 32khz crystal
:lol:

I think attempting that might be more trouble than it is worth, I can’t think of a simple way to test the crystal with the MM. .
Do you have a multimeter that does frequency measurement, or an oscilloscope?
You could also build a crystal tester with a couple of transistors or a 74LS04 or 74HC04 quad inverter.


RogerClark
Wed Aug 09, 2017 11:33 pm
Andy… My thoughts exactly .

Connecting the ADC to the pin will load it. And the oscillator already seems to be temperamental at the best of times


pokemon99
Tue Aug 22, 2017 10:50 am
Most likely the chip is defective.
I dropped the crystal from another board and soldered it from the motherboard instead and it works. I took a working crystal and soldered to a problem board that did not help, changed the capacitors and checked the chip feet. Nothing helped. I think that the defective chip is caught.

aimeiz
Tue Nov 14, 2017 6:34 pm
[RogerClark – Mon Aug 07, 2017 7:35 am] –
RTC cant possibly run when power is removed.

You need to power from a battery to maintain the RTC and also put the MCU into the appropriate low power mode

Any chance to get internal RTC running when backup battery is connected, but main CPu Power is off?
I am facing this problem.
Clock remembers date and time just before cpu lpost power, but clock is stopped.
It restarts ahen CPU is powered again.

Any advise?

Here is clock code:
// RTC and NVRam initialisation
#include <RTClock.h>
RTClock rt (RTCSEL_LSI); // initialise RTC
#define TZ "UTC+1"
time_t tt;
//time_t tt1;
char weekday1[][7] = {"Nie", "Pon", "Wto", "Sro", "Czw", "Pia", "Sob"}; // 0,1,2,3,4,5,6
//char weekday1[][7] = {"Niedzi", "Ponied", "Wtorek", "Sroda", "Czwart", "Piatek", "Sobota"}; // 0,1,2,3,4,5,6
#include <OLED_I2C.h>
OLED myOLED(6, 7, 8); //SDA = 6, SCL = 7, RESET = 8 Niepodłaczone
extern uint8_t SmallFont[];
//extern uint8_t MediumNumbers[];
extern uint8_t BigNumbers[];
//extern uint8_t Standard5x7[];
#define LED_PIN LED_BUILTIN

// This function is called in the attachSecondsInterrpt
void blink ()
{
digitalWrite(LED_PIN,!digitalRead(LED_PIN));
}

void setup()
{
myOLED.begin();
myOLED.setFont(SmallFont);
//myOLED.setFont(Standard5x7);

pinMode(LED_PIN, OUTPUT);
rt.attachSecondsInterrupt(blink);// Call blink
}

void loop()
{
if (rt.getTime()!=tt)

{
tt = rt.getTime();

Serial.print("Time is: ");
Serial.println(tt);
serialCurrentTime();
SetTime();
oledCurrentTime();
}
}
void serialCurrentTime() {
//rtclock.breakTime(tt, mtt);
char Buf[24];
snprintf(Buf, sizeof(Buf),"%s %04d/%02d/%02d %02d:%02d:%02d",
weekday1[rt.weekday()],(rt.year()+1970),rt.month(),rt.day(),
rt.hour(),rt.minute(),rt.second());
Serial.println(Buf);

}

void SetTime() {
Serial.println("Podaj datę i czas w formacie yyyy-mm-dd hh:mm dzien(1..7)<ENTER>");
while (Serial.available() > 0) {
int Year = Serial.parseInt();
int Month = Serial.parseInt();
int Day = Serial.parseInt();
int Hour = Serial.parseInt();
int Minute = Serial.parseInt();
int Wkday = Serial.parseInt();
if (Serial.read() == '\n') {
int Sec = 0;
int Yr = Year - 1970;
tm_t mtt = { Yr, Month, Day, Wkday, 11, Hour, Minute, Sec };
tt = rt.makeTime(mtt);
rt.setTime(tt);
}
}
}

void oledCurrentTime() {
char Buf[22];
//Wyświetl datę
myOLED.clrScr();
snprintf(Buf, sizeof(Buf),"%s %04d/%02d/%02d",
weekday1[rt.weekday()],(rt.year()+1970),rt.month(),rt.day());
myOLED.setFont(SmallFont);
// myOLED.setFont(Standard5x7);
myOLED.print(Buf,CENTER,0);
//Wyświetl czas
snprintf(Buf, sizeof(Buf),"%02d-%02d-%02d",
rt.hour(),rt.minute(),rt.second());
// myOLED.print(Buf,CENTER,9);
// myOLED.setFont(MediumNumbers);
myOLED.setFont(BigNumbers);
myOLED.print(Buf,CENTER,18);
myOLED.update();
}


Leave a Reply

Your email address will not be published. Required fields are marked *