Hi David, I am not familiar with this TechTools, therefore it is very little I can help I am afraid. However, one thing that I spot in your code: You are using 'org' directive for both data and code location. What I suspect is that the first 'org' with the value of 8 is irrelevant for the 'ds' directive, therefore your data declaration starts from address 0 -- then you are writing into special function registers so the strange behaviour could be explained. Tamas On Sun, Feb 7, 2010 at 10:42 PM, David V. Fansler wrote: > Hi Tamas - I use the TechTools assembler and ICE which tends to use the 8= 051 > mnemonics. =A0They are literally one to one with the Microchip mnemonics.= =A0I > have the WDT turned off. =A0The problem generally only occurs on a cold > startup. =A0After the first startup, any others work correctly for the > duration. =A0Here is a little more code: > > ;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > ; =A0CVASM16 INCLUDE FILE for the 12C509A > ; =A0 =A0 =A0Copyright (c) 2001 by TechTools > ;support@tech-tools.com, sales@tech-tools.com > ; =A0 =A0972-272-9392 =A0FAX: 972-494-5814 > ; > ; =A0- Last update: 04/23/01 > ;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > ;DEVCODE =A0 =A000509h > ;ROMSIZE =A0 =A01024 > ;EESIZE =A0 =A0 0 > ;CORE =A0 =A0 =A0 _12bit > ;PAGEBIT =A0 =A01 > ;MAXTRIS =A0 =A00006 > > ;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > ;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=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=A0FUSES _MCLRE_OFF > =A0 =A0 =A0 =A0FUSES _XT_OSC > =A0 =A0 =A0 =A0FUSES _WDT_OFF > =A0 =A0 =A0 =A0FUSES _CP_OFF > > ; PROGRAM: RCV232.SRC > ; Taken from TechTools PIC Application Note: Receiving RS-232 Serial Data > ; Written =A0 =A0 July 15, 1993 > ; Revised February 24, 1996 (to accomodate SPASM v4.2) > ; Revised May 3, 2000 > > ; This program receives a byte of serial data and leaves it in the regist= er > ; RCV_BYTE. The receiving baud rate is determined by the value of > ; the constant bit_K and the clock speed of the PIC. See the table in the > ; application note (above) for values of bit_K. For example, with the clo= ck > ; running at 4 MHz and a desired receiving rate of 4800 baud, make bit_K = 50. > ;For 9600 Baud make bit_K 23. > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0reset =A0 begin > > bit_K =A0 =A0 =A0 =A0 =A0 =3D =A0 =A0 =A0 23 =A0 =A0 =A0 =A0 =A0 =A0 =A0;= Change this value for desired > baudrate > half_bit =A0 =A0 =A0 =A0=3D =A0 =A0 =A0 bit_K/2 =A0 =A0 =A0 =A0 ;as shown= in table. > serial_in =A0 =A0 =A0 =3D =A0 =A0 =A0 GP0 > serial_out =A0 =A0 =A0=3D =A0 =A0 =A0 GP1 > LED =A0 =A0 =A0 =A0 =A0 =A0 =3D =A0 =A0 =A0 GP2 > LX200_Ver =A0 =A0 =A0 =3D =A0 =A0 =A0 GP3 > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0org =A0 =A0 8 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = ;Start of available RAM > > delay_cntr =A0 =A0 =A0ds =A0 =A0 =A01 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ;Counte= r for serial delay routines > bit_cntr_out =A0 =A0ds =A0 =A0 =A01 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ;Number o= f transmitted bits > msg_cntr =A0 =A0 =A0 =A0ds =A0 =A0 =A01 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ;Offs= et in string > xmt_byte =A0 =A0 =A0 =A0ds =A0 =A0 =A01 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ;The = transmitted byte > bit_cntr_in =A0 =A0 ds =A0 =A0 =A01 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ;Number o= f received bits > rcv_byte =A0 =A0 =A0 =A0ds =A0 =A0 =A01 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ;The = received byte > delay_inner =A0 =A0 ds =A0 =A0 =A01 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ;inner de= lay for long delay loop > char_cnt =A0 =A0 =A0 =A0ds =A0 =A0 =A01 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ;Numb= er of characters to send > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0org =A0 =A0 0h =A0 =A0 =A0 =A0 =A0 =A0 =A0= ;Start of code space > > ; Remember to change device info if programming a different PIC. Do not u= se > RC > ; devices. Their clock speed is not sufficiently accurate or stable for > serial > ; communication. > > ;************************************************************************= *** > ** > ; Set up I/O ports. > ;************************************************************************= *** > ** > begin > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0movlw =A0 00001001b =A0 =A0 =A0 ;Use GP0 f= or serial input, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0;GP3 for version select > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0TRIS =A0 =A0gpio =A0 =A0 =A0 =A0 =A0 =A0;a= nd store. > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0movlw =A0 10000000b > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0option > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0call =A0 =A0FLASH_LED > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0call =A0 =A0general_delay_out > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0call =A0 =A0general_delay_out > > ;************************************************************************= *** > ** > ; =A0 =A0 =A0 Check to see if the telescope is a PRE or POST LX200 > ;************************************************************************= *** > ** > > :SEND_DATA =A0 =A0 =A0jb =A0 =A0 =A0LX200_Ver,:prepare_POST ;if high jump= to post, else > goto LX200_early > ----- > ------- more code > > ;************************************************************************= *** > ** > ; =A0 =A0 =A0 RECEIVE section of code > ;************************************************************************= *** > ** > :start_bit =A0 =A0 =A0btfsc =A0 serial_in =A0 =A0 =A0 ;Detect start bit. = Change to > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0;btfss from btfsc serial_in if using > ------------- > ------------ more code > > ;************************************************************************= *** > ** > ; =A0 =A0 =A0 DATA received from LX200 - first check to see if it is a PO= ST or a > ; =A0 =A0 =A0 PRE model of the LX200. > ;************************************************************************= *** > ** > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0sb =A0 =A0 =A0LX200_Ver =A0 =A0 =A0 ;if hi= gh skip next, else post model > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0jmp =A0 =A0 :check_pre =A0 =A0 =A0;low so = jump to pre model > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0movlw =A0 01Bh =A0 =A0 =A0 =A0 =A0 =A0;com= pare for Escape > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0xor =A0 =A0 w,rcv_byte > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0jz =A0 =A0 =A0FLASH_LED_START ;if zero aft= er xor, flash led > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0jmp =A0 =A0 ERROR_LED =A0 =A0 =A0 ;else go= to show error on the LED > :check_pre > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0movlw =A0 'P' =A0 =A0 =A0 =A0 =A0 =A0 ;che= ck for a P > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0xor =A0 =A0 w,rcv_byte > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0jz =A0 =A0 =A0FLASH_LED_START ;if zero aft= er xor then jump > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0movlw =A0 'A' =A0 =A0 =A0 =A0 =A0 =A0 ;che= ck for A > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0xor =A0 =A0 w,rcv_byte > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0jz =A0 =A0 =A0FLASH_LED_START ;if zero aft= er xor then jump > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0movlw =A0 'L' =A0 =A0 =A0 =A0 =A0 =A0 ;che= ck for L > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0xor =A0 =A0 w,rcv_byte > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0jz =A0 =A0 =A0FLASH_LED_START ;if zero aft= er xor then jump > ;************************************************************************= *** > ** > ; =A0 =A0 =A0 Error occurred on receive (wrong character - turn the LED o= n for > ; =A0 =A0 =A0 a period of time > ;************************************************************************= *** > ** > > ERROR_LED > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0setb =A0 =A0LED =A0 =A0 =A0 =A0 =A0 =A0 ;t= urn on the LED > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0call =A0 =A0general_delay_out > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0call =A0 =A0general_delay_out > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0call =A0 =A0general_delay_out > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0call =A0 =A0general_delay_out > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0call =A0 =A0general_delay_out > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0call =A0 =A0general_delay_out > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0call =A0 =A0general_delay_out > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0call =A0 =A0general_delay_out > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0call =A0 =A0general_delay_out > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0call =A0 =A0general_delay_out > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0call =A0 =A0general_delay_out > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0call =A0 =A0general_delay_out > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0call =A0 =A0general_delay_out > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0call =A0 =A0general_delay_out > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0call =A0 =A0general_delay_out > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0call =A0 =A0general_delay_out > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0clrb =A0 =A0LED =A0 =A0 =A0 =A0 =A0 =A0 ;t= urn off the LED > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0jmp =A0 =A0 SLEEP_TIME > ;************************************************************************= *** > ** > ; =A0 =A0 =A0 Proper character was received, sl flash the LED a number of= times > ;************************************************************************= *** > ** > FLASH_LED_START > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0call =A0 =A0FLASH_LED > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0jmp =A0 =A0 SLEEP_TIME > FLASH_LED =A0 =A0 =A0 setb =A0 =A0LED =A0 =A0 =A0 =A0 =A0 =A0 ;Flash the = LED if value is correct > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0call =A0 =A0general_delay_out > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0call =A0 =A0general_delay_out > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0clrb =A0 =A0LED > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0call =A0 =A0general_delay_out > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0call =A0 =A0general_delay_out > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0setb =A0 =A0LED > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0call =A0 =A0general_delay_out > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0call =A0 =A0general_delay_out > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0clrb =A0 =A0LED > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0call =A0 =A0general_delay_out > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0call =A0 =A0general_delay_out > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0setb =A0 =A0LED > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0call =A0 =A0general_delay_out > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0call =A0 =A0general_delay_out > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0clrb =A0 =A0LED > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0call =A0 =A0general_delay_out > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0call =A0 =A0general_delay_out > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0setb =A0 =A0LED > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0call =A0 =A0general_delay_out > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0call =A0 =A0general_delay_out > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0clrb =A0 =A0LED > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0call =A0 =A0general_delay_out > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0call =A0 =A0general_delay_out > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0setb =A0 =A0LED > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0call =A0 =A0general_delay_out > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0call =A0 =A0general_delay_out > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0clrb =A0 =A0LED > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0call =A0 =A0general_delay_out > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0call =A0 =A0general_delay_out > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0setb =A0 =A0LED > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0call =A0 =A0general_delay_out > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0call =A0 =A0general_delay_out > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0clrb =A0 =A0LED > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0call =A0 =A0general_delay_out > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0call =A0 =A0general_delay_out > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0setb =A0 =A0LED > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0call =A0 =A0general_delay_out > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0call =A0 =A0general_delay_out > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0clrb =A0 =A0LED =A0 =A0 =A0 =A0 =A0 =A0 ;T= urn off the LED > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0call =A0 =A0general_delay_out > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0call =A0 =A0general_delay_out > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0ret > ;************************************************************************= *** > ** > ; =A0 =A0 =A0 Duty is over, so go to sleep to reduce power consumption > ;************************************************************************= *** > ** > SLEEP_TIME =A0 =A0 =A0sleep =A0 =A0 =A0 =A0 =A0 ;Power down > > ;************************************************************************= *** > ** > ; =A0 =A0 =A0 Characters to send if model is a POST LX200 > ;************************************************************************= *** > ** > string_post =A0 =A0 jmp =A0 =A0 pc+w =A0 =A0 =A0 =A0 =A0 =A0;LX200 Post m= id-93 initiate string > =A0 =A0 =A0 =A0 =A0 =A0 retw =A0 =A00ffh,0ffh,0ffh,02ah > > ;************************************************************************= *** > ** > ; =A0 =A0 =A0 Characters to send if model is a PRE LX200 > ;************************************************************************= *** > ** > string_pre =A0 =A0 =A0jmp =A0 =A0 pc+w =A0 =A0 =A0 =A0 =A0 =A0;LX200 Pre = mid-93 initiate string > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0retw =A0 =A0048h,006h > > > > general_delay_out > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0mov =A0 =A0 delay_cntr,0ffh > :loop_1 =A0 =A0 =A0 =A0 nop > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0mov =A0 =A0 delay_inner, 0a0h > :loop_2 =A0 =A0 =A0 =A0 djnz =A0 =A0delay_inner, :loop_2 > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0djnz =A0 =A0delay_cntr, :loop_1 > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0ret > > ; To change the baud rate, substitute a new value for bit_K at the beginn= ing > of > ; this program. > ; This delay loop takes four instruction cycles per loop, plus eight > ; instruction cycles for other operations (call, mov, the final djnz, and > ret). > ; These extra cycles become significant at higher baud rates. The values = for > ; bit_K in the table take the time required for additional instructions i= nto > ; account. > > bit_delay =A0 =A0 =A0 mov =A0 =A0 delay_cntr,#bit_K > :loop =A0 =A0 =A0 =A0 =A0 nop > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0djnz =A0 =A0delay_cntr, :loop > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0ret > > ; This delay loop is identical to bit_delay above, but provides half the > delay > ; time. > > start_delay =A0 =A0 mov =A0 =A0 delay_cntr,#half_bit > :loop =A0 =A0 =A0 =A0 =A0 nop > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0djnz =A0 =A0delay_cntr, :loop > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0ret > > > > David > > David V. Fansler > s/v Annabelle > dfansler@dv-fansler.com > www.dv-fansler.com > > -----Original Message----- > From: piclist-bounces@mit.edu [mailto:piclist-bounces@mit.edu] On Behalf = Of > Tamas Rudnai > Sent: Sunday, February 07, 2010 5:35 PM > To: Microcontroller discussion list - Public. > Subject: Re: 12C09Timer Problem > > I have never heard of 'mov', 'djnz' and 'ret' instructions in > conjunction to the PIC Baseline family. Also there is no need > semicolon in front of the label. > Are you using a different Assembly than MPASM or some customized macro > set? It is hard to tell the exact timing of the delay routine if the > instruction timing of each step is unknown. > > Anyway, I assume that in your macro set everything is going all right, > so then the different timing is another issue. Maybe you have a WDT > switched on you forget to clear? > > Tamas > > > > On Sun, Feb 7, 2010 at 9:57 PM, David V. Fansler > wrote: >> After a long hiatus from PICs, I picked up a project recently that I am >> using a 12C509(A) for the first time. =A0The project is simple - when > powered >> on check a jumper - if jumper high send 4 characters through a bit bang >> serial port (9600,8,n,1), if jumper low send 2 characters through the bit >> bang serial port (9600,8,n,1). =A0Then wait for the first returned chara= cter >> and verify if it is what was expected. >> >> >> >> All that works. =A0As a visual indicator, I have a LED that flashes seve= ral >> times on power up, flashes once when sending data, and if the returned > data >> is good it flashes several more times and the 12C509 goes to sleep. =A0If > the >> returned character is not valid, it turns on for a short period of time > and >> goes out, and again the PIC goes to sleep. =A0The problem I am having is > that >> the flashing occurs at two different rates. =A0The fast rate is 50ms per >> on/off cycle and the slow rate happens so in often I have not been able = to >> clock it, but it is about 1s per on/off cycle. =A0I am running an extern= al >> 4.00 MHz oscillator. >> >> >> >> Here is the code for the loop >> >> general_delay_out >> >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0mov =A0 = =A0 =A0 delay_cntr,0ffh >> >> :loop_1 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 nop >> >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0mov =A0 = =A0 =A0 delay_inner, 0a0h >> >> :loop_2 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 djnz =A0 =A0 =A0 delay_inner, :l= oop_2 >> >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0djnz =A0 = =A0 =A0 delay_cntr, :loop_1 >> >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0ret >> >> >> >> Thanks, >> >> >> >> David >> >> >> >> David V. Fansler >> >> s/v Annabelle >> >> dfansler@dv-fansler.com >> >> www.dv-fansler.com >> >> >> >> -- >> http://www.piclist.com PIC/SX FAQ & list archive >> View/change your membership options at >> http://mailman.mit.edu/mailman/listinfo/piclist >> > > > > -- > /* www.mcuhobby.com */ int main() { char *a,*s,*q; printf(s=3D"/* > www.mcuhobby.com */ int main() { char *a,*s,*q; printf(s=3D%s%s%s, > q=3D%s%s%s%s,s,q,q,a=3D%s%s%s%s,q,q,q,a,a,q); }", > q=3D"\"",s,q,q,a=3D"\\",q,q,q,a,a,q); } > > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > > > > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > -- = /* www.mcuhobby.com */ int main() { char *a,*s,*q; printf(s=3D"/* www.mcuhobby.com */ int main() { char *a,*s,*q; printf(s=3D%s%s%s, q=3D%s%s%s%s,s,q,q,a=3D%s%s%s%s,q,q,q,a,a,q); }", q=3D"\"",s,q,q,a=3D"\\",q,q,q,a,a,q); } -- = http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist