Menu

Max characters/second through usart

Help
2019-09-14
2019-09-14
  • Jim giordano

    Jim giordano - 2019-09-14
     
  • Jim giordano

    Jim giordano - 2019-09-14

    I've been running some throughput tests between a pic and a pc. I'm trying out a new CP2101 cheapie board I just got.

    The question is, what determines the maximum characters per second you can transfer? By my calculations, I'm not getting anywhere near what I should running at 32mhz. I'm using a 16F18324 pic. The results I'm getting are:

    at baud
    ' 19200 => 750 characters per second
    ' 38400 => 930 cps
    ' 57600 => 1050 cps
    '115200 => 1160 cps
    '230400 => 1220 cps
    '460800 => 1260 cps

    I'm probably not setting up the usart right or something so any suggestions will be greatly appreciated!

    The full program:

    #chip 16F18324,32
    #config RSTOSC=HFINT32, MCLRE=OFF, FEXTOSC=OFF , CLKOUTEN=OFF ', WRT=OFF, CPD=on
    
    #startup InitPPS, 85
    Sub InitPPS
      UNLOCKPPS
      RXPPS = 0x0015    'RC5 > RX
      RA2PPS = 0x0014    'TX > RA2
      LOCKPPS
    End sub
    
    #define USART_BAUD_RATE 460800 '115200 230400 460800 921600 57600 38400 28800 19200
    #define USART_TX_BLOCKING
    ' 19200 =>  750 characters per second
    ' 38400 =>  930 cps
    ' 57600 => 1050 cps
    '115200 => 1160 cps
    '230400 => 1220 cps
    '460800 => 1260 cps
    
    DIR PORTA.4 IN  ' 32k crystal
    DIR PORTA.5 IN  ' 32k crystal
    
    InitTimer1 sosc,0 ' 32768 crystal time keeper
    
    On Interrupt Timer1Overflow Call CheckClock
    
    #define prt HSerPrint
    #define lines 50
    dim cc,nn,lin,ii,jj as long
    
    CheckClock  ; set timer to 1 second
    cc= 0
    StartTimer 1
    
    for lin= 1 to lines
      for nn=32 to 126: prt chr(nn): next nn
      for nn=128 to 255: prt chr(nn): next nn
      HSerPrintCRLF
     next lin
    StopTimer 1
    
    jj=TMR1H-128
    ii=cc
    jj=(jj*1000)/128
    prt ii:prt ".":prt jj:prt " seconds, "
    nn=(225000*lines)/(ii*1000+jj) ' 225 chars/line * lines * 1000  /  ms
    prt nn:prt " characters per second at ":prt USART_BAUD_RATE:prt " baud "
    do :loop
    
    sub CheckClock
      cc=cc+1
      TMR1H = 128 ' set up for one second delay
      TMR1L = 0
    end sub
    
     
  • Anobium

    Anobium - 2019-09-14

    i think it will be the delay.

    USART_DELAY

    This is the delay between characters.

    Deaults to 1 ms

    To disable this delay between characters …​ Use #define USART_DELAY 0 MS, or, To disable this delay between characters …​ Use #define USART_DELAY OFF

     
  • Jim giordano

    Jim giordano - 2019-09-14

    That did it. At 460800 baud it filled the screen instantaneously.
    Clearly I should have asked days ago.
    Thanks!

     
  • Jim giordano

    Jim giordano - 2019-09-14

    Is is possible that with USART_DELAY OFF and USART_DELAY 0 MS, Timer1 is not getting it's interrupts? The program clearly takes seconds to run, but the timer only got updated a small amount.

     
  • Jim giordano

    Jim giordano - 2019-09-14

    Never mind, I just had to add a do loop to wait for the timer to actually start before starting to time the code.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.