Hi,
You forgot to take the reload time into account ...
from MrE calc. I get 65443 ...
Why not use a 8 bits timer w/ preload = 63 ???
Alain
Hi,
You forgot to take the reload time into account ...
from MrE calc. I get 65443 ...
Why not use a 8 bits timer w/ preload = 63 ???
Alain
Last edited by Acetronics2; - 24th March 2009 at 18:51.
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
1. I would remove "PAUSE 50" from main loop.
2. To load the timer, have a word variable like timex.
For example:
3. Why not use TMR0 ?Code:TimeX VAR WORD TimeX = 65437 TMR1L = TimeX.LowByte TMR1H = TimeX.HighByte
----------------
"If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte
Using a PBP interrupt eats hundreds of instruction cycles just saving & restoring PBP system
variables.
You can get much more accurate timing, and save hundreds of instruction cycles with a
CCP Compare interrupt & .asm interrupt handler.
Try something like this;
This should give you a 5kHz signal on RB7, with Timer1 reset by hardware. To change theCode:INCLUDE "DT_INTS-14.bas" ' Base Interrupt System INCLUDE "ReEnterPBP.bas" ' Include if using PBP interrupts LED VAR PORTB.7 OUTPUT LED LED = 1 ADCON1 = 7 ASM INT_LIST macro ; IntSource, Label, Type, ResetFlag? INT_Handler CCP1_INT, CCP_INT, ASM, yes endm INT_CREATE ; Creates the interrupt processor ENDASM @ INT_ENABLE CCP1_INT ; enable Compare interrupt T1CON = %00000001 ; Prescaler = 1, TMR1ON CCP1CON = %00001011 ; compare mode, int when TMR1 = CCPR1 CCPR1L = 100 ; interrupt every 100 instruction cycles CCPR1H = 0 MAIN: PAUSE 50 GOTO MAIN ASM CCP_INT MOVLW 0x80 ; W = %10000000 XORWF PORTB,F ; toggle RB7 on each interrupt INT_RETURN ENDASM
frequency, just change the value in CCPR1 high & low registers.
See analyzer screen capture attached.
it is realy great bruce.
I HAVE TO USE ASM INTERRUPTS AFTER THAT.
The frequency is 5KHz.
And where can i find some sample codes to use asm interrupt routines in PBP.
thank you very much..
For examples of using assembler interrupts look at some of Darell Taylors code, and look
through a few of the examples on MeLabs website.
Bookmarks