-
Notifications
You must be signed in to change notification settings - Fork 2.1k
boards: support for Olimex MSP430-H1611 board #19558
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
.main_clock_source = MAIN_CLOCK_SOURCE_DCOCLK, | ||
.submain_clock_source = SUBMAIN_CLOCK_SOURCE_DCOCLK, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: The MSP430_HAS_EXTERNAL_CRYSTAL
would indicate that the XT2 clock should be used instead of the DCO. However, the msp430_init_dco()
in the TelosB's board.c
configures and calibrates the DCO as clock source regardless of that macro. It seems to be a copy-paste error.
Also note: It should now be possible to run the DCO at 4 MHz instead of ~2.5 MHz, as the DCO calibration is a bit more robust.
287d27e
to
8f53b23
Compare
Note: I also tested the clock initialization on the Olimex MSP430-H1611 with an 8 MHz crystal inserted into the Q2 socket and the |
boards/msb-430/include/periph_conf.h
Outdated
* @name Clock configuration | ||
* @{ | ||
*/ | ||
/** @todo Move all clock configuration code here from the board.h */ | ||
#define CLOCK_CORECLOCK (7372800U) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How did this ever work? The clock was initialized to run at ~2.5 MHz from DCO due to
#define MSP430_INITIAL_CPU_SPEED 2457600uL
#define F_CPU MSP430_INITIAL_CPU_SPEED
#define F_RC_OSCILLATOR 32768
#define MSP430_HAS_DCOR 1
#define MSP430_HAS_EXTERNAL_CRYSTAL 0
But CLOCK_CORECLOCK
was ~7.4 MHz ans so was CLOCK_CMCLK
, which was used to configure the UART symbol rate to 9600 Baud. The actual symbol rate like was then 3200 Baud due to this mismatch :-/
Update: I double checked: The datasheet says that the DCO tops out at 5.4 MHz maximum, even if the the silicon lottery gave one an extra fast DCO (the production variance is said to be significant) and the supply voltage is extra high. In fact, 4.9 MHz is the typical max frequency at 3 V. The sanity test prevents more than 4 MHz to account for poor luck in the silicon lottery + a low supply voltage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The good thing is that the compile time configuration sanity tests do indeed work and caught the issue.
8f53b23
to
bb54f7a
Compare
I would like to change the DCO calibration algorithm. It is now basically the same approach as before with linear search, just some corner case handling added. This already reduced boot up time from about 4 secs with a 4 MHz DCO to about half a second (perceived duration, I didn't measure) but stopping the calibration once the settings are oscillating between "just a bit too slow" and "just a bit too fast". Still, boot up time is much faster when an external crystal is used. To some part this may be due to the CPU then running at 8 MHz instead of 4 MHz, but I also believe that the DCO calibration is taking ages. I would like to check if using a binary search for the correct DCO settings instead of the linear search yields a significant speed up. As a bonus, this will terminate naturally without having to detect that one is oscillating between "just a bit too fast" and "just a bit too slow" without hitting "just right" until seconds of brute force have passed. (Some simple calculus indicates that indeed linear search among the hole configuration space takes 0.4375 seconds. So I think it is indeed sensible to give the binary search a try.) |
IMO the code with the binary search for the correct DCO calibration is indeed cleaner. I perceive the boot up time to be a bit faster now as well; I haven't done actual measurements though. With the greatly reduced number of steps it is now also feasible to let the timer capture twice with the same DCO settings in place. That should result in higher precision, as now the full duration between two captures the DCO was clocking at the higher frequency (and it also become some time to settle). Again, no actual measurements done, but it at least is plausible that this is better. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks much nicer indeed.
I don't have the hardware, but maybe @kaspar030 or @miri64 still have an msb-430
and can verify this also still works on those boards.
extern "C" { | ||
#endif | ||
|
||
#define INFOMEM (0x1000) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any info on what this is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is the start address of the info mem segment of the flash:
The info mem is actually just normally flash, but the blocks are smaller. This makes it more suitable as EEPROM replacement, as a read-modify-erase-write cycle would be faster due to the smaller block size.
It may be useful for an application to have that address to easily read application data from flash stored there. Likely, it would be better to use the linker (the vendor provided linker files define the INFOMEM memory) to access that, though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If that's a hardware property (e.g. can't be configured by the board) it should be defined by the CPU - and be documented.
I reckon we also don't place firmware there, but instead have a special linker section for this memory?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be how IMO we should do it. As of now, it is up to the application developer to use it.
This is certainly on the list of todos for cleaning up the MSP430 platform; as well as cleaning up all of the periph
drivers. (Likely the periph
drivers are more pressing.)
My original plan was to get in support for the Olimex board without doing any cleanup, so that I can work and test the cleanup with real hardware without having to juggle to much out of tree code. However, adding another copy of the void msp430_init_dco(void)
function implementing the exact same thing for every board is something that just felt too wrong.
Still, I would like to keep the INFOMEM
as a define and on board level for now. Moving that to CPU level would however be swift and easy follow-up PR that I could do prior to cleaning up the peripherals.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks much nicer indeed.
I don't have the hardware, but maybe @kaspar030 or @miri64 still have an msb-430
and can verify this also still works on those boards.
95e2696
to
24f0691
Compare
1e92692
to
0cd6db1
Compare
Build failed: |
Yep, I should have listened to @aabadie 😅 I don't quite get why the insufficient_memory_tool didn't catch that, though. Maybe my container is out of date. |
e4f5e84
to
68c5396
Compare
Or maybe a rebase messed that up... |
68c5396
to
48b3aa1
Compare
48b3aa1
to
ee3a8ec
Compare
ee3a8ec
to
e7d1c4a
Compare
bors retry |
Build succeeded! The publicly hosted instance of bors-ng is deprecated and will go away soon. If you want to self-host your own instance, instructions are here. If you want to switch to GitHub's built-in merge queue, visit their help page. |
🎉 Thx for the review / testing. |
df5c319 from RIOT-OS#19558 broke the clock configuration of the Z1 by relying on the incorrect documentation of what clock is actually used. Closely reading the convoluted clock initialization code revealed that no XT2 crystal is present (as also indicated by some comments in `board.c`), contradicting the `#define MSP430_HAS_EXTERNAL_CRYSTAL 1` in the `board.h`. This now should restore behavior (but with calibrated DCO than hard coded magic numbers).
df5c319 from RIOT-OS#19558 broke the clock configuration of the Z1 by relying on the incorrect documentation of what clock is actually used. Closely reading the convoluted clock initialization code revealed that no XT2 crystal is present (as also indicated by some comments in `board.c`), contradicting the `#define MSP430_HAS_EXTERNAL_CRYSTAL 1` in the `board.h`. This now should restore behavior (but with calibrated DCO than hard coded magic numbers).
19705: boards/z1: fix broken clock configuration r=maribu a=maribu ### Contribution description The MSP430F2xx family has on RSEL bit more than the MSP430x1xxx family. The first commit updates the clock calibration accordingly. df5c319 from #19558 broke the clock configuration of the Z1 by relying on the incorrect documentation of what clock is actually used. Closely reading the convoluted clock initialization code revealed that no XT2 crystal is present (as also indicated by some comments in `board.c`), contradicting the `#define MSP430_HAS_EXTERNAL_CRYSTAL 1` in the `board.h`. The second commit should restore behavior (but with calibrated DCO than hard coded magic numbers). 19713: nanocoap: clean up coap_iterate_option(), make it public r=maribu a=benpicco Co-authored-by: Marian Buschsieweke <marian.buschsieweke@posteo.net> Co-authored-by: Benjamin Valentin <benjamin.valentin@ml-pa.com>
19705: boards/z1: fix broken clock configuration r=maribu a=maribu ### Contribution description The MSP430F2xx family has on RSEL bit more than the MSP430x1xxx family. The first commit updates the clock calibration accordingly. df5c319 from #19558 broke the clock configuration of the Z1 by relying on the incorrect documentation of what clock is actually used. Closely reading the convoluted clock initialization code revealed that no XT2 crystal is present (as also indicated by some comments in `board.c`), contradicting the `#define MSP430_HAS_EXTERNAL_CRYSTAL 1` in the `board.h`. The second commit should restore behavior (but with calibrated DCO than hard coded magic numbers). Co-authored-by: Marian Buschsieweke <marian.buschsieweke@posteo.net>
Contribution description
board_init()
by handclock_init()
in case some really crazy things should happenTesting procedure
Issues/PRs references
None