Instant Interrupts - Revisited


Closed Thread
Results 1 to 40 of 773

Hybrid View

  1. #1
    Join Date
    Jan 2014
    Posts
    84


    Did you find this post helpful? Yes | No

    Default Re: Instant Interrupts - Revisited

    Hi,
    in the last four days I spend my time with play of this code, but now I'm need to your help. I repeat, im begginer and at this time I dont know how work the intrerrupts.
    The Darrel Tylor code blink 3 leds at different intensity. I want to turn on 3 leds in background at different intensity without blinking. i tried this code, but leds blinks....where I'm wrong?


    Main: ; Simple Demo to fade/flash some LED's
    DutyVar1 = 5 ; Start with 3 LED's at different
    DutyVar2 = 50 ; brightness
    DutyVar3 = 150
    GOTO Main

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Re: Instant Interrupts - Revisited

    That is not enough code to make a whole program.
    Please post your entire code.

    Also include the PIC you are using and the compiler version.
    DT

  3. #3
    Join Date
    Jan 2014
    Posts
    84


    Did you find this post helpful? Yes | No

    Default Re: Instant Interrupts - Revisited

    I work with 12F683 and MPASM v5.42.

    1000 x thx

    Code :

    '************************************************* ***************
    '* Name : Test_SPWM.pbp *
    '* Author : Darrel Taylor *
    '* Date : 9/30/2006 *
    '* Version : 1.0 *
    '* Notes : *
    '* : *
    '************************************************* ***************
    ; Initialize your hardware first

    DEFINE OSC 20
    CLEAR

    INCLUDE "..\DT_INTS-14.bas" ; Base Interrupt System
    INCLUDE "SPWM_INT.bas" ; Software PWM module
    wsave VAR BYTE $20 SYSTEM
    wsave1 VAR BYTE $A0 SYSTEM

    DEFINE SPWM_FREQ 40 ; SPWM Frequency
    DEFINE SPWM_RES 256 ; SPWM Resolution

    DutyVars VAR BYTE[3] ; DutyCycle Variables
    DutyVar1 VAR DutyVars[0] ; group them in an array for easy access
    DutyVar2 VAR DutyVars[1] ; with FOR loops etc.
    DutyVar3 VAR DutyVars[2]

    ASM
    SPWM_LIST macro ; Define PIN's to use for SPWM
    SPWM_PIN GPIO, 0, _DutyVar1
    SPWM_PIN GPIO, 1, _DutyVar2
    SPWM_PIN GPIO, 2, _DutyVar3
    endm
    SPWM_INIT SPWM_LIST ; Initialize the Pins
    ENDASM

    ASM
    INT_LIST macro ; IntSource, Label, Type, ResetFlag?
    INT_Handler TMR1_INT, SPWMhandler, ASM, yes
    endm
    INT_CREATE ; Creates the interrupt processor
    ENDASM

    @ INT_ENABLE TMR1_INT ; enable Timer 1 interrupts

    ;_________________________________________________ ____________________________

    RandVar VAR WORD : RandVar = 12345
    LoopCount VAR WORD

    Main:
    DutyVar1 = 5
    DutyVar2 = 50
    DutyVar3 = 150

    GOTO Main

  4. #4
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,144


    Did you find this post helpful? Yes | No

    Default Re: Instant Interrupts - Revisited

    How fast is the led blinking?

    Ioannis

  5. #5
    Join Date
    Jan 2014
    Posts
    84


    Did you find this post helpful? Yes | No

    Default Re: Instant Interrupts - Revisited

    I apreciate 4-5 blinks/sec

  6. #6
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Re: Instant Interrupts - Revisited

    1) Are you really using a 20 Mhz crystal?
    Not very many people use crystals on an 8-pin PIC.

    2) 40 Hz is really slow for LED's
    Increase the SPWM_FREQ.
    DT

  7. #7
    Join Date
    Jan 2014
    Posts
    84


    Did you find this post helpful? Yes | No

    Default Re: Instant Interrupts - Revisited

    I use in config : @_INTRC_OSC_NOCLKOUT . its necessary to use external crystal ?
    I increased the SPWM_FREQ at 219 and leds are relativelly well
    Last edited by midali; - 8th January 2014 at 19:35.

  8. #8
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Re: Instant Interrupts - Revisited

    No, it is not necessary to use a crystal.
    But your DEFINE OSC must match your actual oscillator frequency.

    If you have specified the internal oscillator in your configs, then the default is 4Mhz, not 20Mhz.
    And your program is running at 1/5th the speed it is supposed to.
    DT

  9. #9
    Join Date
    Jan 2014
    Posts
    84


    Did you find this post helpful? Yes | No

    Default Re: Instant Interrupts - Revisited

    Thank you for your help and patience !

Similar Threads

  1. Clock using Instant Interrupts
    By PICpocket in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 16th February 2009, 21:43
  2. DT instant interrupts with mister_e keypad
    By Tomexx in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 26th November 2008, 20:02
  3. DT's Instant Interrupts trouble
    By Tomexx in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 24th November 2008, 20:48
  4. Keypad and DT's Instant Interrupts
    By Homerclese in forum General
    Replies: 11
    Last Post: - 27th April 2007, 06:32
  5. Replies: 1
    Last Post: - 1st November 2006, 03:11

Members who have read this thread : 5

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

Tags for this Thread

Posting Permissions

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