-
Notifications
You must be signed in to change notification settings - Fork 66
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
XH-M188 locking up after power-up #44
Comments
Old version mistakenly unlocked option bytes, not necessary from user space code Old version didn't wait for EOP (end of programming) bit to be set New version does both, and doesn't hang. Woot.
Fix was easy. Partly reading the three (!) datasheets correctly, partly buckling down and writing a one-liner busy-wait in assembly. Sent pull request. |
Fixes #44: XH-M188 lockup after power cycle
Great :-) https://github.com/TG9541/stm8ef/blob/develop/lib/hw/opt.fs and this: and finally this: |
I wonder whether a standard method for defining option bits in a project should look like. It would be possible to define option bits in a file in the board folder but especially for breakout boards that misses the point. Checking and setting the option bits should be done at the start of the application software. Problem is that options bits can be wrong even if the application is completely happy with the default. What do you think about the following:
|
I didn't know there was option-byte code in lib/ ... or maybe there wasn't when I wrote the first versioin of the XH-M188 code. The OPT! word in lib/ doesn't a) wait for EEPROM write to finish, or b) reset the option-protect bit (in FLASH_CR2) when it's done. It could probably do both. An option-bytes config shouild definitely default to a per-board setting. On the XH-M188, for instance, it's absolutely necessary to set the option bit to enable PWM on the voltage-control channel. And you'll definitely want to enable user access to the option bits for the general-purpose boards as well, as your servo example illustrates. OPT! is a great addition to the lib/. The check-default, modify-if-needed plan you outlined seems fine to me. |
* upstream/master: (25 commits) reference to Wiki updated library additions library mcu according to e4thcom convention Update README.md some bytes saved some editing Fixes TG9541#44: XH-M188 lockup after power cycle fixes TG9541#43 Provide a Forth library infrastructure fixes TG9541#42 Improve W1209 ease of use fixes TG9541#42 Improve W1209 ease of use fixes TG9541#41: improved full duplex simulated serial edit Fix for UART simulation with 2 GPIOs HAS_ALIAS default on (IMMEDIATE words in RAM possible) SWIMCOM fix for HEADER macro, option WORDS_HWREG off issue TG9541#32 Build framework feature #include fixes TG9541#39 : underflow error message doesn't match normal pattern fixes TG9541#39 : underflow error message doesn't match normal pattern issue TG9541#32 Build framework feature: Forth application binary with uCsim issue TG9541#32: use telnet library ...
The library is quite new, and when you published the OPT-setting code the library didn't even exist :-) |
After a power cycle my test XH-M188s don't respond with the stm8eForth prompt, or apparently work at all. Sometimes a reset either with a pushbutton or the st-link programmer will bring the console back, but even then the PWM doesn't work. They work just fine when freshly programmed, but a subsequent power cycle kills 'em.
I wrote some frankly dodgy code in the init section for this board, and I'm not surprised if it's related to that. To set the hardware PWM channel for the board, there is some fooling around with option bytes in flash, and it could be the bug lies there.
I tested the same boards out with the MINDEV version, and they work just fine on power-up every time, so I'm pretty sure that it's the firmware. I'll look into it fairly soon.
The text was updated successfully, but these errors were encountered: