Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PIC12F629 software USART

Status
Not open for further replies.

DexterLB

New Member
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?
 
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.
 
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
 
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 ;)
 
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.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top