Wait Serial1 transmission to complete CODE

Post here all questions related to LibMaple core if you can't find a relevant section!
cpt_cyp
Posts: 8
Joined: Fri May 01, 2020 10:43 pm

Wait Serial1 transmission to complete CODE

Post by cpt_cyp »

Hi

I am using rs485 protocol to communicate other modules on Arduino Mega.
But STM32F103 (bluepill+bootloader), i cant send any serial1 message. i am getting messages well.
This is my Arduino Mega working code:

Code: Select all

digitalWrite(enablePin, HIGH);     //high signal to send data
 Serial1.println("message"); //message
    while (!(UCSR1A & (1 << UDRE1)))  // Wait for empty transmit buffer
    UCSR1A |= 1 << TXC1;  // mark transmission not complete
    while (!(UCSR1A & (1 << TXC1)));   // Wait for the transmission to complete
digitalWrite(enablePin, LOW);     //data send
I cant compile this section is giving me error:

Code: Select all

 while (!(UCSR1A & (1 << UDRE1)))  // Wait for empty transmit buffer
 UCSR1A |= 1 << TXC1;  // mark transmission not complete
 while (!(UCSR1A & (1 << TXC1)));   // Wait for the transmission to complete
how can i deal ??
User avatar
fpiSTM
Posts: 1745
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Wait Serial1 transmission to complete CODE

Post by fpiSTM »

Those definitions are not part of STM32.
They are for AVR.
Try using

Code: Select all

 Serial.flush();
cpt_cyp
Posts: 8
Joined: Fri May 01, 2020 10:43 pm

Re: Wait Serial1 transmission to complete CODE

Post by cpt_cyp »

I tried but not working and also code stucked on Serial1.flush();
stas2z
Posts: 131
Joined: Mon Feb 24, 2020 8:17 pm
Answers: 8

Re: Wait Serial1 transmission to complete CODE

Post by stas2z »

it's working and shouldn't stuck
User avatar
fpiSTM
Posts: 1745
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Wait Serial1 transmission to complete CODE

Post by fpiSTM »

Well, if it's not work then share your full sketch and also all relevant info: stm32 core used, ide version, ....
cpt_cyp
Posts: 8
Joined: Fri May 01, 2020 10:43 pm

Re: Wait Serial1 transmission to complete CODE

Post by cpt_cyp »

---------------
Last edited by cpt_cyp on Tue Aug 24, 2021 10:39 pm, edited 1 time in total.
User avatar
fpiSTM
Posts: 1745
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Wait Serial1 transmission to complete CODE

Post by fpiSTM »

Ok. Thanks.
So you used libmaple core and I don't know if flush is implemented.
I move this to the libmaple core subforum
stas2z
Posts: 131
Joined: Mon Feb 24, 2020 8:17 pm
Answers: 8

Re: Wait Serial1 transmission to complete CODE

Post by stas2z »

@fpiSTM it's implemented in libmaple/roger's core and do the same, at least last time ive tried it with rs485 using roger's core
User avatar
fpiSTM
Posts: 1745
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Wait Serial1 transmission to complete CODE

Post by fpiSTM »

I thouh it was ;)
cpt_cyp
Posts: 8
Joined: Fri May 01, 2020 10:43 pm

Re: Wait Serial1 transmission to complete CODE

Post by cpt_cyp »

so if two cores are same why serial.flush command stuck.
i didnt try any other cores.
and also tried delaymicrosecond but no way..
Post Reply

Return to “General discussion”