Menu

usart baud 115200

Help
2009-10-21
2013-05-30
  • Nobody/Anonymous

    I am using the following
    #chip 16F916, 20 'mhz
    #config  MCLRE=off, WDT=off
    #define USART_BAUD_RATE 115200
    #define USART_BLOCKING
    InitUsart
    On Interrupt UsartRX1Ready call get_data
    lcdcon = 0
    dir portc.7 in 'serial rx p18
    dim temp as byte
    dim loc as byte

    sub get_data
    If RCIF On Then serdata = RCREG
    temp = serdata
    epwrite loc, temp
    loc = loc + 1
    end sub

    I can not get good communication at 115200 baud, i have heard there are some issues with the calculations in gcbasic for that speed, is this true? what fixes it?

     
  • Nobody/Anonymous

    I'm using 115200 with a PIC18F4455 and it seems to work fine.
    Beware of EPWrites inside the interrupt service routine. Each one takes a couple ms to complete, and at this speed it could cause you to miss the next character.

    Joe

     
  • Nobody/Anonymous

    Have a look to the generated asm, at sub: INITUARST, it should be like this (for 115200 at 20 MHz):

        ;********************************************************************************

        INITUSART
        movlw 10
        banksel SPBRG
        movwf SPBRG

    If you have:

        ;********************************************************************************

        INITUSART
        movlw 9
        banksel SPBRG
        movwf SPBRG

    Then perhaps this is your problem ( it was mine), the theoretical value toi SPBRG is 9.85, but this is "cutted" to 9, when it should be rounded to 10.

    To fix this you can edit: GcBasic/include/lowlevel/usart.h line 89 and add a "+0.5"

    'Get high and low bytes

    SPBRGL_TEMP = Int(SPBRG_TEMP + 0.5) And 255

     

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.