CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

INT_RDA fails when using LCD & delay_ms() function!!!!

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Imanjl



Joined: 15 Nov 2004
Posts: 42

View user's profile Send private message Send e-mail Yahoo Messenger

INT_RDA fails when using LCD & delay_ms() function!!!!
PostPosted: Tue Aug 08, 2006 3:20 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Aug 08, 2006 3:39 pm     Reply with quote

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

View user's profile Send private message Send e-mail Yahoo Messenger

PostPosted: Tue Aug 08, 2006 4:02 pm     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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