; **************************************************************************** ;* 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 13:03, local time: 2024/11/8 15:53,
3.144.90.160:LOG IN ©2024 PLEASE DON'T RIP! THIS SITE CLOSES OCT 28, 2024 SO LONG AND THANKS FOR ALL THE FISH!
|
©2024 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? <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? |
PICList 2024 contributors:
o List host: MIT, Site host massmind.org, Top posters @none found - 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: Gregg Rew. on-going support is MOST appreciated! * Contributors: Richard Seriani, Sr. |
Welcome to www.piclist.com! |
.