We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
PA7 digitalRead always returns 0 after Serial.begin() + Serial.end()
Here is the code to reproduce the issue:
void setup() { Serial.begin(115200); } void loop() { Serial.println(millis()); Serial.end(); pinMode(PA7, INPUT_PULLUP); int status = digitalRead(PA7); Serial.begin(115200); Serial.println(status); delay(200); }
I guess Serial.end() should release the resources and bindings so PA7 should be available to read?
The text was updated successfully, but these errors were encountered:
I found that *void serial_free(serial_t obj) does not perform a correct cleanup.
So after Serial.end() I just added
Pinmux_Config((PinName)g_APinDescription[LOG_TX].pinname, PINMUX_FUNCTION_GPIO);
Here is the demo code:
#define RESET_PIN PA7 void setup() { Serial.begin(115200); pinMode(LED_G, OUTPUT); pinMode(LED_R, OUTPUT); digitalWrite(LED_G, LOW); digitalWrite(LED_R, LOW); } unsigned long resetTimerStart; unsigned long resetTimerEnd; void loop() { Serial.println(millis()); Serial.end(); Pinmux_Config((PinName)g_APinDescription[LOG_TX].pinname, PINMUX_FUNCTION_GPIO); pinMode(RESET_PIN, INPUT); if (digitalRead(RESET_PIN) == LOW) { digitalWrite(LED_G, HIGH); resetTimerStart = millis(); while(digitalRead(RESET_PIN) == LOW); resetTimerEnd = millis(); } digitalWrite(LED_G, LOW); if (resetTimerEnd - resetTimerStart >= 5000) { digitalWrite(LED_R, HIGH); } Serial.begin(115200); Serial.print("Factory settings button was pressed for "); Serial.print(resetTimerEnd - resetTimerStart); Serial.println(" milliseconds."); delay(200); }
Sorry, something went wrong.
No branches or pull requests
PA7 digitalRead always returns 0 after Serial.begin() + Serial.end()
Here is the code to reproduce the issue:
I guess Serial.end() should release the resources and bindings so PA7 should be available to read?
The text was updated successfully, but these errors were encountered: