Projects/0000755000076500000240000000000010465503432013437 5ustar rthillestaff00000000000000Projects/DS_1W-16f6x.inc0000744000076500000240000001233210465502331015656 0ustar rthillestaff00000000000000; ******************************************************* ; ; Dallas 1-Wire Support for PIC16F628 ; ; Processor has 4MHz clock and 1s per instruction cycle. ; ; ******************************************************* ; ******************************************************* ; Dallas Semiconductor 1-Wire MACROS ; ******************************************************* OW_HIZ:MACRO BSF STATUS,RP0 ; Select Bank 1 of data memory BSF TRISA ^ 0x80, DQ ; Make DQ pin High Z BCF STATUS,RP0 ; Select Bank 0 of data memory ENDM ; -------------------------------------------------------- OW_LO:MACRO BCF STATUS,RP0 ; Select Bank 0 of data memory BCF PORTA, DQ ; Clear the DQ bit BSF STATUS,RP0 ; Select Bank 1 of data memory BCF TRISA ^ 0x80, DQ ; Make DQ pin an output BCF STATUS,RP0 ; Select Bank 0 of data memory ENDM ; -------------------------------------------------------- OW_STRONG_PULLUP:MACRO BCF STATUS,RP0 ; Select Bank 0 of data memory BSF PORTA, DQ ; Set the DQ bit BSF STATUS,RP0 ; Select Bank 1 of data memory BCF TRISA ^ 0x80, DQ ; Make DQ pin an output BCF STATUS,RP0 ; Select Bank 0 of data memory ENDM ; -------------------------------------------------------- WAIT:MACRO TIME ;Delay for TIME s. ;Variable time must be in multiples of 5s, up to max of 5*256 MOVLW (TIME/5)-1 ;1s MOVWF TMP0 ;1s CALL WAIT5U ;2s ENDM ; ******************************************************* ; Dallas Semiconductor 1-Wire ROUTINES ; ******************************************************* WAIT5U: ;This takes 5uS to complete NOP ;1s NOP ;1s DECFSZ TMP0,F ;1s or 2s GOTO WAIT5U ;2s RETLW 0 ;2s ; -------------------------------------------------------- OW_RESET: OW_HIZ ; Start with the line high CLRF PDBYTE ; Clear the PD byte OW_LO WAIT .500 ; Drive Low for 500s OW_HIZ WAIT .70 ; Release line and wait 70s for PD Pulse BTFSS PORTA,DQ ; Read for a PD Pulse INCF PDBYTE,F ; Set PDBYTE to 1 if get a PD Pulse WAIT .400 ; Wait 400s after PD Pulse RETLW 0 ; -------------------------------------------------------- DSRXBYTE: ; Byte read is stored in IOBYTE call StrobePortA0 ; BUG call StrobePortA0 ; BUG MOVLW .8 MOVWF COUNT ; Set COUNT equal to 8 to count the bits DSRXLP: OW_LO NOP NOP NOP NOP NOP NOP ; Bring DQ low for 6s OW_HIZ NOP NOP NOP NOP ; Change to HiZ and Wait 4s MOVF PORTA,W ; Read DQ ANDLW 1< *+  !"#$%&'(),Root EntryPq/= ZOrderQComponentManager"ConfigMemory  !"#$OutputC:\...\Functions.asmDisassembly ListingFirPIC16F690\d|G:\Projects\PIC_2_1W.COD_w 6Pw6Pw5Pw*x33(oPw?*5 zPw5 Ԑ|Қ|`d隀| PЖX(l||隀|3|Pw( Pخ>Pw( خKFPwخ$5 خ>Pw($KFPw$X!X0QPwT))((T ! PPwXT !,x~C:\Documents and Settings\rthille\My Documents\rthille\PIC_Programming\PICkit 2 Lessons Folder\08 Functions|8|2|||d"|-H``whxPw\@2|0l$|8|2||| @7Pw?@h !oPw? |~5zPw52{Pw(/5(0ڎ}, `6MDisassembly ListingC:\Documents and Settings\rthiLoadedDisplaysOpenFiles<Debugger 0'Ƭ<Debugger Breakpoints%$16577 ProjectMgr 0'Ƭ<ProjectMgr A,,uments\rthille\PIC_PstProject.mcwons.asmFirstProject.mcw2|HDisassembly Listing,]GDlle\My Documents\rthille\PIC_Programming\PICkit 2 Lessons Folder\08 Functions\Functions.asmQ|FirstProject.mcpProjectDisplay Ov;Ov;ProjectDisplay,Disassembly Listing(MЉ0LJ8m|D4|4|d"|8.|z0(c"@Hd|p|m|!4|!4|00z\4| $4|7|!4|6|ܛ'|ܛ_ADC(c,6G:G:\Projects\FirstProject.mcpD\EContents' Projects/Hello World.asm0000744000076500000240000000665410337467216016277 0ustar rthillestaff00000000000000;****************************************************************************** ;Software License Agreement ; ;The software supplied herewith by Microchip Technology ;Incorporated (the "Company") is intended and supplied to you, the ;Companys customer, for use solely and exclusively on Microchip ;products. The software is owned by the Company and/or its supplier, ;and is protected under applicable copyright laws. All rights are ;reserved. Any use in violation of the foregoing restrictions may ;subject the user to criminal sanctions under applicable laws, as ;well as to civil liability for the breach of the terms and ;conditions of this license. ; ;THIS SOFTWARE IS PROVIDED IN AN "AS IS" CONDITION. NO WARRANTIES, ;WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED ;TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A ;PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, ;IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR ;CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. ; ******************************************************************* ; PICkit 2 Lesson 1 - "Hello World" ; ; This turns on DS1 LED on the Low Pin Count Demo Board. ; #include __config (_INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF & _BOD_OFF & _IESO_OFF & _FCMEN_OFF) cblock 0x20 Delay1 ; Define three file registers for the Delay2 ; delay loop Delay3 ; Counter ; Value to display on LEDs endc org 0 Start bcf STATUS,RP0 ; Select Bank 0 bcf STATUS,RP1 clrf PORTA ; Initialize PortA to 0's clrf PORTC ; Initialize PortC to 0's bsf STATUS,RP1 ; Select Bank 2 CLRF ANSEL^0x100 ; Select Digital I/O bcf STATUS,RP1 ; Bank 0 bsf STATUS,RP0 ; select Register Page 1 clrf TRISA^0x80 ; Make PORTA all outputs clrf TRISC^0x80 ; Make PORTC all outputs bcf STATUS,RP0 ; back to Register Page 0 clrf Counter MainLoop bsf PORTA,0 ; Write to the port movlw 0x10; call Delay bsf PORTA,1 ; Write to the port movlw 0x10; call Delay bsf PORTA,2 ; Write to the port movlw 0x10; call Delay bsf PORTA,3 ; Write to the port movlw 0x10; call Delay bsf PORTA,4 ; Write to the port movlw 0x10; call Delay bsf PORTA,5 ; Write to the port movlw 0x10; call Delay bsf PORTC,0 ; Write to the port movlw 0x10; call Delay bsf PORTC,1 ; Write to the port movlw 0x10; call Delay bsf PORTC,2 ; Write to the port movlw 0x10; call Delay bsf PORTC,3 ; Write to the port movlw 0x10; call Delay clrf PORTA ; clear the leds clrf PORTC ; clear the leds movlw 0x10; call Delay goto MainLoop ; wait here ; Delay Function. Enter with number 771uS delays in Wreg Delay movwf Delay3 ; DelayLoop decfsz Delay1,f ; Waste time. goto DelayLoop ; The Inner loop takes 3 instructions per loop * 256 loopss = 768 instructions decfsz Delay2,f ; The outer loop takes and additional 3 instructions per lap * 256 loops goto DelayLoop ; (768+3) * 256 = 197376 instructions / 1M instructions per second = 0.197 sec. decfsz Delay3,f ; goto DelayLoop ; clrf PORTA ; clear the leds clrf PORTC ; clear the leds return end Projects/Hello World.o0000744000076500000240000000332410341714374015737 0ustar rthillestaff000000000000004nC<xVf.config  t .org_0rv9 00 0 0 0 0 0 0 0 0 0 0 ( ( ( ("(.4:@FLRZ\ bfj %&'()*+,-. / 0 2 3 456789:;<=>?@ABCDEF G!H"I#J$K%L&M'N(O)P*Q+R,S-T.X/Z0[1\2]3^4_5`6a7b8.fileg.fileg .listl.nolistl.listLl.eofk.config m.org_0mr9StartS Delay/\0.eofkfG:\Projects\Hello World.asmC:\Program Files\Microchip\MPASM Suite\p16F690.incMainLoopDelayLoopProjects/PIC_2_1W.asm0000744000076500000240000001327310465503432015353 0ustar rthillestaff00000000000000 ; ******************************************* ; ; Dallas Semiconductor PIC code ; ; This code will interface a PIC16F690 microcontroller to ; a DS1822-PAR Econo 1-Wire Parasite-Power Digital Thermometer ; ; *******************************************; ; ; VCC ; ^ ; | ; | ; / ; \ Rpup ; / ; \ ; | ; 16F690 | DS1822-PAR ; RA0 (pin 7) ------------------------------ DQ (pin 2) ; ; *******************************************; ;--------------------------------------------------------- ; List your processor here. list p=16F690 ; Include the processor header file here. #include ;--------------------------------------------------------- ; Assign the PORTA with Constants constant DQ=2 ; Use RA2 (pin 17) for 1-Wire ;-------------------------------------------------------- ; These constants are standard 1-Wire ROM commands ;; Generic 1-Wire Commands constant SEARCH_ROM=0xF0 constant READ_ROM=0x33 constant MATCH_ROM=0x55 constant SKIP_ROM=0xCC constant ALARM_SEARCH=0xEC ;; DS1822-PAR Specific Commands constant CONVERT_TEMP=0x44 ; Requires Strong-Pullup (750ms) constant WRITE_SCRATCH=0x4E constant READ_SCRATCH=0xBE constant COPY_SCRATCH=0x48 ; Requires Strong-Pullup (10ms) constant RECALL_EEPROM=0xB8 ;--------------------------------------------------------- ; These constants are used throughout the code cblock 0x20 IOBYTE TMP0 ; Address 0x23 COUNT ; Keep track of bits PICMSB ; Store the MSB PICLSB ; Store the LSB PDBYTE ; Presence Detect Pulse MSEC_CNTR ; Used by the wait_w_msec delay routine. TEMP_LO ; LSB of the temp TEMP_HI ; MSB of the temp endc ;--------------------------------------------------------- ; Setup your configuration word by using __config. __config (_FCMEN_OFF & _IESO_OFF & _BOD_OFF & _CP_OFF & _MCLRE_OFF & _PWRTE_OFF & _WDT_OFF & _INTRC_OSC_NOCLKOUT) ;--------------------------------------------------------- ; Set the program origin for subsequent code. org 0x00 GOTO SETUP NOP NOP NOP GOTO INTERRUPT ; PC 0x04...INTERRUPT VECTOR! ;--------------------------------------------------------- INTERRUPT: SLEEP ;--------------------------------------------------------- ; Option Register bits ; ____ ; RBPU,INTEDG,TOCS,TOSE,PSA,PS2,PS1,PS0 ; 7=PORTB Pullup Enable, 6=Interrupt Edge Select, 5=TMR0 Source, ; 4=TMR0 Source Edge, 3=Prescaler Assign, 2-0=Prescaler Rate Select ; 11010111 == 0xD7 ; 11010000 == 0xD0 ; PORTB pullups disabled,rising edge,internal,hightolow,TMR0,1:256 SETUP: bcf STATUS,RP0 ; Select Bank 0 bcf STATUS,RP1 clrf PORTA ; Initialize PortA to 0's clrf PORTC ; Initialize PortC to 0's bsf STATUS,RP0 ; Select Bank 1 of data memory clrf TRISA^0x80 ; Make PORTA all outputs clrf TRISC^0x80 ; Make PORTC all outputs movlw 0xD0 ; Set options as specified above. movwf OPTION_REG ^ 0x80 bcf STATUS,RP0 ; Select Bank 0 of data memory bsf STATUS,RP1 ; Select Bank 2 clrf ANSEL^0x100 ; Select Digital I/O bcf STATUS,RP1 ; Bank 0 ;--------------------------------------------------------- BCF INTCON,7 ; Disable all interrupts. ;--------------------------------------------------------- GOTO START ;--------------------------------------------------------- ; Include the 1-Wire communication routines and macros #INCLUDE DS_1W-16f6x.inc #include RPT_STD_PIC.inc ;--------------------------------------------------------- START: call StrobePortA0 ; BUG GET_TEMPERATURE: CALL OW_RESET ; Send Reset Pulse and read for Presence Detect Pulse BTFSS PDBYTE,0 ; 1 = Presence Detect Detected GOTO NOPDPULSE MOVLW SKIP_ROM CALL DSTXBYTE ; Send Skip ROM Command (0xCC) MOVLW CONVERT_TEMP CALL DSTXBYTE ; Send Convert Temp Command (0x44) OW_STRONG_PULLUP ; Exert Strong Pullup on the 1-wire bus call wait_m_750 CALL OW_RESET ; Send Reset Pulse and read for Presence Detect Pulse BTFSS PDBYTE,0 ; 1 = Presence Detect Detected GOTO NOPDPULSE MOVLW SKIP_ROM CALL DSTXBYTE ; Send Skip ROM Command (0xCC) MOVLW READ_SCRATCH ; Ask the DS1822 for the temp out of scratch ram CALL DSTXBYTE ; Send the command CALL DSRXBYTE ; Read the LSB of the Temp (reg 0) MOVF IOBYTE,W MOVWF TEMP_LO ; Put the LSB of the TEMP into TEMP_LOW CALL DSRXBYTE ; Read the MSB of the Temp (reg 1) MOVF IOBYTE,W MOVWF TEMP_HI ; Put the LSB of the TEMP into TEMP_LOW CALL OW_RESET ; Stop the read from the DS1822 ;; Output the LSB of the Temp into PORTC movf TEMP_LO,W movwf PORTC bsf PORTA, 1 ; Note success call wait_m_750 goto GET_TEMPERATURE NOPDPULSE: ; Add some error processing here! bsf PORTA, 0 ; Note an error call wait_m_750 bcf PORTA, 0 call wait_m_750 goto NOPDPULSE sleep ;--------------------------------------------------------- end Projects/PIC_2_1W.asm~0000744000076500000240000001401610342205452015540 0ustar rthillestaff00000000000000 ; ******************************************* ; ; Dallas Semiconductor PIC code ; ; This code will interface a PIC16F690 microcontroller to ; a DS1822-PAR Econo 1-Wire Parasite-Power Digital Thermometer ; ; *******************************************; ; ; VCC ; ^ ; | ; | ; / ; \ Rpup ; / ; \ ; | ; 16F690 | DS1822-PAR ; RA0 (pin 7) ------------------------------ DQ (pin 2) ; ; *******************************************; ;--------------------------------------------------------- ; List your processor here. list p=16F690 ; Include the processor header file here. #include ;--------------------------------------------------------- ; Assign the PORTA with Constants constant DQ=2 ; Use RA2 (pin 17) for 1-Wire ;-------------------------------------------------------- ; These constants are standard 1-Wire ROM commands ;; Generic 1-Wire Commands constant SEARCH_ROM=0xF0 constant READ_ROM=0x33 constant MATCH_ROM=0x55 constant SKIP_ROM=0xCC constant ALARM_SEARCH=0xEC ;; DS1822-PAR Specific Commands constant CONVERT_TEMP=0x44 ; Requires Strong-Pullup (750ms) constant WRITE_SCRATCH=0x4E constant READ_SCRATCH=0xBE constant COPY_SCRATCH=0x48 ; Requires Strong-Pullup (10ms) constant RECALL_EEPROM=0xB8 ;--------------------------------------------------------- ; These constants are used throughout the code cblock 0x20 IOBYTE TMP0 ; Address 0x23 COUNT ; Keep track of bits PICMSB ; Store the MSB PICLSB ; Store the LSB PDBYTE ; Presence Detect Pulse MSEC_CNTR ; Used by the wait_w_msec delay routine. TEMP_LO ; LSB of the temp TEMP_HI ; MSB of the temp endc ;--------------------------------------------------------- ; Setup your configuration word by using __config. __config (_FCMEN_OFF & _IESO_OFF & _BOD_OFF & _CP_OFF & _MCLRE_OFF & _PWRTE_OFF & _WDT_OFF & _INTRC_OSC_NOCLKOUT) ;--------------------------------------------------------- ; Set the program origin for subsequent code. org 0x00 GOTO SETUP NOP NOP NOP GOTO INTERRUPT ; PC 0x04...INTERRUPT VECTOR! ;--------------------------------------------------------- INTERRUPT: SLEEP ;--------------------------------------------------------- ; Option Register bits ; ____ ; RBPU,INTEDG,TOCS,TOSE,PSA,PS2,PS1,PS0 ; 7=PORTB Pullup Enable, 6=Interrupt Edge Select, 5=TMR0 Source, ; 4=TMR0 Source Edge, 3=Prescaler Assign, 2-0=Prescaler Rate Select ; 11010111 == 0xD7 ; 11010000 == 0xD0 ; PORTB pullups disabled,rising edge,internal,hightolow,TMR0,1:256 SETUP: bcf STATUS,RP0 ; Select Bank 0 bcf STATUS,RP1 clrf PORTA ; Initialize PortA to 0's clrf PORTC ; Initialize PortC to 0's bsf STATUS,RP0 ; Select Bank 1 of data memory clrf TRISA^0x80 ; Make PORTA all outputs clrf TRISC^0x80 ; Make PORTC all outputs movlw 0xD0 ; Set options as specified above. movwf OPTION_REG ^ 0x80 bcf STATUS,RP0 ; Select Bank 0 of data memory bsf STATUS,RP1 ; Select Bank 2 clrf ANSEL^0x100 ; Select Digital I/O bcf STATUS,RP1 ; Bank 0 ;--------------------------------------------------------- BCF INTCON,7 ; Disable all interrupts. ;--------------------------------------------------------- GOTO START ;--------------------------------------------------------- ; Include the 1-Wire communication routines and macros #INCLUDE DS_1W-16f6x.inc #include RPT_STD_PIC.inc ;--------------------------------------------------------- START: ;--------------------------------------------------------- TIMERLOOP: ; bcf PORTA,1 ; movlw 0xA ; bsf PORTA,1 ; call wait_w_msec ; bcf PORTA,1 ; movlw 0xA ; call wait_w_msec bsf PORTA,0 nop bcf PORTA,0 nop bsf PORTA,0 nop bcf PORTA,0 nop bsf PORTA,0 nop bcf PORTA,0 nop bsf PORTA,1 bsf PORTA,2 bsf PORTA,4 bcf PORTA,5 sleep goto $ call wait_m_750 bcf PORTA,0 bcf PORTA,1 bcf PORTA,2 bcf PORTA,4 bcf PORTA,5 GET_TEMPERATURE: CALL OW_RESET ; Send Reset Pulse and read for Presence Detect Pulse BTFSS PDBYTE,0 ; 1 = Presence Detect Detected GOTO NOPDPULSE MOVLW SKIP_ROM CALL DSTXBYTE ; Send Skip ROM Command (0xCC) MOVLW CONVERT_TEMP CALL DSTXBYTE ; Send Convert Temp Command (0x44) OW_STRONG_PULLUP ; Exert Strong Pullup on the 1-wire bus call wait_m_750 CALL OW_RESET ; Send Reset Pulse and read for Presence Detect Pulse BTFSS PDBYTE,0 ; 1 = Presence Detect Detected GOTO NOPDPULSE MOVLW SKIP_ROM CALL DSTXBYTE ; Send Skip ROM Command (0xCC) MOVLW READ_SCRATCH ; Ask the DS1822 for the temp out of scratch ram CALL DSTXBYTE ; Send the command CALL DSRXBYTE ; Read the LSB of the Temp (reg 0) MOVF IOBYTE,W MOVWF TEMP_LO ; Put the LSB of the TEMP into TEMP_LOW CALL DSRXBYTE ; Read the MSB of the Temp (reg 1) MOVF IOBYTE,W MOVWF TEMP_HI ; Put the LSB of the TEMP into TEMP_LOW CALL OW_RESET ; Stop the read from the DS1822 ;; Output the LSB of the Temp into PORTC movf TEMP_LO,W movwf PORTC bsf PORTA, 1 ; Note success sleep NOPDPULSE: ; Add some error processing here! bsf PORTA, 0 ; Note an error ;--------------------------------------------------------- end Projects/RPT_STD_PIC.inc0000744000076500000240000000320610342474742016013 0ustar rthillestaff00000000000000;----------------------------------------------------------------------; ; time delay routines ; ;----------------------------------------------------------------------; ; wait_u_160 delays Destro wait_u_160: movlw D'40' ; delay about 160 usec,(4/loop ) wait_u_4: addlw H'FF' ; subtract 1 from 'W' (no declw instruction) btfss STATUS,Z ; skip when you reach zero goto wait_u_4 ; more loops return wait_m_5: movlw 5 ; delay for 5 milliseconds goto wait_w_msec wait_m_250: movlw D'250' ; delay for 250 milliseconds goto wait_w_msec wait_m_750: movlw D'250' ; delay for 250 milliseconds call wait_w_msec movlw D'250' ; delay for 250 milliseconds call wait_w_msec movlw D'250' ; delay for 250 milliseconds call wait_w_msec return ;; Delay routine. Returns after 'W' milliseconds wait_w_msec: movwf MSEC_CNTR ; delay for N (in W) millisec msecloop: movlw D'246' ; 1 usec for load call wait_u_4 ; this instruction takes 995 usec nop ; 1 usec nop ; 1 usec nop ; 1 usec decfsz MSEC_CNTR,f ; 1 usec, (2 if skip taken) goto msecloop ; 2 usec here makes 995+5=1 msec return StrobePortA0: bsf PORTA,0 ; Toggle PortA,0 for a debugging aid. movlw 0x04 call wait_u_4 bcf PORTA,0 movlw 0x04 call wait_u_4 bsf PORTA,0 movlw 0x04 call wait_u_4 bcf PORTA,0 returnProjects/RPT_STD_PIC.inc~0000744000076500000240000000277210342156050016205 0ustar rthillestaff00000000000000;----------------------------------------------------------------------; ; time delay routines ; ;----------------------------------------------------------------------; ; wait_u_160 delays Destro wait_u_160: movlw D'40' ; delay about 160 usec,(4/loop ) wait_u_4: addlw H'FF' ; subtract 1 from 'W' (no declw instruction) btfss STATUS,Z ; skip when you reach zero goto wait_u_4 ; more loops return wait_m_5: movlw 5 ; delay for 5 milliseconds goto wait_w_msec wait_m_250: movlw D'250' ; delay for 250 milliseconds goto wait_w_msec wait_m_750: movlw D'250' ; delay for 250 milliseconds call wait_w_msec movlw D'250' ; delay for 250 milliseconds call wait_w_msec movlw D'250' ; delay for 250 milliseconds call wait_w_msec return ;; Delay routine. Returns after 'W' milliseconds wait_w_msec: movwf MSEC_CNTR ; delay for N (in W) millisec msecloop: movlw D'246' ; 1 usec for load call wait_u_4 ; this instruction takes 995 usec nop ; 1 usec nop ; 1 usec nop ; 1 usec ; movlw (1 << 5) ; set bit 5 ; xorwf PORTA,f ; toggle bit 5 of port A decfsz MSEC_CNTR,f ; 1 usec, (2 if skip taken) goto msecloop ; 2 usec here makes 995+5=1 msec return