View previous topic :: View next topic |
Author |
Message |
koray_duran
Joined: 04 Feb 2010 Posts: 37
|
interesting problem!! (SOLVED) |
Posted: Tue Nov 09, 2010 12:13 pm |
|
|
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
|
|
Posted: Tue Nov 09, 2010 12:19 pm |
|
|
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
|
|
Posted: Tue Nov 09, 2010 1:12 pm |
|
|
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
|
|
Posted: Tue Nov 09, 2010 1:26 pm |
|
|
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
|
|
Posted: Tue Nov 09, 2010 1:32 pm |
|
|
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
|
|
Posted: Sat Nov 13, 2010 9:58 am |
|
|
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
|
|
Posted: Sat Nov 13, 2010 10:04 am |
|
|
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
|
|
Posted: Sat Nov 13, 2010 10:30 am |
|
|
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
|
|
Posted: Sun Nov 14, 2010 10:41 am |
|
|
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!!! |
|
|
|