Clones and RTC

Post here first, or if you can't find a relevant section!
Post Reply
arpruss
Posts: 83
Joined: Sat Dec 21, 2019 10:06 pm

Clones and RTC

Post by arpruss »

I have a bunch of recent Blue Pills, no doubt stm clones, which hang when I call rtc_init(RTCSEL_LSI). Has anyone got any idea on whether clones have a working internal RC oscillator clock, and if so, how one activates it? RTCSEL_LSE seems to work fine.
arpruss
Posts: 83
Joined: Sat Dec 21, 2019 10:06 pm

Re: Clones and RTC

Post by arpruss »

I switched to LSE and that works. However, it seems that clock data (both time and stuff stored in the storage registers) disappears after I pull the USB plug, even if I have 3.3V hooked up to the VBat pin. Any suggestions? I think what I have is a CS32F103C8T6.
arpruss
Posts: 83
Joined: Sat Dec 21, 2019 10:06 pm

Re: Clones and RTC

Post by arpruss »

It looks like I have two types of clones at home. One type hangs when you start LSE, but keeps RTC memory if you pull the power supply (with VBAT connected). The other type hangs when you start LSI, and works with LSE, but loses RTC memory if you pull the power supply (with VBAT connected). It does keep RTC memory if you hit the reset button, though.
ag123
Posts: 1653
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: Clones and RTC

Post by ag123 »

i've got a f401 pill, i think the chip is real. Similarly, LSE didn't work. But in my case i'm suspecting it could be a problem with the crystal or some bad soldering.

for clones, i'd guess it is harder to tell
dannyf
Posts: 446
Joined: Sat Jul 04, 2020 7:46 pm

Re: Clones and RTC

Post by dannyf »

which hang when I call rtc_init(RTCSEL_LSI).
maybe the code is at fault? what if you just fiddle with the registers to see if LSI works? maybe route it out to a pin if possible.
dannyf
Posts: 446
Joined: Sat Jul 04, 2020 7:46 pm

Re: Clones and RTC

Post by dannyf »

LSE didn't work.
on some ST chips they dialed back on the drive.

Putting your fingers on the pins usually get them started - they simply need so kick to get started.
arpruss
Posts: 83
Joined: Sat Dec 21, 2019 10:06 pm

Re: Clones and RTC

Post by arpruss »

On the blue pill where LSE didn't work, it started working for me yesterday. No idea what changed. Anyway, I rewrote a bunch of the LSE init code to have a timeout so that it doesn't hang on failure (for my use case, it's not a big deal if sometimes the clock doesn't work, but it is unfortunate if the pill hangs). That pill has a completely unlabeled microcontroller chip.

I am still not sure what is it the issue with the pills where rtc memory doesn't survive pulling the power plug (with 3V coin cell attached to VBat). Interestingly, rtc memory does survive hitting the reset button. I think these pills have stm labeling, but are probably fakes. It's not a big deal, more a matter of curiosity, because I just needed one pill for my project.

BTW, if anybody is curious what the project is, the issue is that our car mechanic told us to let our deteriorating vehicle warm up 30-60 seconds before driving, unless the car was already used less than 30 minutes before. So I have the pill beep and flash its light for 30 seconds when the car turns on (I just power it from a USB port in the car, and that port is off when the car is off), but I use the RTC to see if the car has been off for less than 30 minutes, in which case I skip the beeping and flashing.
dannyf
Posts: 446
Joined: Sat Jul 04, 2020 7:46 pm

Re: Clones and RTC

Post by dannyf »

a few suggestions:
1. you can use the accesory line from the car.
2. you can use a dedicated rtc which consumes little current. but the high temp in a car can be an issue.

I do remember hearing issues regarding the design around the battery domain. using a fake makes it more challenging.
arpruss
Posts: 83
Joined: Sat Dec 21, 2019 10:06 pm

Re: Clones and RTC

Post by arpruss »

I found an odd thing: for my clone, things worked a lot better if I did:

Code: Select all

  RCC_BASE->BDCR |= RCC_BDCR_RTCSEL_LSE;
  bb_peri_set_bit(&RCC_BASE->BDCR, RCC_BDCR_RTCEN_BIT, 1); // Enable the RTC  
before setting the prescaler, rather than after.
Post Reply

Return to “General discussion”