bouffalolab / bouffalo_sdk

BouffaloSDK is the IOT and MCU software development kit provided by the Bouffalo Lab Team, supports all the series of Bouffalo chips. Also it is the combination of bl_mcu_sdk and bl_iot_sdk
Apache License 2.0
371 stars 127 forks source link

Missing BL702 HBN XCLK initialization in SDK v2.0 #147

Closed mdednev closed 1 year ago

mdednev commented 1 year ago

Hello,

Newest SDK 2.0 lacks HBN_Set_XCLK_CLK_Sel(...) calls to initialize HBN high-speed clock for BL702. Bluetooth LE and other wireless interfaces couldn't perform properly without such initialization, because they should use very stable XTAL 32M clock. Older bl_mcu_sdk V1.4.5 has such calls, current bl_iot_sdk version has such calls too. This initialization should be added to the BSP's system_clock_init(void) function in bsp/board/bl702dk/board.c, so system_clock_init(void) should look like:

static void system_clock_init(void)
{
    GLB_Set_System_CLK(GLB_DLL_XTAL_32M, GLB_SYS_CLK_DLL144M);
    GLB_Set_MTimer_CLK(1, GLB_MTIMER_CLK_BCLK, 71);
    HBN_Set_XCLK_CLK_Sel(HBN_XCLK_CLK_XTAL);
}
sakumisu commented 1 year ago

Right, wireless need external 32M xtal, but currently wireless does not support for bl702.

mdednev commented 1 year ago

Ok, but there is no guarantee that this initialization will be added along with wireless support (f.e. BLE stack) for BL702. So I think that it should be added as soon as possible, because it gives some benefits and apparently doesn't break anything.

sakumisu commented 1 year ago

Thanks, you can submit pr to modify this.

mdednev commented 1 year ago

Done. Created https://github.com/bouffalolab/bouffalo_sdk/pull/149