> -----Original Message----- > From: piclist-bounces@mit.edu = > On Behalf Of G=F6khan SEVER > Sent: Friday, February 24, 2006 7:02 AM > To: Microcontroller discussion list - Public. > Subject: [PIC] accurate delay routines > > Whereas its PIC18 family compiler it has the delay routines = > what i'm looking for. The routines are cycle based and the = > codes are all open for the routines. I started to > examine the sources but i realized that they are all ASM based = > and mostly benefitted of PIC18 ASM. I dont have much experience > with PIC18 assembly so it will be hard for me to adopt them = > for PIC16 family. Are there any other open-source cycle based = > delay implementations which will facilitate my coding works? I look into the delay routine source codes of C18 and they are quite simple. You have to learn some assemblies anyway. Back to PICC, maybe the following example macros can = serve as a starting point for you. #define delay_1tcy() asm("\tclrwdt") //(or use nop) #define delay_2tcy() asm("\tincf pcl, w") #define delay_4tcy() delay_2tcy();delay_2tcy() #define delay_5tcy() delay_4tcy();delay_1tcy() #define delay_10tcy() delay_4tcy();delay_4tcy();delay_2tcy() Another thing is to use simulator and that will count the total delay time for you. Regards, Xiaofan -- = http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist