Gonzalo Jiminez wrote: > Good day to all: > > I'm planing to work with multitasking on a PIC 16F877A, I found a lot of > useful help in PICLIST site, I'm a attaching a code I found there, it works > really well for two task, does anybody know how to expand it to more > tasks??? I was trying, but I can't figure it out how... any help will be > apreciate!!! > > Thanks in advance, > > Gonzalo Multitasking on a 16 series PIC is not trivial. For one thing you need to be careful about shared subroutines. Sometimes you may need to make copies of subroutines that are used in different tasks. Switching the task context from within a called subroutine is another problem on the 16 series PIC since you don't have read/write access to the return stack or its pointer. XCSB is a high level language that has multitasking built in. As you would expect, it allows communication between tasks using global variables, however it also allows comminication through FIFOs and the state of one or more FIFOs can be used to control task schedualing. Example programs are shown at http://www.xcprod.com/titan/XCSB/CONTRIB The XCSB compiler generates optimised native instructions for the 16 series PIC. The following: proc inline clear_bit(ubyte *ptr, int id) *ptr = *ptr & ~(1 << id) endproc proc main() clear_bit(&PORTA, 3) endproc generate just one instruction bcf PORTA,3 Regards Sergio Masci http://www.xcprod.com/titan/XCSB - optimising structured PIC BASIC compiler -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.