potonzio Inserito: 8 maggio 2005 Segnala Share Inserito: 8 maggio 2005 Uso da tempo il parsic, ma ho notato una limitazione, se voglio far suonare un buzer passivo collegandolo al pic, riesco a farlo cantare ad un max di soli 50hz (2ms) che è la max frequenza data da parsic sul modulo clock.Penso però che si possa modificare la frequenza modificando l'asm.Sotto allego appunto l'asm ricavato da parsic per 16f84 con 50hz di uscita su rb.0.Se per esempio volessi portare la frequenza a 3khz, che valori dovrei toccare? ; Source created with Parsic Version 3.x ; at : 08/05/05 13.09.09 ; Project File : C:\PROGRA~1\PARSIC~1\BOZZE\p.PIC ; Project Version : 1.0.0 ; Created : 08/05/05 13.08.16 ; Last change : 08/05/05 13.09.01 PROCESSOR 16F84 INCLUDE P16F84.INC RADIX DEC __IDLOCS H'0100' __CONFIG _CP_OFF & _PWRTE_OFF & _WDT_ON & _XT_OSC ; Diverses ZERO EQU Z; ZERO-Flag CARRY EQU C; CARRY-Flag ; Variable SYS_WSAV = 12; located in Bank 0, 1 SYS_SSAV = 13; located in Bank 0, 1 TR1 = 14; located in Bank 0, 1 TR1_HI = 15; located in Bank 0, 1 RAM = 16; located in Bank 0, 1 ERRORLEVEL -302; disable warning (Bankswitching) ERRORLEVEL -306; disable warning (Pageswitching) ;**************************************** ;Programmanfang ;**************************************** ORG 0 CLRF STATUS; switch to RAM-Bank 0 GOTO SYS_INIT NOP NOP ;**************************************** ;Interrupt-Adress ;**************************************** MOVWF SYS_WSAV; save register SWAPF STATUS,W CLRF STATUS; bank 0 MOVWF SYS_SSAV BCF INTCON,T0IF; Interrupt quitieren INCFSZ TR1,F GOTO SYS_INT_LABEL_0 INCF TR1_HI,F SYS_INT_LABEL_0 EXITINT SWAPF SYS_SSAV,W; Register zurück MOVWF STATUS SWAPF SYS_WSAV,F SWAPF SYS_WSAV,W RETFIE ;**************************************** ; Subroutines ;**************************************** ;**************************************** ;Initialisierung ;**************************************** SYS_INIT MOVLW B'00100000' MOVWF INTCON ; Set output before direction BCF STATUS,RP0; Bank 0 MOVLW B'00000000' MOVWF PORTA MOVLW B'00000000' MOVWF PORTB MOVLW 143 BSF STATUS,RP0; Bank 1 MOVWF OPTION_REG ; Richtung setzen MOVLW B'11111111' MOVWF TRISA MOVLW B'11111110' MOVWF TRISB ; init vars ; Clear RAM MOVLW 12 MOVWF FSR CR1 CLRF INDF INCF FSR,F MOVFW FSR SUBLW 80 BTFSS STATUS,ZERO GOTO CR1 BCF STATUS,RP0; Bank 0 CLRF TMR0 BCF INTCON,T0IF BSF INTCON,GIE; Interrupt freigeben ;********************************** ;******* Haupt-Programm *********** ;********************************** MAIN CLRWDT ;*************************************************** ; Timer -> TR1 ;*************************************************** MOVLW 0; Test auf >= SUBWF TR1_HI,W;F-W -> W BTFSS STATUS,ZERO GOTO LABEL_TR1_CHECK MOVLW 4 SUBWF TR1,W;F-W -> W LABEL_TR1_CHECK BTFSS STATUS,CARRY GOTO LABEL_TR1_ENDE LABEL_TR1_RESET MOVLW 0; Test auf >= SUBWF TR1_HI,F;F-W -> F MOVLW 4 SUBWF TR1,F;F-W -> F BTFSS STATUS,CARRY DECF TR1_HI,F LABEL_TR1_SET; toggel output BCF STATUS,RP0; Bank 0 BTFSC PORTB,0 GOTO LABEL_TR1_CLR BSF PORTB,0 GOTO LABEL_TR1_ENDE LABEL_TR1_CLR BCF PORTB,0 LABEL_TR1_ENDE ;**************************************** GOTO MAIN END Link al commento Condividi su altri siti More sharing options...
Messaggi consigliati
Crea un account o accedi per commentare
Devi essere un utente per poter lasciare un commento
Crea un account
Registrati per un nuovo account nella nostra comunità. è facile!
Registra un nuovo accountAccedi
Hai già un account? Accedi qui.
Accedi ora