Made two minimal, surgical fixes to stabilize ON/OFF splitting.
What I changed
- Core/Inc/main.h:76
- Set ADC_BUFF_SIZE from 50 to 64 so each half is even (32). This keeps the “i &
1” parity consistent across half-buffer boundaries.
- Core/Src/stm32f4xx_it.c:388
- Fixed N after splitting the first half: ADC_proc.N = (ADC_BUFF_SIZE/2 -
Sweep_state.curr_step_start_DMA_N)/2;
- Previously it used (Sweep_state.curr_step_start_DMA_N)/2, which was wrong for
that segment.
Why this helps
- With ADC_BUFF_SIZE=50, half-size is 25 (odd). That flips ON/OFF labeling each half
because i & 1 parity shifts by 25, mixing levels and driving avg_ON and avg_OFF
together.
- The N bug skewed normalization, further flattening differences between averages.
How to verify
- Build and flash: make && make flash.
- Observe avg_ON/avg_OFF over CDC. They should now differ consistently; inverting
meандр should swap them cleanly.
- If still needed, I can add a global sample counter (sample_seq) for fully robust
ON/OFF classification without relying on buffer indices.
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
ARM GAS /tmp/ccYDBhKF.s page 1
|
||||
ARM GAS /tmp/ccEtzPFc.s page 1
|
||||
|
||||
|
||||
1 .cpu cortex-m4
|
||||
@ -58,7 +58,7 @@ ARM GAS /tmp/ccYDBhKF.s page 1
|
||||
27:USB_DEVICE/App/usbd_desc.c ****
|
||||
28:USB_DEVICE/App/usbd_desc.c **** /* USER CODE END INCLUDE */
|
||||
29:USB_DEVICE/App/usbd_desc.c ****
|
||||
ARM GAS /tmp/ccYDBhKF.s page 2
|
||||
ARM GAS /tmp/ccEtzPFc.s page 2
|
||||
|
||||
|
||||
30:USB_DEVICE/App/usbd_desc.c **** /* Private typedef -----------------------------------------------------------*/
|
||||
@ -118,7 +118,7 @@ ARM GAS /tmp/ccYDBhKF.s page 1
|
||||
84:USB_DEVICE/App/usbd_desc.c ****
|
||||
85:USB_DEVICE/App/usbd_desc.c **** /* USER CODE END 0 */
|
||||
86:USB_DEVICE/App/usbd_desc.c ****
|
||||
ARM GAS /tmp/ccYDBhKF.s page 3
|
||||
ARM GAS /tmp/ccEtzPFc.s page 3
|
||||
|
||||
|
||||
87:USB_DEVICE/App/usbd_desc.c **** /** @defgroup USBD_DESC_Private_Macros USBD_DESC_Private_Macros
|
||||
@ -178,7 +178,7 @@ ARM GAS /tmp/ccYDBhKF.s page 1
|
||||
141:USB_DEVICE/App/usbd_desc.c **** , USBD_FS_ManufacturerStrDescriptor
|
||||
142:USB_DEVICE/App/usbd_desc.c **** , USBD_FS_ProductStrDescriptor
|
||||
143:USB_DEVICE/App/usbd_desc.c **** , USBD_FS_SerialStrDescriptor
|
||||
ARM GAS /tmp/ccYDBhKF.s page 4
|
||||
ARM GAS /tmp/ccEtzPFc.s page 4
|
||||
|
||||
|
||||
144:USB_DEVICE/App/usbd_desc.c **** , USBD_FS_ConfigStrDescriptor
|
||||
@ -238,7 +238,7 @@ ARM GAS /tmp/ccYDBhKF.s page 1
|
||||
198:USB_DEVICE/App/usbd_desc.c **** USB_DEVICE_CAPABITY_TYPE,
|
||||
199:USB_DEVICE/App/usbd_desc.c **** 0x2,
|
||||
200:USB_DEVICE/App/usbd_desc.c **** 0x2, /* LPM capability bit set*/
|
||||
ARM GAS /tmp/ccYDBhKF.s page 5
|
||||
ARM GAS /tmp/ccEtzPFc.s page 5
|
||||
|
||||
|
||||
201:USB_DEVICE/App/usbd_desc.c **** 0x0,
|
||||
@ -298,7 +298,7 @@ ARM GAS /tmp/ccYDBhKF.s page 1
|
||||
255:USB_DEVICE/App/usbd_desc.c **** * @param length : Pointer to data length variable
|
||||
256:USB_DEVICE/App/usbd_desc.c **** * @retval Pointer to descriptor buffer
|
||||
257:USB_DEVICE/App/usbd_desc.c **** */
|
||||
ARM GAS /tmp/ccYDBhKF.s page 6
|
||||
ARM GAS /tmp/ccEtzPFc.s page 6
|
||||
|
||||
|
||||
258:USB_DEVICE/App/usbd_desc.c **** uint8_t * USBD_FS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
|
||||
@ -358,7 +358,7 @@ ARM GAS /tmp/ccYDBhKF.s page 1
|
||||
69 .loc 1 274 3 view .LVU9
|
||||
70 .loc 1 274 11 is_stmt 0 view .LVU10
|
||||
71 0000 0423 movs r3, #4
|
||||
ARM GAS /tmp/ccYDBhKF.s page 7
|
||||
ARM GAS /tmp/ccEtzPFc.s page 7
|
||||
|
||||
|
||||
72 0002 0B80 strh r3, [r1] @ movhi
|
||||
@ -418,7 +418,7 @@ ARM GAS /tmp/ccYDBhKF.s page 1
|
||||
308:USB_DEVICE/App/usbd_desc.c **** }
|
||||
309:USB_DEVICE/App/usbd_desc.c ****
|
||||
310:USB_DEVICE/App/usbd_desc.c **** /**
|
||||
ARM GAS /tmp/ccYDBhKF.s page 8
|
||||
ARM GAS /tmp/ccEtzPFc.s page 8
|
||||
|
||||
|
||||
311:USB_DEVICE/App/usbd_desc.c **** * @brief Return the serial number string descriptor
|
||||
@ -478,7 +478,7 @@ ARM GAS /tmp/ccYDBhKF.s page 1
|
||||
365:USB_DEVICE/App/usbd_desc.c **** return USBD_StrDesc;
|
||||
366:USB_DEVICE/App/usbd_desc.c **** }
|
||||
367:USB_DEVICE/App/usbd_desc.c ****
|
||||
ARM GAS /tmp/ccYDBhKF.s page 9
|
||||
ARM GAS /tmp/ccEtzPFc.s page 9
|
||||
|
||||
|
||||
368:USB_DEVICE/App/usbd_desc.c **** #if (USBD_LPM_ENABLED == 1)
|
||||
@ -538,7 +538,7 @@ ARM GAS /tmp/ccYDBhKF.s page 1
|
||||
417:USB_DEVICE/App/usbd_desc.c ****
|
||||
418:USB_DEVICE/App/usbd_desc.c **** for (idx = 0; idx < len; idx++)
|
||||
100 .loc 1 418 3 view .LVU16
|
||||
ARM GAS /tmp/ccYDBhKF.s page 10
|
||||
ARM GAS /tmp/ccEtzPFc.s page 10
|
||||
|
||||
|
||||
101 .loc 1 418 12 is_stmt 0 view .LVU17
|
||||
@ -598,7 +598,7 @@ ARM GAS /tmp/ccYDBhKF.s page 1
|
||||
138 .loc 1 418 21 is_stmt 1 discriminator 1 view .LVU31
|
||||
139 0028 9342 cmp r3, r2
|
||||
140 002a 09D2 bcs .L16
|
||||
ARM GAS /tmp/ccYDBhKF.s page 11
|
||||
ARM GAS /tmp/ccEtzPFc.s page 11
|
||||
|
||||
|
||||
141 .L11:
|
||||
@ -658,7 +658,7 @@ ARM GAS /tmp/ccYDBhKF.s page 1
|
||||
186 .loc 1 391 3 view .LVU42
|
||||
392:USB_DEVICE/App/usbd_desc.c ****
|
||||
187 .loc 1 392 3 view .LVU43
|
||||
ARM GAS /tmp/ccYDBhKF.s page 12
|
||||
ARM GAS /tmp/ccEtzPFc.s page 12
|
||||
|
||||
|
||||
394:USB_DEVICE/App/usbd_desc.c **** deviceserial1 = *(uint32_t *) DEVICE_ID2;
|
||||
@ -718,7 +718,7 @@ ARM GAS /tmp/ccYDBhKF.s page 1
|
||||
228 .L22:
|
||||
229 002e 00BF .align 2
|
||||
230 .L21:
|
||||
ARM GAS /tmp/ccYDBhKF.s page 13
|
||||
ARM GAS /tmp/ccEtzPFc.s page 13
|
||||
|
||||
|
||||
231 0030 0070FF1F .word 536834048
|
||||
@ -778,7 +778,7 @@ ARM GAS /tmp/ccYDBhKF.s page 1
|
||||
278 72747561
|
||||
278 6C20436F
|
||||
278 6D506F72
|
||||
ARM GAS /tmp/ccYDBhKF.s page 14
|
||||
ARM GAS /tmp/ccEtzPFc.s page 14
|
||||
|
||||
|
||||
279 .section .text.USBD_FS_ProductStrDescriptor,"ax",%progbits
|
||||
@ -838,7 +838,7 @@ ARM GAS /tmp/ccYDBhKF.s page 1
|
||||
323 0014 0248 ldr r0, .L31+4
|
||||
324 .LVL25:
|
||||
292:USB_DEVICE/App/usbd_desc.c **** }
|
||||
ARM GAS /tmp/ccYDBhKF.s page 15
|
||||
ARM GAS /tmp/ccEtzPFc.s page 15
|
||||
|
||||
|
||||
325 .loc 1 292 5 view .LVU77
|
||||
@ -898,7 +898,7 @@ ARM GAS /tmp/ccYDBhKF.s page 1
|
||||
306:USB_DEVICE/App/usbd_desc.c **** return USBD_StrDesc;
|
||||
371 .loc 1 306 3 view .LVU84
|
||||
372 000a FFF7FEFF bl USBD_GetString
|
||||
ARM GAS /tmp/ccYDBhKF.s page 16
|
||||
ARM GAS /tmp/ccEtzPFc.s page 16
|
||||
|
||||
|
||||
373 .LVL30:
|
||||
@ -958,7 +958,7 @@ ARM GAS /tmp/ccYDBhKF.s page 1
|
||||
419 .LVL33:
|
||||
340:USB_DEVICE/App/usbd_desc.c **** }
|
||||
420 .loc 1 340 5 view .LVU93
|
||||
ARM GAS /tmp/ccYDBhKF.s page 17
|
||||
ARM GAS /tmp/ccEtzPFc.s page 17
|
||||
|
||||
|
||||
421 000a FFF7FEFF bl USBD_GetString
|
||||
@ -1018,7 +1018,7 @@ ARM GAS /tmp/ccYDBhKF.s page 1
|
||||
356:USB_DEVICE/App/usbd_desc.c **** if(speed == 0)
|
||||
467 .loc 1 356 1 is_stmt 0 view .LVU101
|
||||
468 0000 08B5 push {r3, lr}
|
||||
ARM GAS /tmp/ccYDBhKF.s page 18
|
||||
ARM GAS /tmp/ccEtzPFc.s page 18
|
||||
|
||||
|
||||
469 .LCFI7:
|
||||
@ -1078,7 +1078,7 @@ ARM GAS /tmp/ccYDBhKF.s page 1
|
||||
513 .section .data.USBD_StringSerial,"aw"
|
||||
514 .align 2
|
||||
517 USBD_StringSerial:
|
||||
ARM GAS /tmp/ccYDBhKF.s page 19
|
||||
ARM GAS /tmp/ccEtzPFc.s page 19
|
||||
|
||||
|
||||
518 0000 1A0300 .ascii "\032\003\000"
|
||||
@ -1127,51 +1127,51 @@ ARM GAS /tmp/ccYDBhKF.s page 1
|
||||
558 .file 3 "Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_def.h"
|
||||
559 .file 4 "USB_DEVICE/App/usbd_desc.h"
|
||||
560 .file 5 "Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_ctlreq.h"
|
||||
ARM GAS /tmp/ccYDBhKF.s page 20
|
||||
ARM GAS /tmp/ccEtzPFc.s page 20
|
||||
|
||||
|
||||
DEFINED SYMBOLS
|
||||
*ABS*:00000000 usbd_desc.c
|
||||
/tmp/ccYDBhKF.s:21 .text.USBD_FS_DeviceDescriptor:00000000 $t
|
||||
/tmp/ccYDBhKF.s:27 .text.USBD_FS_DeviceDescriptor:00000000 USBD_FS_DeviceDescriptor
|
||||
/tmp/ccYDBhKF.s:49 .text.USBD_FS_DeviceDescriptor:00000008 $d
|
||||
/tmp/ccYDBhKF.s:539 .data.USBD_FS_DeviceDesc:00000000 USBD_FS_DeviceDesc
|
||||
/tmp/ccYDBhKF.s:54 .text.USBD_FS_LangIDStrDescriptor:00000000 $t
|
||||
/tmp/ccYDBhKF.s:60 .text.USBD_FS_LangIDStrDescriptor:00000000 USBD_FS_LangIDStrDescriptor
|
||||
/tmp/ccYDBhKF.s:82 .text.USBD_FS_LangIDStrDescriptor:00000008 $d
|
||||
/tmp/ccYDBhKF.s:532 .data.USBD_LangIDDesc:00000000 USBD_LangIDDesc
|
||||
/tmp/ccYDBhKF.s:87 .text.IntToUnicode:00000000 $t
|
||||
/tmp/ccYDBhKF.s:92 .text.IntToUnicode:00000000 IntToUnicode
|
||||
/tmp/ccYDBhKF.s:167 .text.Get_SerialNum:00000000 $t
|
||||
/tmp/ccYDBhKF.s:172 .text.Get_SerialNum:00000000 Get_SerialNum
|
||||
/tmp/ccYDBhKF.s:231 .text.Get_SerialNum:00000030 $d
|
||||
/tmp/ccYDBhKF.s:517 .data.USBD_StringSerial:00000000 USBD_StringSerial
|
||||
/tmp/ccYDBhKF.s:237 .text.USBD_FS_SerialStrDescriptor:00000000 $t
|
||||
/tmp/ccYDBhKF.s:243 .text.USBD_FS_SerialStrDescriptor:00000000 USBD_FS_SerialStrDescriptor
|
||||
/tmp/ccYDBhKF.s:271 .text.USBD_FS_SerialStrDescriptor:00000010 $d
|
||||
/tmp/ccYDBhKF.s:276 .rodata.USBD_FS_ProductStrDescriptor.str1.4:00000000 $d
|
||||
/tmp/ccYDBhKF.s:280 .text.USBD_FS_ProductStrDescriptor:00000000 $t
|
||||
/tmp/ccYDBhKF.s:286 .text.USBD_FS_ProductStrDescriptor:00000000 USBD_FS_ProductStrDescriptor
|
||||
/tmp/ccYDBhKF.s:333 .text.USBD_FS_ProductStrDescriptor:0000001c $d
|
||||
/tmp/ccYDBhKF.s:525 .bss.USBD_StrDesc:00000000 USBD_StrDesc
|
||||
/tmp/ccYDBhKF.s:339 .rodata.USBD_FS_ManufacturerStrDescriptor.str1.4:00000000 $d
|
||||
/tmp/ccYDBhKF.s:343 .text.USBD_FS_ManufacturerStrDescriptor:00000000 $t
|
||||
/tmp/ccYDBhKF.s:349 .text.USBD_FS_ManufacturerStrDescriptor:00000000 USBD_FS_ManufacturerStrDescriptor
|
||||
/tmp/ccYDBhKF.s:381 .text.USBD_FS_ManufacturerStrDescriptor:00000014 $d
|
||||
/tmp/ccYDBhKF.s:387 .rodata.USBD_FS_ConfigStrDescriptor.str1.4:00000000 $d
|
||||
/tmp/ccYDBhKF.s:391 .text.USBD_FS_ConfigStrDescriptor:00000000 $t
|
||||
/tmp/ccYDBhKF.s:397 .text.USBD_FS_ConfigStrDescriptor:00000000 USBD_FS_ConfigStrDescriptor
|
||||
/tmp/ccYDBhKF.s:444 .text.USBD_FS_ConfigStrDescriptor:0000001c $d
|
||||
/tmp/ccYDBhKF.s:450 .rodata.USBD_FS_InterfaceStrDescriptor.str1.4:00000000 $d
|
||||
/tmp/ccYDBhKF.s:454 .text.USBD_FS_InterfaceStrDescriptor:00000000 $t
|
||||
/tmp/ccYDBhKF.s:460 .text.USBD_FS_InterfaceStrDescriptor:00000000 USBD_FS_InterfaceStrDescriptor
|
||||
/tmp/ccYDBhKF.s:507 .text.USBD_FS_InterfaceStrDescriptor:0000001c $d
|
||||
/tmp/ccYDBhKF.s:514 .data.USBD_StringSerial:00000000 $d
|
||||
/tmp/ccYDBhKF.s:522 .bss.USBD_StrDesc:00000000 $d
|
||||
/tmp/ccYDBhKF.s:529 .data.USBD_LangIDDesc:00000000 $d
|
||||
/tmp/ccYDBhKF.s:536 .data.USBD_FS_DeviceDesc:00000000 $d
|
||||
/tmp/ccYDBhKF.s:547 .data.FS_Desc:00000000 FS_Desc
|
||||
/tmp/ccYDBhKF.s:544 .data.FS_Desc:00000000 $d
|
||||
/tmp/ccEtzPFc.s:21 .text.USBD_FS_DeviceDescriptor:00000000 $t
|
||||
/tmp/ccEtzPFc.s:27 .text.USBD_FS_DeviceDescriptor:00000000 USBD_FS_DeviceDescriptor
|
||||
/tmp/ccEtzPFc.s:49 .text.USBD_FS_DeviceDescriptor:00000008 $d
|
||||
/tmp/ccEtzPFc.s:539 .data.USBD_FS_DeviceDesc:00000000 USBD_FS_DeviceDesc
|
||||
/tmp/ccEtzPFc.s:54 .text.USBD_FS_LangIDStrDescriptor:00000000 $t
|
||||
/tmp/ccEtzPFc.s:60 .text.USBD_FS_LangIDStrDescriptor:00000000 USBD_FS_LangIDStrDescriptor
|
||||
/tmp/ccEtzPFc.s:82 .text.USBD_FS_LangIDStrDescriptor:00000008 $d
|
||||
/tmp/ccEtzPFc.s:532 .data.USBD_LangIDDesc:00000000 USBD_LangIDDesc
|
||||
/tmp/ccEtzPFc.s:87 .text.IntToUnicode:00000000 $t
|
||||
/tmp/ccEtzPFc.s:92 .text.IntToUnicode:00000000 IntToUnicode
|
||||
/tmp/ccEtzPFc.s:167 .text.Get_SerialNum:00000000 $t
|
||||
/tmp/ccEtzPFc.s:172 .text.Get_SerialNum:00000000 Get_SerialNum
|
||||
/tmp/ccEtzPFc.s:231 .text.Get_SerialNum:00000030 $d
|
||||
/tmp/ccEtzPFc.s:517 .data.USBD_StringSerial:00000000 USBD_StringSerial
|
||||
/tmp/ccEtzPFc.s:237 .text.USBD_FS_SerialStrDescriptor:00000000 $t
|
||||
/tmp/ccEtzPFc.s:243 .text.USBD_FS_SerialStrDescriptor:00000000 USBD_FS_SerialStrDescriptor
|
||||
/tmp/ccEtzPFc.s:271 .text.USBD_FS_SerialStrDescriptor:00000010 $d
|
||||
/tmp/ccEtzPFc.s:276 .rodata.USBD_FS_ProductStrDescriptor.str1.4:00000000 $d
|
||||
/tmp/ccEtzPFc.s:280 .text.USBD_FS_ProductStrDescriptor:00000000 $t
|
||||
/tmp/ccEtzPFc.s:286 .text.USBD_FS_ProductStrDescriptor:00000000 USBD_FS_ProductStrDescriptor
|
||||
/tmp/ccEtzPFc.s:333 .text.USBD_FS_ProductStrDescriptor:0000001c $d
|
||||
/tmp/ccEtzPFc.s:525 .bss.USBD_StrDesc:00000000 USBD_StrDesc
|
||||
/tmp/ccEtzPFc.s:339 .rodata.USBD_FS_ManufacturerStrDescriptor.str1.4:00000000 $d
|
||||
/tmp/ccEtzPFc.s:343 .text.USBD_FS_ManufacturerStrDescriptor:00000000 $t
|
||||
/tmp/ccEtzPFc.s:349 .text.USBD_FS_ManufacturerStrDescriptor:00000000 USBD_FS_ManufacturerStrDescriptor
|
||||
/tmp/ccEtzPFc.s:381 .text.USBD_FS_ManufacturerStrDescriptor:00000014 $d
|
||||
/tmp/ccEtzPFc.s:387 .rodata.USBD_FS_ConfigStrDescriptor.str1.4:00000000 $d
|
||||
/tmp/ccEtzPFc.s:391 .text.USBD_FS_ConfigStrDescriptor:00000000 $t
|
||||
/tmp/ccEtzPFc.s:397 .text.USBD_FS_ConfigStrDescriptor:00000000 USBD_FS_ConfigStrDescriptor
|
||||
/tmp/ccEtzPFc.s:444 .text.USBD_FS_ConfigStrDescriptor:0000001c $d
|
||||
/tmp/ccEtzPFc.s:450 .rodata.USBD_FS_InterfaceStrDescriptor.str1.4:00000000 $d
|
||||
/tmp/ccEtzPFc.s:454 .text.USBD_FS_InterfaceStrDescriptor:00000000 $t
|
||||
/tmp/ccEtzPFc.s:460 .text.USBD_FS_InterfaceStrDescriptor:00000000 USBD_FS_InterfaceStrDescriptor
|
||||
/tmp/ccEtzPFc.s:507 .text.USBD_FS_InterfaceStrDescriptor:0000001c $d
|
||||
/tmp/ccEtzPFc.s:514 .data.USBD_StringSerial:00000000 $d
|
||||
/tmp/ccEtzPFc.s:522 .bss.USBD_StrDesc:00000000 $d
|
||||
/tmp/ccEtzPFc.s:529 .data.USBD_LangIDDesc:00000000 $d
|
||||
/tmp/ccEtzPFc.s:536 .data.USBD_FS_DeviceDesc:00000000 $d
|
||||
/tmp/ccEtzPFc.s:547 .data.FS_Desc:00000000 FS_Desc
|
||||
/tmp/ccEtzPFc.s:544 .data.FS_Desc:00000000 $d
|
||||
|
||||
UNDEFINED SYMBOLS
|
||||
USBD_GetString
|
||||
|
||||
Reference in New Issue
Block a user