-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cpu, cc2538: add low-level adc periph driver #7327
Conversation
1683564
to
0326e52
Compare
I see some commits which at a first sight don't belong to thus PR. Something wrong with the rebase? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Somehow, ADCs on the Re-Mote board do not work properly. ADC pins do not match with the terminal output. In addition, low level is displayed incorrectly (> 4000). Tested with "tests/periph_adc", 12 bit resolution.
.res = ADC_RES_12BIT, | ||
} | ||
}; | ||
#ifdef __cplusplus |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blank line?
.res = ADC_RES_12BIT, | ||
} | ||
}; | ||
#ifdef __cplusplus |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blank line?
cpu/cc2538/include/periph_cpu.h
Outdated
#define SOC_ADC_ADCCON3_ECH 0x0000000F /**< Single channel select */ | ||
/** @} */ | ||
|
||
/** @name SOC_ADC_ADCCONx registers field values |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line break?
cpu/cc2538/include/periph_cpu.h
Outdated
*/ | ||
#define SOC_ADC_ADCCON_REF SOC_ADC_ADCCON_REF_INT | ||
|
||
/** @name SOC_ADC_ADCCON3 register bit masks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line break?
0326e52
to
0f13d79
Compare
Fixed the miss matched ADC lines, however, the output looks still a bit weird. That is, with 10Bit resolution applying HIGH on any channel results in 511 and applying GND result in 0 on ADC3 (as expected) but 1023 on ADC1 and ADC2. |
btw. rebased onto #7316, to make merge easier |
0f13d79
to
e2efe32
Compare
|
e2efe32
to
f555442
Compare
this one would be ready - for testing and merging, that is 😉 On the remotes the actual values are a bit weird, which means with 10Bit resolution ADC1 reads |
*/ | ||
#define HAVE_ADC_RES_T | ||
typedef enum { | ||
ADC_RES_6BIT = (0xa00), /**< not supported by hardware */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@A-Paul this defines are used in similar fashion throught RIOTs ADC low-level drivers. I don't know why its done this way, but this here is consistent with other drivers.
adapted boards are: cc2538dk, openmote-cc2538, remote-pa, remote-reva, and remote-revb.
f555442
to
2806484
Compare
@A-Paul can you please test again with your cc2538dk board - I think I fixed it, though its a bit hacky as RIOT does not support differential ADC readings (yet). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After the last tweaks the output on a cc2538dk shows 1023 for a input voltage equal to VDD.
Dividing the voltage 1:1 with a resistor network gives ~505. So, the readout is almost sane.
I appreciate the comments giving a hint to the irregularities.
ACK regarding this board.
@dnahm if you can spare some time on testing to verify this, too - would be great thanks! |
I tested with tests/periph_adc on a *remote-reva. Voltages taken from Pins 9,10,31. "ADC3" |
as said offline, there is some voltage divider (or so) on ADC3 which make this ADC behave different from ADC1 and ADC2 - I don't know/remember the details right now, maybe @PeterKietzmann can shed some light? |
Hello! sorry I have been absent, new job and less bandwidth... |
@alignan so taking @A-Paul values for ADC3 with 5V = However, I would have expected, that applying 5V would give max value ( |
I seem to recall there was a change in the impedance value for the ADC from Adding also @amejias (from Zolertia) as they might be more available to test |
Still, the ADC3 issue should not block this driver in general. That is better to have a mostly working ADC driver than none, at all 😉 right? |
btw. @alignan
|
oops, wrong button ... need ☕️ anyway, what I meant: we test with remote revb here |
Agree, the driver is in a better shape than it were on the original PR, happy with the results :-) |
thanks for the 💐 - so I'll merge this, but we still should clarify the results for ADC3. |
specifically the weird readings only apply for the remotes and ADC3 there on, cc2538dk seems on affected and for openmote-cc2538 we need test results from someone with the board available. |
started from #5823 (and makes that obsolete), but rewrote ADC based on TI periphal driver library. Adds also board periph confs for all CC2538 based boards, including SAUL adaption for Zolertia Remotes.
Requires #7320 (and all sub PRs dependencies of that one).