on 2/2/02 7:48 AM, Jinx at joecolquitt@CLEAR.NET.NZ wrote: Hi Joe, > That may be false economy. I had something similar to this a > while ago and struggled long and hard to find the problem before > I gave in and ran it through MPLAB. Yes, it did take a while, but > the cause of the problem was found very quickly. I thought it was just me or my computer! Surely it could be re-written to run faster than it does. I bought a PIC Tutor package and it came with a little simulator program. It has arrays of "LEDs" on the screen to indicate pins, registers etc. and it runs in real time! The only downside is that you have to write the code inside this little app and it is only for the PIC16F84, but surely Microchip could do something like this. One simple > conditional break-point and it was all over, I kicked myself at > something that had been staring me in the face all day and > moved on. It sounds like a cheap platitude, but it is never a > good idea to check your own work. Short of posting the entire > code for us to look at, MPLAB is a good sniffer dog Yeah, fair enough. I do not mind posting all of my code, but my code gets spat out of my compiler - and before anybody says "Why don't you write it yourself" - I am now writing about 90% of simple programs myself. However, I write them *inside* the compiler as an assembly instruction. Then when I 'compile' my code, the compiler kindly strips away all my comments. :-( So, I do not like to post my complete, uncommented code. Here it is as follows with a few quick comments addaed. Also the delay routine used to be at the end. I have moved it to the beginning of the code, but no other changes have been made. LIST P= 12C508A INCLUDE "P12C508A.INC" RADIX DEC ORG 0X1 AUX1_L EQU 0X7 AUX1_H EQU 0X8 AUX2_L EQU 0X9 AUX2_H EQU 0XA AUX EQU 0XB S0 EQU 0XC COUNTB EQU 0XD COUNT_H EQU 0XE COUNT_L EQU 0XF __CONFIG _CP_OFF & _WDT_ON & _MCLRE_OFF & _INTRC_OSC MOVWF OSCCAL GOTO STARTHERE ORG 0X40 DELAY500 ; CREATE A DELAY OF 500MS MOVLW 9;* MOVWF AUX2_L DELAYLAB31 MOVLW 169;* MOVWF AUX1_H;* DELAYLAB21 MOVLW 81;* MOVWF AUX1_L;* DELAYLAB11 CLRWDT DECFSZ AUX1_L, F;* GOTO DELAYLAB11 CLRWDT DECFSZ AUX1_H, F;* GOTO DELAYLAB21 CLRWDT DECFSZ AUX2_L, F;* GOTO DELAYLAB31 RETLW 0 STARTHERE MOVLW B'000000' TRIS GPIO STAGE1 MOVLW 6; I want a delay of 6 seconds MOVWF COUNTB STAGE1_LEDON MOVLW B'000011' MOVWF GPIO CALL DELAY500 STAGE1_LEDOFF MOVLW B'100011' MOVWF GPIO CALL DELAY500 DECFSZ COUNTB, F GOTO STAGE1_LEDON IDLE1; just a 500ms delay MOVLW B'100001' MOVWF GPIO CALL DELAY500 STAGE2 MOVLW 10; I want a delay of 5 seconds MOVWF COUNTB STAGE2_2 MOVLW B'000101' MOVWF GPIO CALL DELAY500 DECFSZ COUNTB, F GOTO STAGE2_2 IDLE2 MOVLW 20; I want a delay of 10 seconds here with NOTHING happening MOVWF COUNTB IDLE3 MOVLW B'100000' MOVWF GPIO CALL DELAY500 DECFSZ COUNTB, F GOTO IDLE3 GOTO STAGE1 END -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads