; **************************************************************************** ;* Inställningar ;**************************************************************************** include "P16f873.inc" include "inkl.inc" __CONFIG _WDT_OFF & _XT_OSC & _CP_OFF & _PWRTE_OFF __IDLOCS 0x1234 ;**************************************************************************** ;* Här startar programmet ;**************************************************************************** ;--->Huvudprogrammet: ORG 0x000 ; processor reset position GOTO ProgramStart ; start cblock H'20' TMP1 TMP2 PULSLÄNGD endc ;**************************************************************************** ;* interupt ;**************************************************************************** org 0x0004 RETFIE ;**************************************************************************** ;* ProgramStart och huvudloop ;**************************************************************************** ProgramStart BANK1 MOVLW 0x06 MOVWF ADCON1 CLRF TRISA MOVLW B'00000011' MOVWF TRISB BSF OPTION_REG, 7 CLRF TRISC BANK0 ;PWM: ; osc / 4 * Fpwm * 4 - 1 ; 1000000 / 5000 = fpwm = 2000 hz BSF STATUS,RP0 MOVLW D'125' MOVWF PR2 BCF STATUS,RP0 ;ställer in duty cycle: ;01111101 = 125 * 0.00000025 * 4 ;01000000 = 64 MOVLW B'01000000' MOVWF CCPR1L BCF CCP1CON,CCP1X BCF CCP1CON,CCP1Y MOVLW b'00000101' ; prescaler = 4 MOVWF T2CON MOVF CCP1CON, W ANDLW b'00110000' IORLW b'00001111' MOVWF CCP1CON HL CLRF PULSLÄNGD BTFSS PORTB, 0 ;Wait for a pulse to arrive GOTO $-1 ; Waiting... CALL PAUS1MS ;Wait 1 ms before counting BTFSS PORTB, 0 ;Count as long as the pulse is active GOTO PULSKLAR ; pulse has stopped, goto "pulsklar" INCF PULSLÄNGD, F ; counting... GOTO $-3 ; PULSKLAR MOVF PULSLÄNGD, W ADDLW D'60' MOVLW D'255' BTFSC STATUS, C MOVWF PULSLÄNGD MOVF PULSLÄNGD, W ;SET PWM DUTY CYCLE! MOVWF CCPR1L BTFSC STATUS, Z ;BRAKE IF DUTY CYCLE = 0% BSF PORTC, 6 BTFSS STATUS, Z BCF PORTC, 6 GOTO HL ;**************************************************************************** ;* PAUS1MS ;**************************************************************************** PAUS1MS MOVLW 0xDB MOVWF TMP1 MOVLW 0x01 MOVWF TMP2 PAUS1MS_0 DECFSZ TMP1, f GOTO $+2 DECFSZ TMP2, f GOTO PAUS1MS_0 RETURN END
| file: /techref/microchip/io/dev/motor/esc-js_files/1.asm, 2KB, , updated: 2002/6/3 14:03, local time: 2008/7/5 06:19,
38.103.63.16:LOG IN
|
| ©2008 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? Please DO link to this page! Digg it! <A HREF="http://www.piclist.com/techref/microchip/io/dev/motor/esc-js_files/1.asm"> microchip io dev motor esc-js_files 1</A> |
| Did you find what you needed? |
|
o List host: MIT, Site host massmind.org, Top posters @20080705 Apptech, Jinx, Xiaofan Chen, Alan B. Pearce, David VanHorn, Bob Axtell, William \Chops\ Westfield, Cedric Chang, olin piclist, Gerhard Fiedler, * Page Editors: James Newton, David Cary, and YOU! * Roman Black of Black Robotics donates from sales of Linistep stepper controller kits. * Ashley Roll of Digital Nemesis donates from sales of RCL-1 RS232 to TTL converters. * Monthly Subscribers: Shultz Electronics, Larry Williams, David VanHorn, Bryan Whitehouse, Timothy Weber, David Challis. Peter Todd. on-going support is MOST appreciated! * Contributors: Neil Narwani, David Cary, Elemer AM Nyiry, Philip J Taylor, Gus Calabrese of Omegadogs.com, Gautama Venegas, Patrick B. Murphy, William Chops Westfield, Peter Todd, Leslie Ellis |
|
.