Black STM32F407VET6 + STM32F407ZET6 dev boards

Discussion and questions about boards that can run MicroPython but don't have a dedicated forum.
Target audience: Everyone interested in running MicroPython on other hardware.
User avatar
dhylands
Posts: 2260
Joined: Mon Jan 06, 2014 6:08 pm
Location: Shuswap, BC, Canada
Contact:

Re: Black STM32F407VET6 + STM32F407ZET6 dev boards

Postby dhylands » Sat Mar 04, 2017 10:11 pm

Try pyb.RTC

kid06
Posts: 14
Joined: Fri Mar 03, 2017 4:21 pm

Re: Black STM32F407VET6 + STM32F407ZET6 dev boards

Postby kid06 » Sat Mar 04, 2017 10:28 pm

It works, set, but reset on power cycle. Backup battery is ok. Strange. Seems like hw failure or something. Machine.RTC should be more tight to hw, were pyb sounds like a wrapper (newbie hunch)

User avatar
dhylands
Posts: 2260
Joined: Mon Jan 06, 2014 6:08 pm
Location: Shuswap, BC, Canada
Contact:

Re: Black STM32F407VET6 + STM32F407ZET6 dev boards

Postby dhylands » Sat Mar 04, 2017 11:07 pm

pyb was the original classes. machine is the "new" definitions trying to create a homogeneous API across devices.

Neither one is a wrapper, and often the implementations between machine and pyb are actually identical.

Are you able to measure 3V on the vbat pin going into the microcontroller?

kid06
Posts: 14
Joined: Fri Mar 03, 2017 4:21 pm

Re: Black STM32F407VET6 + STM32F407ZET6 dev boards

Postby kid06 » Sat Mar 04, 2017 11:40 pm

I found pinout somewhere, the first one on line. Vbat -> pin 6. On that pin (maybe i'm wrong, they're tiny) 3.1v.

I'm not sure also about pin numbering because chip has two 'dots'. Anyway seems correct.

Thank you for your help.

kid06
Posts: 14
Joined: Fri Mar 03, 2017 4:21 pm

Re: Black STM32F407VET6 + STM32F407ZET6 dev boards

Postby kid06 » Sat Mar 04, 2017 11:54 pm

Ok, found dot on pcb. Dot on chip is the small one. Pin6 ->3.1v.

I'm thinking about a test with stm32arduino just to check rtc healt. Anyway now in Italy is midnight... so.... eventually tomorrow... :D

Thanks again!

kid06
Posts: 14
Joined: Fri Mar 03, 2017 4:21 pm

Re: Black STM32F407VET6 + STM32F407ZET6 dev boards

Postby kid06 » Sun Mar 05, 2017 6:38 am

Code: Select all

>>>
>>> rtc=pyb.RTC()
>>> rtc.datetime()
(2015, 1, 1, 4, 0, 0, 0, 255)
>>> rtc.datetime((2017,3,5,7,7,28,30,0))
>>> rtc.datetime()
(2017, 3, 5, 7, 7, 28, 33, 236)                                                 
>>>                                                                             
Traceback (most recent call last):                                             
  File "<stdin>", line 1                                                       
SyntaxError: invalid syntax                                                     
>>>                                                                             
>>> rtc=pyb.RTC()                                                               
>>> rtc.datetime()                                                             
(2015, 1, 1, 4, 0, 0, 0, 255)                                                   
>>> rtc.info()                                                                 
536925662                                                                       
>>> rtc.datetime((2017,3,5,7,7,28,30,0))                                       
>>> rtc.datetime()                                                             
(2017, 3, 5, 7, 7, 28, 39, 8)                                                   
>>> rtc.info()                                                                 
536925662                                                                       
>>>

Just a snip. On Traceback error (garbage on serial buffer) I soft reset (via pushbutton).

kid06
Posts: 14
Joined: Fri Mar 03, 2017 4:21 pm

Re: Black STM32F407VET6 + STM32F407ZET6 dev boards

Postby kid06 » Sun Mar 05, 2017 8:06 am

I made some more tests.

I've changed battery with a new one (no difference) and made some run without battery (same results).

Here also some rtc.info()

Code: Select all

>>> rtc.datetime()                                                             
(2015, 1, 1, 4, 0, 0, 0, 255)                                                   
>>> rtc=pyb.RTC()                                                               
Traceback (most recent call last):                                             
  File "<stdin>", line 1                                                       
SyntaxError: invalid syntax                                                     
>>> rtc=pyb.RTC()                                                               
>>> rtc.datetime((2017,3,+-----------------------------+                       
>>> rtc.datetime()       |                             |                       
(2017, 3, 5, 6, 8, 17, 9,|  Cannot open /dev/ttyACM0!  |                       
>>> rtc.info()           |                             |                       
536922152                +-----------------------------+                       
>>> rtc=pyb.RTC()                                                               
Traceback (most recent call last):                                             
  File "<stdin>", line 1                                                       
SyntaxError: invalid syntax                                                     
>>> rtc=pyb.RTC()                                                               
>>> rtc.info()                                                                 
1056964608                                                                     
>>> rtc.datetime()                                                             
(2015, 1, 1, 4, 0, 0, 0, 255)                                                   
>>> rtc.info()                                                                 
536931049                                                                       
>>>

kid06
Posts: 14
Joined: Fri Mar 03, 2017 4:21 pm

Re: Black STM32F407VET6 + STM32F407ZET6 dev boards

Postby kid06 » Mon Mar 06, 2017 9:23 am

So the answer (IMHO):"It's not a HW problem"

I compiled a test sketch in Arduino (STM32Arduino). It's not easy to work with F4 because of preliminary Arduino support. Anyway there is a RTC lib which lacks of maintainer=xxx def (yes, it blocks building :-) ). I've manually uploaded .bin with stm32flasher and USB to serial because IDE supports Stlink (which I haven't).

Finally I checked output on serial monitor and as you see there is a counter which survive to resets and power cycle.

Here source:

Code: Select all

#include <RTClock.h>

RTClock rt (RTCSEL_LSE); // initialise
uint32 tt;

void setup()
{
  Serial.begin(115200);
}

void loop()
{
 
  if (rt.getTime()!=tt)
  {
    tt = rt.getTime();
   
    Serial.print("time is: ");
    Serial.println(tt);
  }
}

Here console output with my comments:

Code: Select all

time is: 946685071
time is: 946685072
time is: 946685073
time is: 946685074
time is: 946685075
time is: 946685076
time is: 946685077
time is: 946685078
*****************************************
* HERE I PRESSED AND KEEP PRESSED RESET *
* FOR A WHILE                           *
*****************************************
time is: 946685083
time is: 946685084
time is: 946685085
time is: 946685086
*****************************************
* HERE I REMOVED POWER FOR A MORE LONG  *
* PERIOD                                *
*****************************************
time is: 946685414
time is: 946685415
time is: 946685416
time is: 946685417
time is: 946685418
time is: 946685419
time is: 946685420
time is: 946685421
time is: 946685422

RTC lib for arduino/F4 can be found on GitHub for reference:

https://github.com/rogerclarkmelbourne/ ... es/RTClock

Maybe problem is related to OSC source (ext) or something.

kid06
Posts: 14
Joined: Fri Mar 03, 2017 4:21 pm

Re: Black STM32F407VET6 + STM32F407ZET6 dev boards

Postby kid06 » Mon Mar 06, 2017 10:44 am

Finally, I got it!

Code: Select all

>>> rtc=pyb.RTC()
>>> rtc.datetime()                                                                   
(2000, 1, 1, 1, 1, 38, 47, 22)                                                       
>>> rtc.datetime((2017,3,6,1,11,25,0,0))
>>> rtc.datetime()
(2017, 3, 6, 1, 11, 25, 2, 0)
****************************
       SOFT RESET
****************************
>>> rtc=pyb.RTC()
>>> rtc.datetime()
(2017, 3, 6, 1, 11, 25, 53, 31)
****************************
       POWER CYCLE 
****************************
>>> rtc=pyb.RTC()
>>> rtc.datetime()
(2017, 3, 6, 1, 11, 27, 0, 145)
>>>

Black board has extrenal oscillator (opposed to default pyb, I suppose). So peeking in rtc.c you find:

Code: Select all

70 #if defined(MICROPY_HW_RTC_USE_LSE) && MICROPY_HW_RTC_USE_LSE
71 STATIC bool rtc_use_lse = true;
72 #else
73 STATIC bool rtc_use_lse = false;
74 #endif
75 STATIC uint32_t rtc_startup_tick;
76 STATIC bool rtc_need_init_finalise = false;

I added

Code: Select all

#define MICROPY_HW_RTC_USE_LSE (1)

in mpconfigboard.h under board type, for example after -#define MICROPY_HW_ENABLE_RTC (1)- and it fixed all.

Good monday... :D

User avatar
mcauser
Posts: 133
Joined: Mon Jun 15, 2015 8:03 am

Re: Black STM32F407VET6 + STM32F407ZET6 dev boards

Postby mcauser » Mon Mar 06, 2017 1:43 pm

@kid06 I noticed this too and can confirm adding MICROPY_HW_RTC_USE_LSE(1) to mpconfigboard.h enables the datetime to persist between power cycles.

When I first enabled it and uploaded new firmware, rtc.datetime() would only output 2000 and not increment:

Code: Select all

>>>rtc = pyb.RTC()
>>> rtc.datetime()
(2000, 1, 1, 1, 0, 0, 0, 0)
>>> rtc.datetime()
(2000, 1, 1, 1, 0, 0, 0, 0)


Fixed by running rtc.init():

Code: Select all

>>>rtc = pyb.RTC()
>>> rtc.datetime()
(2000, 1, 1, 1, 0, 0, 0, 0)
>>> rtc.init()
(2015, 1, 1, 4, 0, 0, 0, 38)
>>> rtc.datetime()
(2015, 1, 1, 4, 0, 0, 2, 214)


Return to “Other Boards”

Who is online

Users browsing this forum: No registered users and 1 guest