diff --git a/9_Firmware/9_1_Microcontroller/9_1_3_C_Cpp_Code/main.cpp b/9_Firmware/9_1_Microcontroller/9_1_3_C_Cpp_Code/main.cpp index b0e563b..cf82984 100644 --- a/9_Firmware/9_1_Microcontroller/9_1_3_C_Cpp_Code/main.cpp +++ b/9_Firmware/9_1_Microcontroller/9_1_3_C_Cpp_Code/main.cpp @@ -302,7 +302,16 @@ return Micros; //Clock TIM1 -> AHB/APB1 is set to 72MHz/presc+1 presc = 71 ////////////////////////////////////////////// void delay_us(volatile uint32_t us){ -__HAL_TIM_SET_COUNTER(&htim1,0); // set the counter value a +// MCU-N4: chunk requests larger than the TIM1 ARR (0xffff-1 = 65534 ticks +// at 1 MHz = ~65 ms). Without this, GET_COUNTER never reaches `us` once +// it wraps and the loop spins forever — a hazard with the PA energized. +const uint32_t ARR_TICKS = 0xffff - 1; +while (us > ARR_TICKS) { + __HAL_TIM_SET_COUNTER(&htim1, 0); + while (__HAL_TIM_GET_COUNTER(&htim1) < ARR_TICKS); + us -= ARR_TICKS; +} +__HAL_TIM_SET_COUNTER(&htim1, 0); // set the counter value a while (__HAL_TIM_GET_COUNTER(&htim1) < us); // //Clock TIMx -> AHB/APB1 is set to 72MHz/presc+1 presc = 71 } diff --git a/9_Firmware/9_3_GUI/radar_protocol.py b/9_Firmware/9_3_GUI/radar_protocol.py index a0a18c7..652c2ac 100644 --- a/9_Firmware/9_3_GUI/radar_protocol.py +++ b/9_Firmware/9_3_GUI/radar_protocol.py @@ -67,7 +67,7 @@ class Opcode(IntEnum): RADAR_MODE = 0x01 # 2-bit mode select TRIGGER_PULSE = 0x02 # self-clearing one-shot trigger DETECT_THRESHOLD = 0x03 # 16-bit detection threshold value - STREAM_CONTROL = 0x04 # 3-bit stream enable mask + STREAM_CONTROL = 0x04 # 6-bit stream enable mask (FPGA: usb_cmd_value[5:0]) # --- Digital gain (0x16) --- GAIN_SHIFT = 0x16 # 4-bit digital gain shift