Hi,
If you look at the second post in this thread :
http://www.picbasic.co.uk/forum/show...stant+interupt
you will see a code snippet that ALMOST does what you want to do. It has a main loop where it is just performing a pause and then a timer is setup to toggle the led.
This is very close to what you are asking for.. just enable the interupt before entering your task (so the led will start to flash) and when you exit your task disable it again.
If you change the preloaded value (and prescaler if you have to) for the timer you can have different fast flashing led depending what task you are performing...
This is not difficult because of the EXCELLENT code provided by DT.
This might ( I didn't compile and test it, and I am not sure if it is the right register for your PIC) work and should flash the LED while you are performing my_task only.. just remember if my_task is very fast you might come out of it before we flash since the LED is flashing once per sec or something now.Code:LED1 VAR PORTB.1 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 goto main my_task: T1CON = $31 ; Prescaler = 8, TMR1ON to desice how fast we will flash @ INT_ENABLE TMR1_INT ; enable Timer 1 interrupts ;do all the stuff you want to do here @ INT_DISABLE TMR1_INT ; DISABLE Timer 1 interrupts RETURN Main: GOSUB my_task PAUSE 10 GOTO Main '---[TMR1 - interrupt handler]-------------------------------------------------- ToggleLED1: TOGGLE LED1 @ INT_RETURN
also we will go back to my_task every 10 sek... but what you do in your main loop I leave to you to decide.
/me




Bookmarks