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

WDT

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



Joined: 20 Mar 2010
Posts: 193
Location: Auckland NZ

View user's profile Send private message

WDT
PostPosted: Fri Apr 02, 2010 7:23 am     Reply with quote

Hello,

I have a little problem, my PIC works well and WTD works. I test it by changing timing and as long as it is WDT<256 my PIC loops forever during start - so I know WDT works. However when I send 999 calls over RS232 with interval of <=5ms it hangs some times and WDT never resets the unit. I use 18F4520 and PCH - any clues what could cause such thing?

Initial setup as follows:
Code:

...
#fuses MCLR, BROWNOUT , NOPROTECT, WDT256, HS, PUT, NOCPD
...
void main() {

int ...
int ...
...();
setup_wdt(WDT_ON);
disable_interrupts(GLOBAL);
set_timer0(0);
set_rtcc(0);
enable_interrupts(GLOBAL);
enable_interrupts(INT_RTCC);
setup_timer_0(RTCC_EXT_L_TO_H| RTCC_DIV_256);
setup_adc_ports( ALL_ANALOG );
setup_adc_ports(AN0_TO_AN7);
setup_adc(ADC_CLOCK_DIV_8);
setup_comparator(NC_NC_NC_NC);
enable_interrupts(int_rda);
...
while...{
    }
}

Thank you.
_________________
Help "d" others and then you shell receive some help from "d" others.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Apr 02, 2010 9:57 am     Reply with quote

Post a small compilable program that shows the problem, and post
your compiler version.
Linuxbuilders



Joined: 20 Mar 2010
Posts: 193
Location: Auckland NZ

View user's profile Send private message

PostPosted: Fri Apr 02, 2010 6:12 pm     Reply with quote

PCH 4.104
will do some program and post in later on.
Thank you
_________________
Help "d" others and then you shell receive some help from "d" others.
Linuxbuilders



Joined: 20 Mar 2010
Posts: 193
Location: Auckland NZ

View user's profile Send private message

PostPosted: Fri Apr 02, 2010 10:22 pm     Reply with quote

I have found a problem and I think it will affect any pic on hardware UART.

So it is as follows:

I send 999 messages without any break (not even 1ms) so as my speed goes 19200 over rs485 the delay between each message is almost nothing.
Then processor is receiving data, processing it and as is meant to do it tries to send an answer. An this is a problem because I hit it almost instantly with another message on RX. It is in half of sending a thing when my IRQ kicks on and breaks TX. Then whole CPU hangs. It must be a hardware thing because WDT stops working as well. I imagine setting TX up and in the same time get RX going. Because of half duplex on rs485 the bus is getting high and UART is bombarded with wrong potentials and crashing whole unit.

So in TX routine I have added:
Code:

if (!kbhit()) {
disable_interrupts(int_rda);
comms_TX_high();   
printf("%c",TX);
comms_TX_low();
enable_interrupts(int_rda);
}

and it fixed the problem.

Thank you
_________________
Help "d" others and then you shell receive some help from "d" others.
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