12F683 and DT Instant Interrupts


Results 1 to 27 of 27

Threaded View

  1. #22
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Talking You've asked for it ... do not cry, now !!!

    Hi, Martin

    Darrel will love it, for sure !!! ( Lol ...)

    Code:
    '*****************************************************************************
    'FRAMEGEN.BAS
    '*****************************************************************************
    '
    ' Générateur de Trame R/C Graupner/Multiplex sur 12F675
    '
    ' 4,7,8 ou 9 Canaux - Neutre 1.5 ms
    '
    ' Oscillateur interne 4 Mhz
    '
    ' Trames déclenchées par interruptions TMR0 : PS = 1/128 Pl = 80
    '
    ' Sortie sur GPIO.5
    ' Choix 4,7,8 ou 9 voies sur GPIO.3 et 4
    
    '*****************************************************************************
    '*****************************************************************************
    '
    @    __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _PWRTE_ON & _MCLRE_OFF & _CP_OFF & _BODEN_ON
    
    
    DEFINE OSC 4
    DEFINE OSCCAL_1K 1
    DEFINE INTHAND _Marker
    
    ADCON0		= 0
    ANSEL		= 0
    CMCON		= 7
    
    OPTION_REG	= %10000110     'Disable Pull-Ups - PSA = 128
    INTCON		= %00100000		'TMR0 interrupt
    PIE1		= 0
    PIR1 		= 0
    
    '*****************************************************************************
    ' Constantes
    
    Mark 	CON 400
    Reload 	CON 80
    Neutral CON 1500
    GR		CON 8
    MPX		CON 9
    
    '*****************************************************************************
    ' Variables
    
    
    PROGRAM		var byte
    PROGRAMOLD	var byte
    
    FRAME4		var bit
    FRAME7		var bit
    FRAME8		var bit		
    
    CLEAR
    
    '*****************************************************************************
    ' I/Os
    
    GPIO 		=%00100000	'GPIO.5 = 1 at startup
    TRISIO 		=%00011000  'set GPIO3 GPIO4 as input GPIO.5 as Output
    
    '*****************************************************************************
    
    GOTO INIT
    
    '*****************************************************************************
    '*****************************************************************************
    Marker: ' Interruption - Génération de la trame
    
    TMR0 = Reload
    
    GPIO.5 	= 0
    PAUSEUS	Mark
    
    GPIO.5 	= 1				' Voie 1
    PAUSEUS 696
    
    GPIO.5 = 0
    PAUSEUS Mark
    
    GPIO.5 	= 1				' Voie 2
    PAUSEUS 796
    
    GPIO.5 = 0
    PAUSEUS Mark
    
    GPIO.5 	= 1				' Voie 3
    PAUSEUS 896
    
    GPIO.5 = 0
    PAUSEUS Mark
    
    GPIO.5 	= 1				' Voie 4
    PAUSEUS 992
    
    IF FRAME4 THEN Selection
    
    @ NOP
    GPIO.5 = 0
    PAUSEUS Mark
    
    GPIO.5 	= 1				' Voie 5 - 1500µS
    PAUSEUS 1096
    
    GPIO.5 = 0
    PAUSEUS Mark
    
    GPIO.5 	= 1				' Voie 6
    PAUSEUS 1196
    
    GPIO.5 = 0
    PAUSEUS Mark
    
    GPIO.5 	= 1				' Voie 7
    PAUSEUS 1290
    
    IF FRAME7 THEN Selection
    
    @ NOP
    GPIO.5 = 0
    PAUSEUS Mark
    
    GPIO.5 	= 1				' Voie 8
    PAUSEUS 1392
    
    IF FRAME8 THEN Selection
    
    @	NOP
    GPIO.5 = 0
    PAUSEUS Mark
    
    GPIO.5 	= 1				' Voie 9
    PAUSEUS 1496
    
    Selection:
    
    GPIO.5 = 0
    PAUSEUS Mark
    
    GPIO.5 = 1
    
    '*****************************************************************************
    'Lecture des Jumpers
    
    PROGRAM = GPIO & %00011000
    
    IF PROGRAMOLD <> PROGRAM THEN INIT
    
    '*****************************************************************************
    Start: 'Fin d'Interruption
    
    INTCON.2 = 0
    INTCON.7 = 1
    
    '*****************************************************************************
    CYCLE: 'Boucle de fonctionnement
    
    WHILE 1
    WEND
    
    '*****************************************************************************
    INIT: 'Lecture des Jumpers
    
    PROGRAM = GPIO & %00011000
    
    SELECT CASE Program
    
    	CASE 24
    	
    		FRAME4 = 1 : FRAME7 = 0 : FRAME8 = 0
    		
    	CASE 16
    	
    		FRAME4 = 0 : FRAME7 = 1 : FRAME8 = 0
    		
    	CASE 8
    	
    		FRAME4 = 0 : FRAME7 = 0 : FRAME8 = 1
    		
    	CASE ELSE
    	
    		FRAME4 = 0 : FRAME7 = 0 : FRAME8 = 0
    		
    END SELECT
    
    PROGRAMOLD = PROGRAM
    
    GOTO Start
    
    END
    If you want to have variable pulse length... just inc or dec the PAUSEUS value before the "START" Label


    And ... if you find something strange ... it is NOT an error !!!

    ( I told you Darrel would love it ....)

    Alain
    Last edited by Acetronics2; - 13th November 2008 at 15:45.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

Similar Threads

  1. Instant Interrupts - Revisited
    By Darrel Taylor in forum Code Examples
    Replies: 772
    Last Post: - 17th February 2016, 23:14

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