Skip to content

fix(ads1258): correct CONFIG1 SCBCS field values for bits [3:2]#3

Open
scalecode-solutions wants to merge 1 commit intoTexasInstruments:mainfrom
scalecode-solutions:fix/ads1258-config1-scbcs-values
Open

fix(ads1258): correct CONFIG1 SCBCS field values for bits [3:2]#3
scalecode-solutions wants to merge 1 commit intoTexasInstruments:mainfrom
scalecode-solutions:fix/ads1258-config1-scbcs-values

Conversation

@scalecode-solutions
Copy link
Copy Markdown

Summary

CONFIG1_SCBCS_1_5uA and CONFIG1_SCBCS_24uA in ads1258.h have incorrect values. The field values target bits [7:6] (IDLMOD/DLY positions) instead of bits [3:2] (SCBCS positions).

The Bug

#define CONFIG1_SCBCS_MASK   ((uint8_t) 0x0C)   // bits [3:2] ← correct mask
#define CONFIG1_SCBCS_1_5uA  ((uint8_t) 0x40)   // bit [6]    ← wrong, this is DLY[0]
#define CONFIG1_SCBCS_24uA   ((uint8_t) 0xC0)   // bits [7:6] ← wrong, this is IDLMOD + DLY[2]

The values fail their own mask — 0x40 & 0x0C = 0x00 and 0xC0 & 0x0C = 0x00.

Additionally, 0x40 collides with CONFIG1_DLY_64us defined on line 196, so code using CONFIG1_SCBCS_1_5uA would silently configure a 64µs switch time delay instead of the sensor bias current source.

The Fix

#define CONFIG1_SCBCS_1_5uA  ((uint8_t) 0x04)   // SCBCS[1:0] = 01
#define CONFIG1_SCBCS_24uA   ((uint8_t) 0x0C)   // SCBCS[1:0] = 11

Datasheet Reference

ADS1258 datasheet SBAS297G, Table 18 (page 38):

Bits 3–2: SBCS[1:0]
These bits set the sensor bias current source.

  • 0 = Sensor Bias Current Source Off (default)
  • 1 = 1.5µA Source
  • 3 = 24µA Source

Root Cause

The logical encoding values (1 and 3) are correct, but they were shifted to bits [7:6] instead of bits [3:2] — left-shifted by 6 instead of by 2.

Setting Correct (bits [3:2]) Erroneous (bits [7:6])
OFF (0) 0x00 0x00
1.5µA (1) 0x04 0x40
24µA (3) 0x0C 0xC0

Impact

Low in practice — adcStartupRoutine() does not use these constants, so the bug is dormant in the example code. It only affects users who explicitly configure sensor bias current using the named constants.

Additional Note

The datasheet uses SBCS (Sensor Bias Current Source) while the header uses SCBCS. This is a minor naming discrepancy but not addressed in this PR to avoid unnecessary breakage.

CONFIG1_SCBCS_1_5uA and CONFIG1_SCBCS_24uA were set to 0x40 and 0xC0,
which place the values in the DLY/IDLMOD bit positions (bits [7:6])
instead of the SCBCS field (bits [3:2]).

The header's own mask confirms the correct position:
  CONFIG1_SCBCS_MASK = 0x0C (bits [3:2])

The previous values fail their own mask:
  0x40 & 0x0C = 0x00  (no bits in SCBCS field)
  0xC0 & 0x0C = 0x00  (no bits in SCBCS field)

Corrected per ADS1258 datasheet SBAS297G, Table 18, page 38:
  SBCS[1:0] = 0 (0x00) → Off
  SBCS[1:0] = 1 (0x04) → 1.5µA Source
  SBCS[1:0] = 3 (0x0C) → 24µA Source

Note: 0x40 collides with CONFIG1_DLY_64us defined on line 196 of the
same file, meaning any code using CONFIG1_SCBCS_1_5uA would silently
configure a 64µs switch time delay instead of enabling sensor bias.
Copilot AI review requested due to automatic review settings April 3, 2026 21:38
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Corrects the ADS1258 CONFIG1 sensor-bias current source (SCBCS) field value macros so they map to bits [3:2] (matching CONFIG1_SCBCS_MASK) instead of incorrectly targeting bits [7:6] (IDLMOD/DLY region).

Changes:

  • Fix CONFIG1_SCBCS_1_5uA to 0x04 (SCBCS = 01b at bits [3:2]).
  • Fix CONFIG1_SCBCS_24uA to 0x0C (SCBCS = 11b at bits [3:2]).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants