Hello.
I'm using this sample code on 16F628A:
By changing T1CON=$01 now I have about 7hz interrupt speed, but I want to make it faster.Code:;----[16F628A Hardware Configuration]------------------------------------------- #IF __PROCESSOR__ = "16F628A" #DEFINE MCU_FOUND 1 #CONFIG cfg = _INTOSC_OSC_NOCLKOUT ; INTOSC oscillator: I/O function on RA6/OSC2/CLKOUT pin, I/O function on RA7/OSC1/CLKIN cfg&= _WDT_ON ; WDT enabled cfg&= _PWRTE_OFF ; PWRT disabled cfg&= _MCLRE_OFF ; RA5/MCLR/VPP pin function is digital input, MCLR internally tied to VDD cfg&= _BODEN_ON ; BOD enabled cfg&= _LVP_OFF ; RB4/PGM pin has digital I/O function, HV on MCLR must be used for programming cfg&= DATA_CP_OFF ; Data memory code protection off cfg&= _CP_OFF ; Code protection off __CONFIG cfg #ENDCONFIG #ENDIF ;----[Verify Configs have been specified for Selected Processor]---------------- ; Note: Only include this routine once, after all #CONFIG blocks #IFNDEF MCU_FOUND #ERROR "No CONFIGs found for [" + __PROCESSOR__ +"]" #ENDIF PCON=%00001010 'set int osc to 4mhz LED1 VAR PORTB.1 wsave2 var byte $120 SYSTEM wsave1 VAR BYTE $A0 SYSTEM wsave VAR BYTE $20 SYSTEM INCLUDE "DT_INTS-14.bas" ' Base Interrupt System INCLUDE "ReEnterPBP.bas" ' Include if using PBP interrupts ASM INT_LIST macro ; IntSource, Label, Type, ResetFlag? INT_Handler TMR1_INT, _ToggleLED1, PBP, yes endm INT_CREATE ; Creates the interrupt processor ENDASM T1CON = $01 ; Prescaler = 0, TMR1ON @ INT_ENABLE TMR1_INT ; enable Timer 1 interrupts Main: PAUSE 1 GOTO Main '---[TMR1 - interrupt handler]-------------------------------------------------- ToggleLED1: TOGGLE LED1 @ INT_RETURN
Darrel's page lists another code for changing interrupt speeds, which is complex and I don't need that much code space to be wasted. So is it possible to modify above code, to make interrupt work say at 20, 50, 400hz speed?
If I understand properly, specific values are to be written to TMR1L and TMR1H registers each time interrupt occurs, right? but how to do that and which values?




Bookmarks