Android Question Serial too fast

Discussion in 'Android Questions' started by freetoair, Sep 3, 2015.

  1. freetoair

    freetoair Member Licensed User

    Serial port on Android has a very short stop start time between two bytes . I have a problem that the microcontroller does not have time to recognize the stop bit of the byte just received from the start bit of the next. Is there any way to extend this time?

    Sub konverzija (Value As Int)


    Do Until (Value < 100)
    Value = Value - 100
    outpkt(2) = outpkt(2)+1
    outpkt(2) =Bit.ShiftLeft(outpkt(2),4)
    outpkt(2) = Bit. Or(outpkt(2),komanda)


    Do Until (Value < 10)
    Value = Value - 10
    outpkt(1) = outpkt(1)+1
    outpkt(1) =Bit.ShiftLeft(outpkt(1),4)

    outpkt(0) = Value
    outpkt(0) = Bit. Or(outpkt(1),outpkt(0))

  2. Erel

    Erel Administrator Staff Member Licensed User

    Please use [code]code here...[/code] tags when posting code.

    You can use a timer to add a delay.
    JordiCP likes this.
  3. JordiCP

    JordiCP Well-Known Member Licensed User

    I have never worked with Android serial port. But you could try to change the settings from 8N1 (or whatever you have now) to 8N2

    This way, the stop bit period will be doubled.
  4. DavideV

    DavideV Active Member Licensed User

    As Erel said, send a byte at a time using a timer .
    But if your microcontroller has an hardware serial port (not simulated) then consider to use that port/pins.
    also use interrupts on hardware serial port to save received bytes to a buffer . By this way you should be able to send more bytes at a time...
    KitCarlson likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice