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

2 interrupts

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



Joined: 24 Jun 2005
Posts: 5

View user's profile Send private message

2 interrupts
PostPosted: Mon Oct 10, 2005 10:09 am     Reply with quote

hi ,sorry for my english

I'm writing a program for the pic 16f877a and I want to use 2 interrupts(int rda and int rtcc) but the int rda doesn't work , How can I do? Does anyone have a suggestion ?

thanks in advance
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

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

PostPosted: Mon Oct 10, 2005 10:42 am     Reply with quote

Post a small test program.
sander



Joined: 24 Jun 2005
Posts: 5

View user's profile Send private message

PostPosted: Mon Oct 10, 2005 1:56 pm     Reply with quote

the program is similar to this:

#include<16f877A.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP,PUT,BROWNOUT,NOCPD,NOWRT
#use delay(clock=20000000,RESTART_WDT)
#use RS232(BAUD=9600, BITS=8, PARITY=N, XMIT=PIN_C6, RCV=PIN_C7,RESTART_WDT)



#INT_TIMER0
void desplegar()
{
//This function shows on eleven 7-segment display the values of the data that I am procesing, and it works perfectly
}



#INT_RDA

#SEPARATE
void existe_comunicacion()
{

//this function recieves a 7 bytes array and stores it in trama[7]
//using the following routine:


while(i<7)
{
timeout=0;
while(!kbhit() && (++timeout< (tiempo_de_espera*100)))
{delay_us(10);}

if(kbhit())
{
trama[i]=getc();
i=i+1;
bandera=1; }
else
{
i=8;
bandera=0; } //cambiar a 0
}

//bandera tells me wether or not the 7 bytes has arrived
}


void main()
{


set_timer0(0);
setup_counters( RTCC_INTERNAL, RTCC_DIV_16 | RTCC_8_BIT); //RTCC_DIV_64 para 20M
//RTCC_DIV_32=1,6ms
enable_interrupts(INT_RTCC); //RTCC_DIV_8 para 4M
enable_interrupts(INT_RDA);
enable_interrupts(GLOBAL);

while(1)
{
//The pic does all here (i.e read a keyboard chance values,etc)

}
}

Actually, the program has more than 1500 lines I probed the comunication routines alone and they work, the problem is when I put the 2 interrupts together, the program doesn't do the comunication.

sander.
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

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

PostPosted: Mon Oct 10, 2005 1:59 pm     Reply with quote

Probably UART overflow. Try this

#use RS232(BAUD=9600, BITS=8, PARITY=N, XMIT=PIN_C6, RCV=PIN_C7,RESTART_WDT,ERRORS)
sander



Joined: 24 Jun 2005
Posts: 5

View user's profile Send private message

PostPosted: Mon Oct 10, 2005 2:12 pm     Reply with quote

there isn't a uart overflow because I tested all the communication routines that I made one by one and they work well, in addition when I disable the rtcc interrupt the communication works well

sander
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

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

PostPosted: Mon Oct 10, 2005 2:14 pm     Reply with quote

sander wrote:
there isn't a uart overflow because I tested all the communication routines that I made one by one and they work well, in addition when I disable the rtcc interrupt the communication works well

sander


Sounds exactly like an overflow problem. Just try it!
sander



Joined: 24 Jun 2005
Posts: 5

View user's profile Send private message

PostPosted: Mon Oct 10, 2005 2:33 pm     Reply with quote

I can't believe it but now it is working better, but just arrive well 3 bytes but I think that I can solve that , thank you very much

sander
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

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

PostPosted: Mon Oct 10, 2005 2:35 pm     Reply with quote

Interrupts need to be short. Putting delays in an interrupt routine can cause you problems. I suspect that you Timer0 interrupt routine is too long causing you to miss the communication interrupt and thus get the overflow problem.
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