Replies: 1 comment
-
Duplicate of https://github.com/orgs/stm32duino/discussions/2778 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am trying to get ADC working on Weact G474CE long board and there is only 0 returned from analogread.
The code:
`void setup() {
// put your setup code here, to run once:
delay(20);
Serial.begin(115200);
while (!Serial);
delay(500);
Serial.println();
Serial.print("SETUP: ");
Serial.println(BOARD_NAME);
Serial.print("FLASH->ACR = 0x");Serial.println(FLASH->ACR,HEX);
Serial.print("SystemCoreClock: ");
Serial.println(SystemCoreClock);
Serial.print("F_CPU: ");
Serial.println(F_CPU);
Serial.printf("RCC_CR 0x%08X \n", RCC->CR);
Serial.printf("RCC_CFGR 0x%08X \n", RCC->CFGR);
Serial.printf("RCC_PLLCFGR 0x%08X \n", RCC->PLLCFGR);
pinMode(PA3, INPUT_ANALOG);
}
void loop() {
// put your main code here, to run repeatedly:
static int outval = 0;
analogWrite(A2,outval); /* full range 0-255 /
outval += 10;
if (outval > 255) outval = 0;
delay(10);
String message = "Vb = ";
//int VB= analogRead(PA3); / full range 0-1024 /
int VB= digitalRead(PA10); / full range 0-1024 */
//int VA= analogInputToDigitalPin(p)
//message += VB;
//Serial.println(analogRead(PA0));
Serial.println(VB);
//Serial.println(message);
delay(100);
}`
Using digital read I get 0 or 1 depending on the pulse from A2, so pin works in digital mode but only 0 in analog mode.
I can see the varying pulswidth on A2 with a DSO.
I have tried connecting the analog input to 3.3V, no result.
I have tried on 2 boards same result.
I have tried pins A0 to A10, using their PAx as well.
I have tried INPUT and INPUTANALOG on the pinmode.
The VREF pin is connected to 3.3V or not with no change.
What am I doing wrong, or what can I do to get the ADC to return a value?
Beta Was this translation helpful? Give feedback.
All reactions