bug: XC8 register bitfield accessors used incorrectly across codebase #29

Closed
opened 2026-08-02 05:25:20 +00:00 by time · 1 comment
Contributor

The XC8 DFP header defines peripheral register bits as struct members (FVRCONbits.FVREN, etc.), not as #define constants. Code was using bare bitfield names as if they were C bit-position constants, which only compiled due to XC8 quirks but produced wrong register values. Affected: FVR (ADFVR gain=0, never ready), WDT (reserved prescaler → ~1ms instead of 256s), ADC (channel selection + GO_nDONE), comparator, CPS. Fix: use RegisterNamebits.FieldName pattern throughout.

The XC8 DFP header defines peripheral register bits as struct members (FVRCONbits.FVREN, etc.), not as #define constants. Code was using bare bitfield names as if they were C bit-position constants, which only compiled due to XC8 quirks but produced wrong register values. Affected: FVR (ADFVR gain=0, never ready), WDT (reserved prescaler → ~1ms instead of 256s), ADC (channel selection + GO_nDONE), comparator, CPS. Fix: use RegisterNamebits.FieldName pattern throughout.
Author
Contributor

Fixed in PR #39: all peripheral register access now uses XC8 DFP bitfield accessors (e.g., FVRCONbits.FVREN instead of bare bitfield names).

Fixed in PR #39: all peripheral register access now uses XC8 DFP bitfield accessors (e.g., FVRCONbits.FVREN instead of bare bitfield names).
time closed this issue 2026-08-03 04:06:57 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
daru/PICsense#29
No description provided.