USART working example

Aaron G.
2011-08-08
2013-05-30
  • Aaron G.
    Aaron G.
    2011-08-08

    Just a working example of USART communication, I could never figure out how the usart.h file calculates the baud rate so I just adjusted BRGH and SPBRG manually.

    Using MAX232, and putty software on the PC with N-8-1 protocol

    {'Serial communication with PIC16F88 made by aarongarzaATgmail.com
    'Using MAX232 to communicate and a prolific usb to serial adapter, Putty software on PC
    'Putty Settings - COM15 (check device manager for your own port), 2400 bps, parity none, 8 data bits, 1 stop bit, Local Echo ON
    #chip PIC16F88,8
    #config OSC=XT, PWRTE=ON, BODEN=OFF, CCP1=RB3, CP=OFF, MCLR=OFF, WDT=OFF
    #define GREENLED PORTA.1
    #define REDLED PORTA.0
    #define RX PORTB.2
    #define TX PORTB.5
    dim messager
    dir GREENLED out
    dir REDLED out
    dir RX in
    dir TX out
    SET GREENLED ON
    wait 500 ms
    SET GREENLED OFF
    InitUSART
    BRGH = 0
    SPBRG = 51
    SET REDLED ON
    Communicate:
    messager = HSerReceive
    HSerSend(HSerReceive)
    flashled
    GOTO Communicate
    Sub flashled
    REPEAT 5    
        SET GREENLED ON
        wait 20 ms
        SET GREENLED OFF
        wait 20 ms
    END REPEAT
    Return}
    
     
  • Hi, I want to use "usart.h" with a 12F683. Can I do? and how?
    Alternatively, Is there a software USART?