2020-09-16 10:43 AM
SBSFU 2.4.0 initializes CPU2 in all cases (for a good reason, locking the AES Key used for decryting the firmware image(s) )
When trying to set a HSE tune value (neccessary for proper Bluetooth connectivity) in the application (and also in my loader), the procedure hangs on stopping HSE and waiting for the HSERDY bit to become reset.
I tracked it down to the very moment the PWR->CR4, PWR_CR4_C2BOOT is set.
The HSEON bit is not set at any time I could observe it. From RM0434: "This bit cannot be reset if the HSE oscillator is used directly or indirectly as the system
clock."
So while HSERDY is set after C2BOOT i can still set HSEON to 1 and 0 as I wish (without influence on HSERDY). Only after I select HSE as a system clock source, I can't reset HSEON anymore. This lets me believe that the HSERDY bit staying on is indeed a bug, and not caused by it accidentially being selected as a clock source.
Does CPU2 / BLE Wireless Stack initialize HSE? Why does it make HSERDY stick to be SET?
Is it safe to ignore that HSERDY is set (and setting a HSE tune value)?
2020-09-21 02:07 AM
Hello,
Here is the way HSE is used in the device.
The BLE IP Core (in CPU2 subsystem) is taking the clock from HCLK5 as described in the Reference manual RM0434 ( fig15 Clock tree).
The switch between HSE/2 and HSI16 is done by hardware. HSE/2 is selected when available on the board.
The BLE IP Core is able to start the HSE oscillator on its own when needed ( whatever is the setting of the HSEON bit) whereas it requires HSION bit to be set to take it from HSI16 when HSE is not available.
At CPU2 startup, it is required to make some initialization of the BLE IP Core ( even though BLE is not yet started by the CPU1) so there is a request done to the HSE oscillator.
That's the reason why although HSEON bit is set to 0 ( as not used by the CPU1), HSERDY is set to 1 because the oscillator has been started by the BLE IP Core.
Note that you don't mandatory need either HSI16 or HSE to be used as system clock. HCLK5 is a separated clock feeding the BLE IP Core and you can use whatever clock system you need for your product.
Regarding HSE Tuning, it is safe to write HSETUNE even though HSERDY is set.
However, there are some requirements to tune the HSE ( especially concerning the maximum step allowed)
Please refer to AN5042 for complete trimming procedure.
Regards.
2020-09-22 01:35 AM
Hello Christophe,
RM0434 states:
HSETUNE[5:0]: HSE capacitor tuning
Can be changed by software. Not to be changed when HSE is on.
In my scenario SBSFU initializes CPU2. But the user application is intended to switch HSE on.
AN5042 does not mention a maximum step size for applying an already found tune value. Can you give details on that?
2020-09-22 09:01 AM
Hello,
It is recommended to limit each step size to 0x08.
Regards.