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 support@ccsinfo.com

interesting problem!! (SOLVED)

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



Joined: 04 Feb 2010
Posts: 37

View user's profile Send private message

interesting problem!! (SOLVED)
PostPosted: Tue Nov 09, 2010 12:13 pm     Reply with quote

When i disable int_rda everything works fine but when i enable int_rda device can't start and all time restarts by WDT. I can't find the solution and also in forum such a problem.

Last edited by koray_duran on Sun Nov 14, 2010 10:41 am; edited 1 time in total
pmuldoon



Joined: 26 Sep 2003
Posts: 218
Location: Northern Indiana

View user's profile Send private message

PostPosted: Tue Nov 09, 2010 12:19 pm     Reply with quote

start by removing the 2nd fgetc(RS);
from your interrupt routine.
The interrupt routine should only retrieve one char and exit.

If you need to, you can have a static var in the interrupt to tell you where the next char goes.

Code:
void receiving_data() {
static int1 NextChar =0;

   rcv_data[NextChar++]=fgetc(RS);
   if(rcv_data[0]==adress) { stt_cntrl=1; }
}

koray_duran



Joined: 04 Feb 2010
Posts: 37

View user's profile Send private message

PostPosted: Tue Nov 09, 2010 1:12 pm     Reply with quote

thanks for answering, i tried this without success. i deactiveted the code in int_rda. The problem occurs not after receiving a char, it occours before main program starts and restarts the system.

Do you have another suggestion ??

pmuldoon wrote:
start by removing the 2nd fgetc(RS);
from your interrupt routine.
The interrupt routine should only retrieve one char and exit.

If you need to, you can have a static var in the interrupt to tell you where the next char goes.

Code:
void receiving_data() {
static int1 NextChar =0;

   rcv_data[NextChar++]=fgetc(RS);
   if(rcv_data[0]==adress) { stt_cntrl=1; }
}

pmuldoon



Joined: 26 Sep 2003
Posts: 218
Location: Northern Indiana

View user's profile Send private message

PostPosted: Tue Nov 09, 2010 1:26 pm     Reply with quote

I think you're hanging in the RDA interrupt.
Comment out all of the code in the interrupt and just leave empty braces.
Then enable the RDA interrupt.

If the program runs after doing that, then
insert a simple
Code:
rcv_data[0]=fgetc(RS);

and see if the main program still runs.
pmuldoon



Joined: 26 Sep 2003
Posts: 218
Location: Northern Indiana

View user's profile Send private message

PostPosted: Tue Nov 09, 2010 1:32 pm     Reply with quote

You also might try with WDT disabled.
I don't have time to look it up, but your
Code:
setup_WDT(WDT_2304MS);
  \

may be overwritten when you initialize timer 0 afterward with
Code:
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);

which would probably make the WDT 256 instruction cycles.
koray_duran



Joined: 04 Feb 2010
Posts: 37

View user's profile Send private message

PostPosted: Sat Nov 13, 2010 9:58 am     Reply with quote

I've figured out that system can't get out from interrupt. It acts like there is an endless receving. MCU drives a RS485 chip and transmitting works if i disable interrupt.
pmuldoon



Joined: 26 Sep 2003
Posts: 218
Location: Northern Indiana

View user's profile Send private message

PostPosted: Sat Nov 13, 2010 10:04 am     Reply with quote

What does your current interrupt routine look like?
did you get rid of the redundant fgetc()'s?
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Sat Nov 13, 2010 10:30 am     Reply with quote

Did you connect a pull-up resistor for PIN_C7? The pin will be floating while the RS485-receiver is disabled, possibly causing erratic action of the receiver UART. This may happen during device initialization, because RS485_EN2 isn't initially driven low, and during RS485 send.
koray_duran



Joined: 04 Feb 2010
Posts: 37

View user's profile Send private message

PostPosted: Sun Nov 14, 2010 10:41 am     Reply with quote

Thanks FvM!! Actually there is a pullup resistor but because of deisgn change (I was using max3440 instead of Max485) i've placed it to the wrong pin and that was causing problems.
Thanks guys for your helps!!!
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