Help writing pic program with i/p o/p hold delay


Closed Thread
Results 1 to 3 of 3

Hybrid View

  1. #1
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    There you go... I was feeling benevolent...

    You could do this with a 10F series chip... 90 words are not exactly taxing a 12F... (actually, thinking about it, you could do this with a NE555 configured in monostable mode)...

    Untested - but it compiles and it's a start to check the logic...

    Code:
    	'
    	'	PIC Defines
    	'	-----------
    	@ DEVICE pic12F675, INTRC_OSC_NOCLKOUT
    		' System Clock Options (Internal)	
    	@ DEVICE pic12F675, WDT_ON
    		' Watchdog Timer
    	@ DEVICE pic12F675, PWRT_ON
    		' Power-On Timer
    	@ DEVICE pic12F675, MCLR_OFF
    		' Master Clear Options (Internal)
    	@ DEVICE pic12F675, BOD_ON
    		' Brown-Out Detect
    	@ DEVICE pic12F675, CPD_OFF
    		' Data Memory Code Protect
    	@ DEVICE pic12F675, PROTECT_OFF
    		' Program Code Protection
    
    	'
    	'	Define Hardware
    	'	---------------
    	InputTrigger var GPIO.0		' Input normally LOW, goes HIGH to Trigger
    	InputReset var GPIO.1		' Input normally LOW, goes HIGH to RESET
    	OutputLine var GPIO.2		' Normally LOW, goes HIGH when triggered
    
    	'
    	'	Define Variables
    	'	----------------
    	DelayTick var Byte		' 100mS Tick Counter
    
    	'
    	'	Initialise PIC
    	'	--------------
    Reset:
    	TRISIO=%00000011		' Preset I/O
    	CMCON=%00000111 		' Disable Comparators
    	ANSEL=%00000000 		' Disable ADC
    	DelayTick=0			' Reset Counter
    	Low OutputLine			' Everything RESET
    
    	'
    	'	Main Program Loop
    	'	-----------------
    Loop:
    		'
    		'	Test for RESET
    		'	--------------
    	While InputReset=1		' Just wait here if RESET
    		DelayTick=0		' Reset Counter
    		Low OutputLine		' Reset Output
    		Wend
    		'
    		'	Test for Trigger
    		'	----------------
    	If InputTrigger=1 then		' Test for Trigger
    		High OutputLine		' Enable Output
    		DelayTick=1		' Arm Counter
    		Goto Loop
    		endif
    		'
    		'	Timeout Counter
    		'	---------------
    	If DelayTick>0 then
    		DelayTick=DelayTick+1	' Count Time
    		Pause 100		' Waste 100mS
    		If DelayTick>201 then goto Reset
    					' Reset at 20 Seconds
    		endif
    	Goto Loop
    
    	'
    	End

  2. #2
    Join Date
    Oct 2007
    Posts
    35


    Did you find this post helpful? Yes | No

    Default Many thanks..

    Hi Melanie

    Many thanks for the code,
    Its just the job and it gives me a chance to learn some more code functions.

    All the best
    Dave..

Similar Threads

  1. Presetting Configuration Fuses (PIC Defines) into your Program
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 82
    Last Post: - 15th December 2013, 10:54
  2. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 09:26
  3. PIC read program
    By TEOWK in forum General
    Replies: 3
    Last Post: - 10th June 2005, 14:48
  4. Serial Pic to Pic using HSER
    By Chadhammer in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 12th March 2005, 00:14
  5. size of program vs mem on pic
    By PICMAN in forum General
    Replies: 1
    Last Post: - 1st March 2005, 18:23

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts