Hi, everyone. I'm trying to create a simple frequency divider from 12c508 and I just cannot get the blasted thing to toggle the output pin. I've tried changing the output pin to other out being afraid that the timer mode is on disabling the output, but it did not help. I have compiled it for 16f84 with appropriate changes and it did work on that one (except that the clock did not run with 32khz crystal). Pic is used as follows - oscillator runs in LP mode at 32.768 kHz, GP3 is used as active low turnon input, GP2 is output that outputs low pulses at frequency selected by GP1 and GP0, 100, 200,400, or 800 Hz. Everything works just fine in MPLAB simulator. I'd be very grateful if anyone can point out what I'm doing wrong. I've not used 12c508 before, and tossing them to trashbin is starting to get a bit expensive. please post replies to piclist source code follows: ERRORLEVEL -224 ;supress tris warnings list p=12C508 #include __config _MCLRE_OFF & _LP_OSC & _WDT_ON & _CP_OFF R0 equ 12 ;bit numbers in GPIO register, 12c508 version ; GP0 equ 0 ;FS0 input GP1 equ 1 ;FS1 input GP2 equ 2 ;FOUT GP3 equ 3 ;/ON input ;assign the bits to meaningful names ; FOUT equ GP2 FS0 equ GP0 FS1 equ GP1 ONOFF equ GP3 org 0 main: movwf OSCCAL ;set osc. calibration value clrwdt ;clear watchdog movlw b'01001011' ;set option bits option ;(disable pull-ups,wdt prescaler 1:8) movlw b'11111011' ;12c508 version tris GPIO ;make GP2 output goto start longsleep: movf GPIO,W ;clear change flags sleep ;take a nap and fall through on I/O change or WDT ; this is main loop here. if GP3 is high then the sleep is executed ; change on GP0,GP1 or GP3 pins will wake the chip ; start: btfsc GPIO,ONOFF ;2 goto longsleep ;enter sleep if GP3 is high movf GPIO,W ;1 andlw 3 ;1 isolate frequency select bits addwf PCL,f ;1 this falls directly to f800 if W is 3 goto f100 ;2 to save 2 cycles goto f200 ;2 goto f400 ;2 ; 800 Hz output, 41 cycles for full round ; 8 cycles done ; this one jitters a lot, periods are 11,10,10,10 cycles f800: bcf GPIO,FOUT ;1 bsf GPIO,FOUT ;1 clrwdt ;1 goto f800_1 ;2 f800_1: goto f800_2 ;2 f800_2: goto f800_3 ;2 f800_3: goto f800_4 ;2 f800_4: bcf GPIO,FOUT ;1 bsf GPIO,FOUT ;1 goto f800_5 ;2 f800_5: goto f800_6 ;2 f800_6: goto f800_7 ;2 f800_7: goto f800_8 ;2 f800_8: bcf GPIO,FOUT ;1 bsf GPIO,FOUT ;1 goto f800_9 ;2 f800_9: goto f800_10 ;2 f800_10: goto f800_11 ;2 f800_11: goto f800_12 ;2 f800_12: bcf GPIO,FOUT ;1 bsf GPIO,FOUT ;1 goto start ;2 ; 400 Hz output, 10 cycles done ; full round is 82 cycles ; period alternates between 20 and 21 ; f400: goto f400_1 ;2 f400_1: goto f400_2 ;2 f400_2: goto f400_3 ;2 f400_3: goto f400_4 ;2 f400_4: bcf GPIO,FOUT ;1 bsf GPIO,FOUT ;1 movlw 4 ;1 call delay ;17 nop ;1 bcf GPIO,FOUT ;1 bsf GPIO,FOUT ;1 movlw 4 ;1 call delay ;17 bcf GPIO,FOUT ;1 bsf GPIO,FOUT ;1 movlw 4 ;1 call delay ;17 clrwdt ;1 bcf GPIO,FOUT ;1 bsf GPIO,FOUT ;1 goto start ;2 ; 200 Hz output, 10 cycles done ; full round is 164 cycles ; 200Hz has no jitter ; f200: movlw 7 ;1 call delay ;26 nop ;1 clrwdt bcf GPIO,FOUT ;1 bsf GPIO,FOUT ;1 movlw 11 ;1 call delay ;38 bcf GPIO,FOUT ;1 bsf GPIO,FOUT ;1 movlw 11 ;1 call delay ;38 bcf GPIO,FOUT ;1 bsf GPIO,FOUT ;1 movlw 11 ;1 call delay ;38 bcf GPIO,FOUT ;1 bsf GPIO,FOUT ;1 goto start ;2 ; 100 Hz output, 10 cycles done ; full round is 328 cycles ; 100 Hz has no jitter ; f100: movlw 21 ;1 call delay ;68 clrwdt bcf GPIO,FOUT ;1 bsf GPIO,FOUT ;1 movlw 24 ;1 call delay ;77 goto f100_1 ;2 f100_1: bcf GPIO,FOUT ;1 bsf GPIO,FOUT ;1 movlw 24 ;1 call delay ;77 goto f100_2 ;2 f100_2: bcf GPIO,FOUT ;1 bsf GPIO,FOUT ;1 movlw 24 ;1 call delay ;77 goto f100_3 ;2 f100_3: bcf GPIO,FOUT ;1 bsf GPIO,FOUT ;1 goto start ;2 ; delay routine. including the call it will take ; 5+(W*3) cycles ; delay: movwf R0 ;1 del1: decfsz R0,f ;1 goto del1 ;2 retlw 0 ;3 end -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.