LoRa-E5 STM32 WLE 5JC: i2c doesnt work if not in debug mode [ioc -> debug -> serial/disabled]
My I2C doesn;t seem to work whenever i turn off debug pins in IOC. I used a diff to see the changes but it seems fine to my untrained eyes:
$ git diff
diff --git a/Core/Inc/sys_conf.h b/Core/Inc/sys_conf.h
index 988f1e8..b3cb386 100644
--- a/Core/Inc/sys_conf.h
+++ b/Core/Inc/sys_conf.h
@@ -75,7 +75,7 @@ extern "C" {
* @brief Enable/Disable MCU Debugger pins (dbg serial wires)
* @note by HW serial wires are ON by default, need to put them OFF to save power
*/
-#define DEBUGGER_ENABLED 1
+#define DEBUGGER_ENABLED 0^M
/**
* @brief Disable Low Power mode
diff --git a/Seeed-LoRa-E5.ioc b/Seeed-LoRa-E5.ioc
index c1059bc..ffbda64 100644
--- a/Seeed-LoRa-E5.ioc
+++ b/Seeed-LoRa-E5.ioc
@@ -199,64 +199,61 @@ Mcu.CPN=STM32WLE5JCI6
Mcu.Family=STM32WL
Mcu.IP0=ADC
Mcu.IP1=ADV_TRACE
-Mcu.IP10=RTC
-Mcu.IP11=SEQUENCER
-Mcu.IP12=SUBGHZ
-Mcu.IP13=SYS
-Mcu.IP14=TIMER
-Mcu.IP15=TINY_LPM
-Mcu.IP16=USART1
-Mcu.IP17=USART2
-Mcu.IP2=DEBUG
-Mcu.IP3=DMA
-Mcu.IP4=I2C2
-Mcu.IP5=LORAWAN
-Mcu.IP6=LPUART1
-Mcu.IP7=MISC
-Mcu.IP8=NVIC
-Mcu.IP9=RCC
-Mcu.IPNb=18
+Mcu.IP10=SEQUENCER
+Mcu.IP11=SUBGHZ
+Mcu.IP12=SYS
+Mcu.IP13=TIMER
+Mcu.IP14=TINY_LPM
+Mcu.IP15=USART1
+Mcu.IP16=USART2
+Mcu.IP2=DMA
+Mcu.IP3=I2C2
+Mcu.IP4=LORAWAN
+Mcu.IP5=LPUART1
+Mcu.IP6=MISC
+Mcu.IP7=NVIC
+Mcu.IP8=RCC
+Mcu.IP9=RTC
+Mcu.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3
+Mcu.Pin19=PA2
+Mcu.Pin2=PC14-OSC32_IN
+Mcu.Pin20=PB10
+Mcu.Pin21=PA4
+Mcu.Pin22=PA5
+Mcu.Pin23=VP_ADC_TempSens_Input
+Mcu.Pin24=VP_ADC_Vref_Input
+Mcu.Pin25=VP_ADV_TRACE_VS_ADV_TRACE
+Mcu.Pin26=VP_LORAWAN_VS_LoRaWAN
+Mcu.Pin27=VP_MISC_VS_MISC
+Mcu.Pin28=VP_RTC_VS_RTC_Activate
+Mcu.Pin29=VP_RTC_VS_RTC_Calendar
+Mcu.Pin3=PB3
+Mcu.Pin30=VP_RTC_VS_RTC_Alarm_A_Intern
+Mcu.Pin31=VP_SEQUENCER_VS_SEQUENCER
+Mcu.Pin32=VP_SUBGHZ_VS_SUBGHZ
+Mcu.Pin33=VP_SYS_VS_Systick
+Mcu.Pin34=VP_TIMER_VS_TIMER
+Mcu.Pin35=VP_TINY_LPM_VS_TINY_LPM
+Mcu.Pin4=PB4
+Mcu.Pin5=PB7
+Mcu.Pin6=PB9
+Mcu.Pin7=PC15-OSC32_OUT
+Mcu.Pin8=PB14
+Mcu.Pin9=PA10
+Mcu.PinsNb=36
Mcu.ThirdPartyNb=0
Mcu.UserConstants=RTC_N_PREDIV_S,10;RTC_PREDIV_S,((1<<RTC_N_PREDIV_S)-1);RTC_PREDIV_A,((1<<(15-RTC_N_PREDIV_S))-1)
Mcu.UserName=STM32WLE5JCIx
@@ -298,10 +295,6 @@ PA10.GPIO_Label=BQ_ALERT
PA10.GPIO_PuPd=GPIO_NOPULL
PA10.Locked=true
PA10.Signal=GPXTI10
-PA13.Mode=Serial_Wire
-PA13.Signal=DEBUG_JTMS-SWDIO
-PA14.Mode=Serial_Wire
-PA14.Signal=DEBUG_JTCK-SWCLK
PA15.Locked=true
PA15.Mode=I2C
PA15.Signal=I2C2_SDAim using the following code to wait for another chip to wake up. when debug is activated it works fine but when debug is tuned off it doesn;t work and is forever waiting for I2C:
//wait for i2c to activate
while (HAL_I2C_IsDeviceReady(&hi2c2, hbat1.address_i2c, 3, 5)) {
//TODO i2c doesnt work if not in debug mode - ioc debug -> serial/disabled
HAL_Delay(BAT_DELAY_WHILE_LOOP);
}I am at the end of my ideas. What is causing this?
Also i did use the following around my I2C code to prevent the device frmo going into sleep mode:
//start the active power counter
UTIL_LPM_SetStopMode((1 << CFG_LPM_BAT_MANAGER), UTIL_LPM_DISABLE);
//do the I2C code here
i2c_code();
UTIL_LPM_SetStopMode((1 << CFG_LPM_BAT_MANAGER), UTIL_LPM_ENABLE);I did use a logic analyzer to see if anything is sent from the STM and no luck. Both SDA and SCL stay high and don't go down ever.
Why is that? its also hard to debug with the debug turned off.