F401 Nucleo Espruino Question #4292
Replies: 1 comment
-
Posted at 2014-11-24 by @allObjects To my knowledge, the board has a user button - does it? You can use it with a bit of code and a watch w/ second hand to (roughly) figure out what - it at all - clocking has an impact. Set a repeating watch on the button with a callback that stores the time in an array. Then you take some times like taking lap times: press the button, watch your watch for 10 seconds, press the button again, an do that several times. After that, list the array in the console window and do some math... Copy following code into the edit area in the IDE and upload it to the board.
For the explanation of the code look take a look at:http://www.espruino.com/Reference#l__global_setWatch I kept the function as terse as possible to have minimal impact on time. For looking at the times captured enter the following in your console:
If there are not too many times in the array, it will list them all. Otherwise, use enter the following to get them all, each on a single line:
For more luxury or convenient math, add this snipped to the code initial code which you upload to the board.
To show the results, enter If you pressed the button 11 times - every ten seconds, you will get 10 values you can average... and if you do not get a value close to 10 (seconds), then you know that the clock has an impact. If there is an impact, you may calculate a correction coefficient sufficiently accurate... and if you want it more accurate, you can take it minute by minute, or even hour by hour and do the math... with error calculation (this will give you a calibrated correction coefficient). To repeat the process, just upload the code again, or enter Btw, your numbers look odd to me, because they should have some relation to the clock frequency... but I'm sure @gfwilliams has a much better explanation than my empirical approach is based on. Posted at 2014-11-24 by Manxome @allObjects, thanks for the reply! Posted at 2014-11-24 by Manxome Edit: Multiple edits, I apologize if anyone read this post while I kept fixing it! OK, first simple test...here is the code I used:
I pressed/released the button, waited 60 seconds wall time, then pressed/released the button:
So 60 seconds wall time was approximately 11.4 seconds "computer" time, about a 5 1/4 times slowdown. BTW: I appreciate your code, and I get it; it helps me to see examples right now to absorb them. I'm just not sure I need more than the setWatch() you helped me set up to know that something is up. Posted at 2014-11-24 by @gfwilliams @manxome - thanks, I'll take a look at it (I'm a bit busy this week though!). The F401 binary is very new, and while it uses the same processor as the Pico it keeps the time a bit differently. It could well be that something has got set up wrong in the processor, and so the timings are all off. Posted at 2014-11-24 by Manxome Thanks @gfwilliams! Please note that I modified that last post several times, so what you read probably isn't what I ended up with, but if there is a timing issue, perhaps you know enough to find it already :) Posted at 2014-11-24 by asez73 Hi @manxome, That's an interesting problem. Have you updated your firmware from st.com? Are you using an NucleoF401RE or an NucleoF411RE? Here is my test of your code on an NucleoF401RE. Don't hesitate to copy your left pane of the web ide.
Posted at 2014-11-24 by @allObjects the 5-1/4 vs. the calculated 4-1/2 (72 / 16) value can make sense, because the timer internally fires events to update the time more often and base on the clock. The cycles used to handle the timer event is usually taken into account and is with the internal timer/interval value for sure not linear with the time itself. Posted at 2014-11-24 by @gfwilliams On the Espruino board (and the Pico) there's the RTC, but also another software timer based on SysTick that 'follows' the RTC and allows the board to make very accurate time measurements. On other boards (like the Nucleo) that doesn't happen. Instead SysTick is used directly, which means that you're totally dependent on the speed that the processor is running at. Posted at 2014-11-24 by Manxome Thanks very much for the replies all!
I have both, but have only been playing on the F401 so far
Yes, basically followed the instructions on the F401 page. I decided to start from scratch. I downloaded fresh copy of F401 firmware from ST and did the ST-Link Upgrade to V2.J23.M6 (again) just in case.
Those comments I typed in as I went. You will notice I get 'funny stuff' going on, perhaps this is a clue that I haven't a clue and/or I have bad hardware/firmware/something. But once again, you can see that both tests took about 5.25 longer than "computer" time would indicate. I don't know (yet) how to ask the Nucleo what clock speed it is running at. Posted at 2014-11-24 by Manxome Here is a discussion of F401 clock speeds out of the box. Posted at 2014-11-24 by DrAzzy My interpretation is that their thinking was "Oh, we'll leave out the crystal so the person developing with this can run it at whatever speed they want" - but this means you need a crystal to make it run at 84 x_x I think it's the black one, X2, that's used to set the clock speed of the MCU, but I'm not certain. Posted at 2014-11-25 by Manxome From more research I am pretty certain that F401 Nucleo ships at 16MHz. @drazzy, it sounds like the board can run at 84MHz without the crystals, but I am far from a hardware guy... Posted at 2014-11-25 by DrAzzy Yup, that explains it - It sounds like this is something that the Espruino firmware ought to be doing, but isn't. Posted at 2014-11-25 by asez73 Hello @manxome, @gfwilliams, The speed problem of the Nucleo is also described here and is well worth reading. If you have a F401 which is what the UM1724 manual calls a "MB1136 C-01" then it doesn't use HSE (High Speed External clock) and that the main point. From what I understand so far, it will need more than just software debugging/corrections to make it work in any or every case. Posted at 2014-11-25 by @gfwilliams @manxome so you're saying that over 60 seconds it's out by 5.25? I guess mine may do the same as I only tested that it was roughly correct. Interestingly my F401 board has just the black crystal (which is a 32k clock crystal - so not the high speed oscillator). @asez73 it looks like probably the best method right now is to just use the HSI, which will work on all boards - and which we know the speed of. I don't think there will be a huge problem - I think HSE is only really used because of USB. Posted at 2014-11-25 by Manxome And I thought software was complicated, sigh... My F401 Nucleo has a sticker on the back that says "MB1136 C-01" and has only the X1 (8MHz) crystal. What does "MCO" stand for? Not oddly, I am still somewhat confused. Are these the 2 possibilities?
I suppose adding X3 (and caps etc.) would allow you to break off the ST-Link if desired and still use an external (8MHz) crystal. If I added X2 and the caps and moved around the resistors, my F401 Nucleo would boot up at 84MHz using external X2 crystal, yes? No software initialization needed. Posted at 2014-11-25 by Manxome @gfwilliams yes, my 60-second test was off by a factor of 84/16, ie, 5.25.
The C-01 version of the motherboard has neither X2 or X3, the C-02 version has X2. You got yours directly from STM, so they sent you the latest version I guess. I got mine from Mouser just last week and it was C-01 so I guess they dumped old stock on me :( Posted at 2014-11-25 by DaveNI I am am expecting one from Mouser today. I was looking forward to getting it but not any more:( I'd other things to get (including a wiz550io) and just ordered it to get above £50 for free shipping so no big deal anyway. Lesson learnt - stick to the official boards which just work out of the box!! Posted at 2014-11-25 by asez73 @gfwilliams, @manxome, Posted at 2014-11-25 by Manxome @asez73, thanks for the info, very helpful :) @DaveNI, please let us know which version (C-01 or C-02) of the Nucleo board you get from Mouser, thanks! Posted at 2014-11-25 by @gfwilliams I actually got mine from Farnell. No freebies for me :) I understand about USB. I think given the right config you should be able to get pretty fast off of the internal RC oscillator. I'll have to see what can be done. Posted at 2014-11-25 by DaveNI I missed the FedEx delivery this afternoon but have just picked up my delivery from the depot - the first thing I did was look at the F401 version - like you it's the C-01. Hopefully we can make use of them! I am also from a software background and have little hardware experience. I have been using one of Gordon's boards for a few weeks and have really enjoyed it. It's a long wait until April for your picos - maybe you should get an official board - if you do just make sure it is a 1v4. I ended up with a 1v3 from digital means but it's fine - very robust & has endured my clumsy soldering! Posted at 2014-11-26 by Manxome @DaveNI, I really think the F4x1's are great boards, they will simply force us to learn more :) Posted at 2014-11-26 by Manxome What the heck??? Posted at 2014-11-26 by @gfwilliams I guess someone bought a few and decided to resell them? If they bought them from Seeed or somewhere then I guess they'd have to increase the price so they could make some profit... Posted at 2014-12-30 by DrAzzy I have done a bit of poking around here and come to a few conclusions. 1). On the MB1136 C-01, it has no LSE or HSE on the main chip, no jumper on SB16 (MCO) or SB50 (MCO). The 02 has LSE and the aforementioned jumpers are present. 2). On the C-01, which seems much more readily available, the clock runs at 16mhz by default. On the C-02, it runs at 84mhz. 3). On the C-01, registers show that clock is using the 16mhz HSI. Attempting to get it to use the PLL based on the HSI via poke has succeeded only in locking up the board when I try to kick it over to the PLL. 3). To install the crystal, 5 things need to be installed. The crystal itself, the 2 loading caps (maybe? We don't need them on the Espruino), and two jumpers to the right of C29. I have given up on trying to connect those jumpers for now. I do not think I will be successful unless I have a correctly sized 0-ohm resistor; those pads are very small and right next to eachother - not like the easy-jumpers on the bottom that you can close with a dab of solder. 4). Shorting the two MCO jumpers makes it run at 84mhz, and poke says it's running off the PLL. No crystal need be installed. 5). MCO stands for Microcontroller Clock Output. The two MCO jumpers are in series. Hence, in this case, the clock signal is coming from the other chip (the one used for STLink)! 6). Never ever make a white PCB, unless you want it to look like crap if anyone ever modifies or repairs it. In any event, I think the external crystals are unnecessary for general use, and a software change to Espruino is unnecessary. If you got a C-01 board, you can "fix" the clock speed by simply shorting the two MCO jumpers on the underside. No parts, any only minimal soldering skill required. You may not even need solder (I was able to short them by pushing around the solder already on the pads with the tip of the iron) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-11-24 by Manxome
Playing with the F401 w/ Espruino while waiting for my Pico's to arrive :)
I barely know enough yet to even type this question, but perhaps someone can help...
I am fooling around with beginner examples from Espruino.com, and I typed in the example
where OnSec() maintained a "time" object with seconds, hours, days, etc. This worked just fine, and I was embellishing it when I noticed that it seemed to be running really slowly. So I added a console.log(getTime()) that got executed every 10 seconds and I noticed it took approximately 50-60 seconds between logs.
So, what am I doing wrong? My first guess, and bear with my noobidity please, is that something in the .bin is still set at 16MHz instead of 84MHz, or perhaps 16MHz is the default for the F401 Nucleo and I should have done something to make it run at its faster setting.
Thanks in advance!
Edit: Just noticed that the Espruino runs at 74MHz, so there goes that noob guess.
Beta Was this translation helpful? Give feedback.
All reactions