RS232 for 16F877A


Closed Thread
Results 1 to 8 of 8
  1. #1
    Join Date
    Aug 2007
    Posts
    12

    Default RS232 for 16F877A

    i am not sure how 2 use the interupt and how 2 access the interupt. any guild line on where should i start?
    thank you

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default

    Is the problem serial or interrupt?
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Aug 2007
    Posts
    12

    Default

    both...

    this is what i want to do.

    from pc, i'll sent a txt file using hyper link. then, on my 16f877a side, it will auto recieve with it's uart capability. then, my controller will constantly scan the buffer. if there is something in the buffer, it will halt the program and start recieving the data.

    the problem is that i dono how 2 enable that rs232 interupt, how 2 chk the buffer and how 2 read the buffer.

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default

    I know a little about interrupts but I have not triggered one with a serial input yet. Sorry .
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    May 2006
    Location
    Del Rio, TX, USA
    Posts
    343

    Default

    As for the interrupts, the best place to start is with Darrel Taylor's Instant Interrupts. These allow for simplified creation of interrupts for PBP programs. Do a search on the forum for more on using these. Here is the "Mother Thread" for Darrel's work. There is a lot of good info in that thread alone.

    Next, read up on the 16F877A data sheet for the USART so you can understand exactly how it recieves the incoming bytes, and how they are accessed (read). Page 117 (10.2.2) as a basic discription for receiving data. Page 118 gives step-by-step instructions.

    Here is a simplified, basic idea of what needs to happen: As bytes are recieved, they trigger the interrupt (when set up appropriately). The program flow branches to an interrupt handler subroutine (also known as Interrupt Service Routine, ISR), which reads the incoming byte. At this point it can save the byte in a buffer, or deal with it in any number of ways, depending our you requirements. After this is done, the interrupt routine is exited and program flow returns to where it was.

    Not a whole lot of detail (I haven't found the need to use 16F chips, so don't have any specific code for you), I know, but they are some "guide line[s] on where [to] start"

    SteveB
    Last edited by SteveB; - 29th September 2007 at 22:11. Reason: added a Datasheet reference for the USART

  6. #6
    Join Date
    Aug 2007
    Posts
    12

    Default

    thanks. i'll go study abit about that.

  7. #7
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818

    Default

    Hello Spirithunter
    Look at the code in post 16 for how to set up a ring buffer and use hserin, and Darrel's instant interrupts.
    JS
    EDIT: http://www.picbasic.co.uk/forum/showthread.php?t=4972
    DON'T KNOW HOW I OMITTED THIS !
    Last edited by Archangel; - 1st October 2007 at 18:39.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  8. #8
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959

    Default

    Hi Joe,

    I'm confussed. Which Post 16 is that?

    EDIT: Oh that post 16. Now I remember

    Last edited by Darrel Taylor; - 2nd October 2007 at 06:09. Reason: .
    DT

Similar Threads

  1. Universal remote and Rs232
    By Michael in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 7th February 2010, 17:55
  2. UART vs software RS232
    By Michael in forum mel PIC BASIC Pro
    Replies: 27
    Last Post: - 5th September 2008, 18:27
  3. RS232 into 2 PC ports
    By manxman in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 30th August 2008, 13:33
  4. PIC18F4680 to PC via MAX232 (RS232 serial) no output
    By opticsteam1 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 14th April 2008, 20:39
  5. RS232 to Weigand
    By Stevenindon in forum Serial
    Replies: 0
    Last Post: - 6th April 2006, 04:35

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts