PDA

View Full Version : RS232 for 16F877A



SpiritHunter
- 28th September 2007, 05:09
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

mackrackit
- 28th September 2007, 16:03
Is the problem serial or interrupt?

SpiritHunter
- 29th September 2007, 02:56
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.

mackrackit
- 29th September 2007, 15:26
I know a little about interrupts but I have not triggered one with a serial input yet. Sorry .

SteveB
- 29th September 2007, 23:01
As for the interrupts, the best place to start is with Darrel Taylor's Instant Interrupts (http://darreltaylor.com/DT_INTS-14/intro.html). 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" (http://www.picbasic.co.uk/forum/showthread.php?t=3251&highlight=instant+interrupts) 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

SpiritHunter
- 30th September 2007, 04:25
thanks. i'll go study abit about that.

Archangel
- 1st October 2007, 09:55
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 !

Darrel Taylor
- 1st October 2007, 17:25
Hi Joe,

I'm confussed. Which Post 16 is that? :confused:

EDIT: Oh that post 16. Now I remember :)
<br>