this is PBP 2.6 and 20MHZ clock, and 10 times a second tmr1 interrupt....... on interrupt routine, need to, 1) stop timer... 2) reload tmr1 counters for timing period... 3) do something ( I set a flag so next loop in basic can see if something happened) .... turn tmr1 back on and leave int... of course you have to adjust for your stuff and PBP3
______'''Code:include "D:\All_PIC\Project_18f2525 RTOS\A_18F2525_Setup.pbp" 'f2525 setup stuff include "D:\All_PIC\Project_18f2525 RTOS\A_TX_RX.pbp" output portc.2 ' LED on pin 13 of F2525 T1CON = $31 ' Prescaler = 8, TMR1ON BH=11 : BL=190 '...MAIN INT TIMING PRELOAD FOR TIMER1 INT = 10X/SEC L0=0:B3=10 '''' interrupts for T1 timeout (main timing loop), etc'''''''''''''''' ASM INT_LIST macro ; IntSource, Label, Type, ResetFlag? INT_Handler TMR1_INT, _T1int, PBP, yes INT_Handler RX_INT, _RCint, PBP, yes INT_Handler TX_INT, _TRint, PBP, no endm INT_CREATE ; Creates the interrupt processor ENDASM @ INT_ENABLE TMR1_INT ; enable Timer 1 interrupts @ INT_DISABLE RX_INT ; enable RX interrupts @ INT_DISABLE TX_INT ;disable tx int ''''_________________________________________________
Code:''''''''''''''''''''''-----END OF MAIN LOOP-------''''''''''''''' ''''''''''''''-----INTERRUPTS HERE----------'''''''''''''''''' '''''''T1 main''Interrupt Routine'''''''''''''''''' T1int: T1CON.0=0 TMR1h=bh :TMR1l=bl 'load tmr1 FLG1 =0 T1CON.0=1 @ INT_RETURN ;RESET FLAG FOR BASIC LOOP '''-------------RCV INT ROUTINE----------------'''' RCint: RCX=RCREG '@ bcf RCSTA,4 '@ bsf RCSTA,4 '''@ CLRF CREN ;RESET RCV overrun '''@ SETF CREN




Bookmarks