Hi all I am using yet another chip I've not worked with before. This time a 16C73 My problem is a little complicated. I am working on a program that someone else wrote(basically sending data to a PC via RS-485). The timing is kept using the RTC. What I am doing is using spare processing time(between data sends, etc.) to do various functions(turn on/off relays,etc). I have a sequence in which some relays must turn on & off, with a three second delay between each. In the simulator it simulates the time correctly(ie. the bits change when the stopwatch has reached aprox. 3 sec.) but when I programmed the chip the sequence happens over a few milliseconds. I dont know what could be the problem. Could it be I'm not setting page bits correctly?(I never seem to get them right :) The code is over 800 lines long!!! I don't get any warnings or anything about it anyhow. I thought it may be the RTC, but for the whole sequence to happen the RTC has to "overflow." Below is a snippet of the main code. It calls various other subroutines for the RS485 but the processes that I have written are do_full,do_mt. They are called every 256ms(in software simulator) ********** RTC START ********** rtc_start ;1ms period load_tmr0 bsf rtc_test ;start external rtc pulse clrwdt bcf t0if ;clear overflow flag call do_coms ;RS485 process incf scan_time,1 ;256mS scan interval call do_analog ;sample RC0, RC1, RC2 and RC3 (one per scan) Reads some analog inputs(AFAIK) movf scan_time,1 ;test for overflow on scan_time btfss z ;run full and mt on zero condition goto idle_state call do_full call do_mt These are the processes the aren't working properly. The seqeunce is called once every 256ms * 4 sequences = 1s. I dec a counter 3 times to get 3 seconds and still return to the rest of the program(needed for RS485 timing etc. I think) eg. Set relay1, then dec the counter. If 0 then set relay2 and so on I can post that part of the code (or attach the asm) too if it would help any call do_batt An unrelated process, used to collect battery level data(part of what the chip send to the PC) btfss relay2 goto $+3 bcf relay2 goto $+2 bsf relay2 This is a bit of code I put in afterward to try "debug" the program. My theory was that this is ran every 256ms.(It works okay in the simulator also) And so the relay would switch four times a second..... but in hardware it switches on when I turn on the power, and stays on( I checked for pulses with an oscilliscope, but found none) until you turn off the power idle_state ;wait here for real time clock to expire bcf rtc_test ;switch off rtc monitor signal btfss t0if goto idle_state goto rtc_start I think this bit is self explanatory....... :? waits till the RTC has overflowed and goes through the above cycle again( every 1ms AFAIK) I can't think what could be the problem. The person I am doing this for says the RS485 part works perfectly....... If it would help to c the whole code I can send it......... Thanks again Christopher Tyler -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu