Menu

16F628A USART

Help
2008-05-15
2013-05-30
  • Nobody/Anonymous

    Hi, I'm new to GCBASIC (which I think is fantastic BTW). I've made LED's blink etc. Now I want to send serial data to my pc. I've looked at the examples but cannot get my head around how I use the hardware USART on my 16F628A and 16F877A's? Can someone give me a simple example of how I send a stream of "A" in GCBASIC?

     
    • Hugh Considine

      Hugh Considine - 2008-06-02

      Try this:

      https://sourceforge.net/forum/forum.php?thread_id=1664683&forum_id=629990

      I don't know how it will work on the '628 and '877, try it and post if you have any trouble.

      The alternative is to use the software serial routines. This code is quite old now, but should still work:

      #chip 16F628A, 4
      #config Osc = Int

      #define SendAHigh SET PORTB.2 on
      #define SendALow SET PORTB.2 off

      dir PORTB.2 out

      InitSer (1, r2400, WaitForStart+1, 8, 1, none, normal)

      'Startup delay, can probably be removed
      wait 1 sec

      'Send "a"s
      Do
         SerPrint "a"
         Wait 10 ms
      Loop

       

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.