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 disable Interrupts???

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



Joined: 27 Jun 2006
Posts: 3

View user's profile Send private message

INT_rda disable Interrupts???
PostPosted: Fri Jul 28, 2006 8:24 am     Reply with quote

Hello everybody, I have a problem.

I want disable interrupts before make a delay.

I have test some way but not good.

If anyone have any idea???

I have tested:

disable_interrupts(INT_RDA);
delay_ms(500);
enable_interrupts(INT_RDA);

disable_interrupt(GLOBAL);
disable_interrupts(INT_RDA);
delay_ms(500);
enable_interrupt(INT_RDA);
enable_interrupt(GLOBAL);

Please help me I don't know why the interrupts stop?

Thanks
rnielsen



Joined: 23 Sep 2003
Posts: 852
Location: Utah

View user's profile Send private message

PostPosted: Fri Jul 28, 2006 8:41 am     Reply with quote

If you are going to be receiving data via RS232 it will be a very BAD idea to disable the RDA interrupt to do a 500ms delay. You could miss a boat load of data by doing this. I really hate using the delay function unless it's very short. The best way to do a delay is to use one of the timers to count up(or down) and then set a bit that will initiate whatever you wanted to be delayed. Try experimenting with the different timers. There are both 8-bit and 16-bit timers. I use them both quite a bit.

Ronald
lerastas



Joined: 27 Jun 2006
Posts: 3

View user's profile Send private message

thanks
PostPosted: Fri Jul 28, 2006 9:13 am     Reply with quote

Yes I have already receive data via the RS232 but i don't want that the delay make not 500ms.

I want disable any interrupts for that my delay is the time specified.

If anyone have another suggestion???

Thanks you for the help

Lerastas
Ttelmah
Guest







PostPosted: Fri Jul 28, 2006 2:52 pm     Reply with quote

There are two 'parts' to this. You only need to use
'disable_interrupts(GLOBAL);' to actually turn the interrupts off. That having been done, the problem is restarting the interrupts. The INT_RDA interrupt, has the behaviour, that if the data is not retrieved, a second character arrives, and it too is not retrieved, the UART, will go into an 'error' state, and hang. In your 500mSec delay, this is happening.
The 'solution', is to code as follows:
First, add 'errors' to your #use RS232 declaration line. This makes the compiler add code to clear the hang, if it has occured, when you use 'getc'.
Then code the delay as follows:
Code:

disable_interrupts(global);
delay_ms(500);
while (kbhit()) getc();
enable_interrupts(global);

This will force the compiler to flush the UART input buffer of any waiting characters (and because of the 'errors' statement, clear the overrun error bit), before continuing.

Best Wishes
stevie_jay
Guest







Thanks
PostPosted: Wed Aug 30, 2006 6:05 am     Reply with quote

Your solution worked for me, I had the same problem with my UART, trying to enable interrupt half way through a transmission!!!

Thanks
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