Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Tools
Old 26th January 2009, 03:00 PM   #1
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."
DexterLB is offline  
Old 26th January 2009, 05:21 PM   #2
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
Nigel Goodwin is offline  
Old 26th January 2009, 06:02 PM   #3
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
Mike, K8LH is offline  
Old 26th January 2009, 06:41 PM   #4
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."
DexterLB is offline  
Old 26th January 2009, 07:06 PM   #5
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.
Mike, K8LH is offline  
Reply

Tags
interrupt, pic12f629, soft usart

Thread Tools
Display Modes


Similar
Title Starter Forum Replies Latest
Anyone Using a PIC12F629 and C? mrmonteith Micro Controllers 16 23rd March 2008 06:27 PM
PIC12f629 + motor nuttaphong191 Electronic Projects Design/Ideas/Reviews 1 27th May 2007 01:18 PM
ARGH! PIC12F629 help please =D Peter_wadley Micro Controllers 37 27th May 2007 05:58 AM
AVR USART by software? MrMikey83 Micro Controllers 1 15th March 2006 10:02 PM
software usart Ricardoco Electronic Projects Design/Ideas/Reviews 13 30th November 2005 12:14 AM



All times are GMT. The time now is 09:38 PM.


Electronic Circuits  |  Learning Electronics
eXTReMe Tracker