|
|
View previous topic :: View next topic |
Author |
Message |
Imanjl
Joined: 15 Nov 2004 Posts: 42
|
INT_RDA fails when using LCD & delay_ms() function!!!! |
Posted: Tue Aug 08, 2006 3:20 pm |
|
|
Hi guys,,
Im using PIC16f877A in some kind of MIDI Controller project,,,I completely confused ..when I send the data to rx pin of 16f877 ,Int_rda doesnt call. with deleting the delay_ms() or also Lcd_putc("test") the problem solve,,,
I knew that interrupt calls during the delay execution without using Lcd_putc("test") in the rda_isr() and lcd functions work well without using delay_ms in the main code too .but I want to use both.
whats the problem,,,,help me plz,
Code: |
#device adc=8
#use delay(clock=10000000)
#fuses NOWDT,HS, NOPUT, NOPROTECT, NODEBUG, BROWNOUT,NOLVP, NOCPD, NOWRT
#use rs232(baud=31250,parity=N,xmit=PIN_c6,rcv=PIN_c7,bits=8)
#USE FASt_IO(C)
#USE FASt_IO(D)
#include <LCD>
#int_RDA
RDA_isr()
{
int data,i;
if (1==1) {data=getc();
putc(data);}
lcd_putc("test"); ////problem**
}
void main(){
SET_TRIS_C(0b10100000);
enable_interrupts(INT_RDA);
enable_interrupts(GLOBAL);
lcd_init() ;
loop :
delay_ms(500); //problem**
goto loop;
}
|
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Aug 08, 2006 3:39 pm |
|
|
The compiler has inserted code to disable interrupts while the delay_ms()
function is being executed.
You can fix this by adding a 2nd #use delay statement right before main()
as shown below:
Quote: |
#use delay(clock=10000000)
void main(){
SET_TRIS_C(0b10100000);
enable_interrupts(INT_RDA);
enable_interrupts(GLOBAL |
However, I believe you may still have problems with the isr because
you're doing an lcd_putc() for several characters. Depending on
how fast that code takes to execute, you may miss incoming chars
from your UART. |
|
|
Imanjl
Joined: 15 Nov 2004 Posts: 42
|
|
Posted: Tue Aug 08, 2006 4:02 pm |
|
|
tnx,,,It works now,,,,the problem solved by inserting #use delay(clock=10000000) ...
I try delay_US and see that the problem is just with delay_MS i dont know why compiler dont inserted code to disable interrupts in this case .
I dont have any problem with uart buferring cause it is not all my code and i send a few line ,,,,everything is ok thanks alot helping me |
|
|
|
|
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
|