That makes 2 of us..... I just know vary little ASM
I've never really learn it because its to tedious, and sloooow.
1. You have to define interrupt variables
2. Jump the interrupt handler
3. Write the interrupt handler
4. Define your Program Variables
5. Start of program
6. Loop to start.
So when the program runs the first time it does 1,2,4,5. Then it should stay in in 5-6 infinitly until a interupt occurs. Then it will jump to 2 and will return where it left off between 5-6.
So what happens in the interrupt part?
You increase a variable you can use in PICBASIC.... PICBASIC variables are the same as the ASM variables with an "_". So a PICBASIC variable named myVar will be call in the compile ASM: _myVar.
That is what you are playing with. By incrementing in ASM:
Code:
incf _TICK,F ; INCREMENT TICK COUNT
you are actually incrementing the PICBASIC variable TICK. So in your loop (5-6) you can check if the TICK value is greater that something. You know that this "TICK" value occurs every x usec according to what you set the Timer register to be.
So before you enable the interrupts you set the TMR0 or TMR1 register to the value you want, so that the amount of counts left are the time you are looking for. Then you enable the interrupts and the timer will be set and will interrupt what you set it for, set the timer register again, increment the TICK and go back to your program.
The timer register is set at:
Code:
movlw 0C0h ; Prepare to set TMR1 high register
movwf TMR1H ; Set TMR1H to C0h
0C0 here is the number that the example uses to increment timer 1 by. YOu can change this number to anything. It is in HEX so keep that in mind, I am not sure if you can out a decimal value here.... but I suppose you could.
Since the TMR! (timer resgister) is 16 bit, it is devided in two 8-bit parts TMR1H for the 8 most significat bits, and TMR1L for the remaining bits.
Also you may want to set this bits before you enable your interrupts in PICBASIC by doing a TMR1H = and TMR1L = so that you can start with the interrupts right away. Then keep track of how many interrupts occur and when the TICK is at the value you want it, then you reset it in PICBASIC by TICK = 0... then the interrupts in ASM will start incrementig them by 1
Hope it helps some, could not really understand what you were asking
Ivancho