Hi all! I'm looking to use a pic 12c508 to make a square wave out fom gp2-5 every 1.5 / 3 minutes selectable with gp0. I tryed to use the internal rc oscillator. but i've discovered two things: - 12c508 is "one shot one kill" and i burned out 2 micros - the program doesent work :( Above i've putted my source code sorry for my english. list p=12c508 ; list directive to define processor #include ; processor specific variable definitions __CONFIG _CP_OFF & _WDT_OFF & _MCLRE_OFF & _IntRC_OSC ; code protect disattivato, watchdog timer disattivato, memory clear disattivato ; selezionato il clock interno :)))) ;***** DEFINIZIONE DELLE COSTANTI USATE N_C_B equ 0x22 ; numero di cicli che devo fare prima di ; spegnere il cicalino LUNGO equ 0xb4 ; temporizzazione lunga = 3 minuti CORTO equ 0x5a ; temporizzazione corta = 1.5 minuti ;***** VARIABLE DEFINITIONS TEMP1 equ 0x08 ;Temp variables TEMP2 equ 0x09 TEMP3 equ 0x0A sec2cnt equ 0x10 ; numero di secondi da contare nsecs equ 0x11 ; numero secondi contati ncicli equ 0x12 ; numero di cicli max equ 0x13 ; var. dove setto il massimo da contare ;********************************************************************** ORG 0x1FF ; processor reset vector ; Internal RC calibration value is placed at location 0x1FF by Microchip ; as a movlw k, where the k is a literal value. ORG 0x000 ; coding begins here movwf OSCCAL ; update register with factory cal value reset ; reset sequence ;bsf STATUS,RP0 ; bank 1 movlw 0x01 tris GPIO ; gp0 in input resto output ;bcf STATUS,RP0 ; bank 0 clrf sec2cnt clrf nsecs clrf ncicli clrf max ; posso entrare nell loop principale mainloop bsf GPIO,1 ; quando entro nel ciclo accendo il led ;controllo quale periodo e' stato scelto btfsc GPIO,0 goto breve movlw LUNGO goto avanti1 breve movlw CORTO avanti1 movwf sec2cnt ; incremento i secondi incf nsecs,F movfw nsecs xorwf sec2cnt,0 btfsc STATUS,2 call suona bcf GPIO,1 ; lo spengo appena termina l'esecuzione call unsecondo ; controllo lo scorrere de tempo goto mainloop ;*************************************** ;* This routine is a software delay. * ;* Fosc = 1/Tosc; Tcycle = 4 x Tosc * ;* Delay = TEMP1xTEMP2xTEMP3xTcycle * ;* delay = 200*200*25 = 1 secondo * ;*************************************** unsecondo ; here i count a second movlw 0xc8 movwf TEMP1 ;TEMP1 = 200 movwf TEMP2 ;TEMP2 = 200 movlw 0x19 movwf TEMP3 ;TEMP3 = 25 movlw 0xc8 DLOOP decfsz TEMP1, F goto DLOOP movwf TEMP1 ; restart from 200 decfsz TEMP2, F goto DLOOP movwf TEMP2 ; restart from 200 decfsz TEMP3, F goto DLOOP retlw 0x00 suona ; here i put high and low gp2-5 at a frequence near 0.005 secs movlw 0xc8 movwf TEMP1 ;TEMP1 = 200 movwf TEMP2 ;TEMP2 = 200 movlw 0x32 movwf TEMP3 ;TEMP3 = 50 movlw 0xc8 DLOOP1 decfsz TEMP1, F goto DLOOP1 movwf TEMP1 ; restart from 200 decfsz TEMP2, F goto DLOOP1 movwf TEMP2 ; restart from 200 movlw 0xfe xorwf GPIO,F decfsz TEMP3, F goto DLOOP1 clrf nsecs ; seconds couter resetted retlw 0x00 END ; directive 'end of program' -=0=--=0=--=0=- Marco Bettini Sistemista UNIX Programmatore C / C++ / C# / ASM Progetto e realizzazione controllori con PIC tel. cell. 3476017387 ICQ #: 171966875 -=0=--=0=--=0=- -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics