View previous topic :: View next topic |
Author |
Message |
volcane
Joined: 23 Feb 2008 Posts: 29
|
usart 16F877A |
Posted: Sun Apr 19, 2009 3:46 pm |
|
|
Hi!
I am using a PIC16F877A, as possible checking RCIF? as you are reading RCREG? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Apr 19, 2009 3:54 pm |
|
|
Make a test file. Set the List file format for "Symbolic". Compile the
file and look at the .LST file to see the generated ASM code.
Look at the .LST file below. The kbhit function tests the RCIF bit. The
getc() function also tests the RCIF bit (in a loop) and if it is True, then it
reads the RCREG register.
Code: |
... if(kbhit())
0015: BCF STATUS.RP0
0016: BTFSS PIR1.RCIF // Test the RCIF bit
0017: GOTO 01C
.... c = getc();
0018: BTFSS PIR1.RCIF
0019: GOTO 018 // Stay in a loop until RCIF == 1
001A: MOVF RCREG,W // Then read RCREG
001B: MOVWF c |
Here is the test program:
Code: | #include <16F877.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
//================================
void main()
{
int8 c;
int8 status;
if(kbhit())
c = getc();
while(1);
} |
|
|
|
volcane
Joined: 23 Feb 2008 Posts: 29
|
|
Posted: Sun Apr 19, 2009 4:07 pm |
|
|
Hi!
thanks
without you i do not know how to do :-) |
|
|
|