Rules | Recent posts | topic RSS | Search | Register  | Log in

UART

 
Post new topic  Reply to topic    EDAboard.com Forum Index -> Microcontrollers
Author Message
kotsam



Joined: 17 Nov 2005
Posts: 20


Post11 May 2008 18:13   UART

Hi all ,

i would some help please , how can i can i count time between two interrupts , what i mean for example i can have configured interrupt :

btfsc PIR1, RCIF ; Serial Port Reception interrupt

i need to set counter to be 0 when the first interrupt occurs , and when i send something new (second interrupt occurs to know when its occurs), cuz what i want to do ; is if the time differnce between both interrupts less than 4ms to do function and when its greater than 4ms to do something else , how can i do that btw i'm using ASM
Back to top
Kabanga



Joined: 04 Oct 2007
Posts: 46
Helped: 4


Post11 May 2008 18:54   Re: UART

Hi
you didn't mentioned the MCU you're using!

Could you give more explainations (serial data reception at which rate?, what do you mean by "functiion"?) on what you want to do?

The more you give infos the more we can help you !

Best regards
Kabanga
Back to top
kotsam



Joined: 17 Nov 2005
Posts: 20


Post11 May 2008 19:13   Re: UART

thanks very much for the replay ,
I'm using pic18fxx5x, baudrate 9600 , what i want to do exactly , is

to check the time differnce between first serial interrupt occur and second interrupt occur (for serail receive) ,

if the time deffrence between the first interrupt and the second one greater than 4ms , goto to do sort of operation in the program ,

if not goto to back until received two interrupts (serial interrupts) with deffernce of 4ms (simply , i want to receive RCREG with deffernce of 4ms , ) hope this is more clear . (what is required to configure counter which will be 0 at the first interrupt and check this counter at the second interrupt if it less that 4ms repeat and reset counter till counter value will be 4ms ) but i dont know how can i do that by ASM ???

Added after 5 minutes:

BTW ITS 20MHZ OSC
Back to top
Kabanga



Joined: 04 Oct 2007
Posts: 46
Helped: 4


Post11 May 2008 20:23   Re: UART

How are the data beeing sent to the PIC? I mean, is there any software that is sending automatically the data?
It's important to know how the data are sent!
Back to top
kotsam



Joined: 17 Nov 2005
Posts: 20


Post11 May 2008 20:38   Re: UART

yes , there is program sending data , through usart(rs232)
Back to top
Kabanga



Joined: 04 Oct 2007
Posts: 46
Helped: 4


Post12 May 2008 17:46   Re: UART

Have a look at this is piece of code (supposed you did all necessary initializations at a prior level): we are going to the Timer0 in 16-bit mode

movlw 0x0F ;initialize countH
movwf countH

movlw 0xA0 ;initialize countL
movwf countL

movlw 0x08 ;Timer0, 16-bit, int. clock, no prescaler
movwf T0CON ;load T0CON

movlw 0x0F ;initialize the timer0 registers TMR0H and TMR0L. The initialization
movwf TMR0H ;value is 0FA0. That correspond to 4mS delay
movlw 0xA0
movwf TMR0L

bcf INTCON,TMR0IF ;clear timer0 interrupt flag

Loop1:
btfss PIR1,RCIF ;serial data received?
bra Loop1 ;no, wait
bsf T0CON, TMR0ON ;yes, start Timer0
movff RCREG,TEMP1 ;read RCREG to make the way free for the next data
; and clear the RCIF flag

Loop2:
btfss PIR1,RCIF ;serial data received?
bra Loop2 ;no, wait
bcf T0CON,TMR0ON ; yes, stop the Timer0


At that point the Timer0 contain a value that you will compare with countH and countL. If countH=TMR0H AND countL=TMR0L, then the amount of time between
the reception of two serial bytes is equal to 4mS=> means you can implement one or more of your functions right here....

If they are not equal, then you implement another function....

It should be easier to implement.....

I didn't re-read my post. If you have any question, don't hesitate...
Hope it helps.

Best regards
Kabanga
Back to top
Sayem Ahmed



Joined: 07 Apr 2008
Posts: 48
Helped: 3
Location: Dhaka,Bangladesh


Post12 May 2008 18:23   Re: UART

Thanks all

I am also interested in pc interfacing with PIC.
Interruption process seems hard to me.
Back to top
Kabanga



Joined: 04 Oct 2007
Posts: 46
Helped: 4


Post12 May 2008 21:19   Re: UART

There are wonderful people on that forum who are really willing to help. But you don't specify your problem, how can somebody help you?

You said you are "interested in interfacing PIC and PC", well what is the point now? Did you try to interface PIC and PC and you couldn't succed? if yes, so you shoud tell people what you did and which problems you encountered. Then we can help you !!!

But if you are just interested in that item, it's very simple, you can just google !!!
Hope that helped!

Best regeards
Kabanga
Back to top
menz



Joined: 14 Feb 2008
Posts: 51
Helped: 4


Post13 May 2008 9:06   UART

check the configuration bits..
Back to top
Post new topic  Reply to topic    EDAboard.com Forum Index -> Microcontrollers
Page 1 of 1 All times are GMT + 2 Hours


Abuse
Administrator
Moderators
topic RSS 
sitemap