Menu

usart.h

Help
2007-10-09
2013-05-30
  • Nobody/Anonymous

    Am I wrong or is the usart.h library empty? All I see are routine prototypes. If it was there, what is UsartStatus?

     
    • Hugh Considine

      Hugh Considine - 2007-10-10

      usart.h is indeed empty.

       
    • Nobody/Anonymous

      Enclosed is a simple USART driver file that does not use error checking. These emulate the USART routines in Oshonsoft Pic_Sim_Ide Basic.

      #define TXtris TRISC.6
      #define RXtris TRISC.7
      #define SPBRG_Val 64

      sub initusart
      set TXtris on        'set TX port pin output
      set RXtris on        'set RX port pin output
      SPBRG = SPBRG_Val
      TXSTA=0x24            'enable transmission and BRGH=1
      RCSTA=0x90            'enable serial port and receive
      end sub

      sub HserTX (xmitdata)
      LoopTransmit:
      IF PIR1.TXIF OFF THEN goto LoopTransmit 'check if transmitter is busy 
      TXREG = xmitdata 'transmit data
      end sub

      sub HserTX_Print(PrintData$)
      PrintLen = PrintData(0)
      if PrintLen = 0 then exit sub
      for SysPrintTemp = 1 to PrintLen
      HserTX(PrintData(SysPrintTemp))
      next
      end sub

      function HserRX 'check if data received, and if so, return data
      IF PIR1.RCIF OFF THEN GOTO endreceiveserial
      HserRX = RCREG
      GOTO successreceiveserial
      endreceiveserial:
      HserRX = 0 
      successreceiveserial:
      end function

      function HserIn
      LoopRec:
      IF PIR1.RCIF OFF THEN GOTO LoopRec
      HserIn = RCREG
      end function

       

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.