How to use USB pins?

Post here all questions related to LibMaple core if you can't find a relevant section!
Post Reply
forfrends
Posts: 14
Joined: Mon Jan 20, 2020 10:49 am

How to use USB pins?

Post by forfrends »

Hello. I encountered a restriction on the use of pins. I need to use USB pins (PA11 and PA12) for my own purposes. But if I write a simple sketch, then the pin switching does not happen:

Code: Select all

#define Pin1 PA11
#define Pin2 PA12

void setup() {
    pinMode(Pin1, OUTPUT);
    pinMode(Pin2, OUTPUT);
}

void loop() {
    digitalWrite(Pin1, LOW);
    digitalWrite(Pin2, LOW);
    delay(1000);
    digitalWrite(Pin1, HIGH);
    digitalWrite(Pin2, HIGH);
    delay(1000);
}
It seems that somewhere these pins are used, possibly USB Serial. Can I use these pins somehow?
by stevestrong » Sun Apr 19, 2020 3:38 pm

Code: Select all

Serial.end();
Go to full post
mrburnette
Posts: 633
Joined: Thu Dec 19, 2019 1:23 am
Answers: 7

Re: How to use USB pins?

Post by mrburnette »

From: http://docs.leaflabs.com/docs.leaflabs.com/index.html GPIO Information

Pin D23 (PA12) is the USB D+ line, and D24 (PA11) is the USB D- line. To use them as GPIOs, your program will need to disable SerialUSB first. Be aware, however, that disabling SerialUSB means that the bootloader won’t work properly, and you’ll need to use Perpetual Bootloader Mode to make your next upload.
Ray
forfrends
Posts: 14
Joined: Mon Jan 20, 2020 10:49 am

Re: How to use USB pins?

Post by forfrends »

Thanks!
Can you tell me how to disable SerialUSB?
stevestrong
Posts: 502
Joined: Fri Dec 27, 2019 4:53 pm
Answers: 8
Location: Munich, Germany
Contact:

Re: How to use USB pins?

Post by stevestrong »

Code: Select all

Serial.end();
forfrends
Posts: 14
Joined: Mon Jan 20, 2020 10:49 am

Re: How to use USB pins?

Post by forfrends »

Thank you, you helped me a lot!
Post Reply

Return to “General discussion”