+ Reply to Thread
Results 1 to 5 of 5

Thread: PIC12F629 software USART

  1. #1
    DexterLB Newbie
    Join Date
    Jan 2009
    Location
    Samokov, Bulgaria; GP:42°19'53"; 23°33'40"
    Posts
    33

    Question PIC12F629 software USART

    Hello. I'm using Hi-tech PICC pro and PIC12F629. I want to make a simple usart communication subroutine: I've set Timer0 to make an interrupt every 250 miliseconds. In that interrupt I want to check whether there's an incoming byte from RS232. If there isn't - exit the interrupt and resume normal work. If there is - read the byte in a variable, and start a dialog subroutine. The thing I can't make is the interrupt - how do I check if there's an incoming byte, when I use the soft usart?
    "Humans are stupid."


  2. #2
    Super Moderator Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent
    Join Date
    Nov 2003
    Location
    Derbyshire, UK
    Posts
    29,796

    Default

    Can't help you with C, but a 250mS timer routine would be useless, you could (and would) miss loads of data in the 250mS.

    If you want interrupt driven routines then best to choose a PIC with a hardware UART, otherwise you need to check for the presence of a start bit VERY much more often, depending on baud rate.

    A software option would require an interrupt as the start bit begins, which could be done if the PIC supports interrupt from a pin change - this is usually available on PortB (interrupt on change on portb). Check the datasheet, see what the 12F629 has got.
    PIC programmer software, and PIC Tutorials at:
    http://www.winpicprog.co.uk

  3. #3
    Mike, K8LH Excellent Mike, K8LH Excellent Mike, K8LH Excellent Mike, K8LH Excellent Mike, K8LH Excellent Mike, K8LH Excellent Mike, K8LH Excellent
    Join Date
    Jan 2005
    Location
    Michigan, USA
    Posts
    2,522

    Default

    I posted an interrupt driven 9600 baud half-duplex demo' for the 12F675 here but it's written in assembly language, sorry. It uses IOC (interrupt on change) to detect the start bit leading edge then uses 104 usec interrupts to clock in the data bits.

    Regards, Mike

  4. #4
    DexterLB Newbie
    Join Date
    Jan 2009
    Location
    Samokov, Bulgaria; GP:42°19'53"; 23°33'40"
    Posts
    33

    Default

    Hmm, OK. Today I thinked about it and figured out a way how to make it without an interrupt. Thank you for the help anyway
    "Humans are stupid."

  5. #5
    Mike, K8LH Excellent Mike, K8LH Excellent Mike, K8LH Excellent Mike, K8LH Excellent Mike, K8LH Excellent Mike, K8LH Excellent Mike, K8LH Excellent
    Join Date
    Jan 2005
    Location
    Michigan, USA
    Posts
    2,522

    Default

    You should be able to do it without interrupts. You just need to detect the start bit and then clock in data bits by sampling them in the middle of each bit.

    Sorry I can't help you out with your particular version of C.

+ Reply to Thread

Similar Threads

  1. Anyone Using a PIC12F629 and C?
    By mrmonteith in forum Micro Controllers
    Replies: 16
    Latest: 23rd March 2008, 05:27 PM
  2. PIC12f629 + motor
    By nuttaphong191 in forum Electronic Projects Design/Ideas/Reviews
    Replies: 1
    Latest: 27th May 2007, 12:18 PM
  3. ARGH! PIC12F629 help please =D
    By Peter_wadley in forum Micro Controllers
    Replies: 37
    Latest: 27th May 2007, 04:58 AM
  4. AVR USART by software?
    By MrMikey83 in forum Micro Controllers
    Replies: 1
    Latest: 15th March 2006, 09:02 PM
  5. software usart
    By Ricardoco in forum Electronic Projects Design/Ideas/Reviews
    Replies: 13
    Latest: 29th November 2005, 11:14 PM

Tags for this Thread