|
|
View previous topic :: View next topic |
Author |
Message |
GQ Guest
|
#INT_RDA |
Posted: Tue Sep 20, 2005 12:10 am |
|
|
Would somebody suggest why this code wont work, cuz it aint?
Im printing a character upon a serial interrupt
Code:
********************************
#include <16F877a.h>
#device *=16
#include<stdlib.h>
#fuses XT,NOWDT,NOLVP
#use delay (clock=4000000)
#use rs232(baud=4800,xmit=PIN_A1,rcv=PIN_B1,parity=N)
char ch;
int i;
#INT_RDA
void serial_isr()
{
putc('a');
}
void main()
{
enable_interrupts(INT_RDA);
enable_interrupts(GLOBAL);
while(1)
{
delay_ms(333);
}
} |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Sep 20, 2005 12:26 am |
|
|
#int_rda only works with the hardware UART.
If you move your RS-232 to pins C6 and C7, then you can use it.
Example:
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS) |
|
|
GQ Guest
|
Re: #INT_RDA |
Posted: Tue Sep 20, 2005 1:38 am |
|
|
Thanx,programs working. but it continously prints 'a' once a key is pressed. That means the key acts as just another key triggering the isr. Since it keeps on printing 'a' without getting out of the isr(no delay of while loop), it also means the isr interrupt flag bit is not going low. Am i right?
*****************
Code:
#include <16F877a.h>
#device *=16
#include<stdlib.h>
#fuses XT,NOWDT,NOLVP
#use delay (clock=4000000)
//#use rs232(baud=4800,xmit=PIN_A1,rcv=PIN_B1,parity=N)
#use rs232(baud=4800, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
char ch;
int i;
#INT_RDA
void serial_isr()
{
/*
ch=getc();
if(ch=='A')
putc('a');
else if(ch=='B')
putc('b');
else
putc('E');
*/
putc('a');
}
void main()
{
enable_interrupts(INT_RDA);
enable_interrupts(GLOBAL);
while(1)
{
delay_ms(1000);
}
} |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Sep 20, 2005 1:45 am |
|
|
You must actually 'get' the character while inside the isr. Do this with
the getc() function. You have it commented out. |
|
|
GQ Guest
|
|
Posted: Tue Sep 20, 2005 3:14 am |
|
|
thanx |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|