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 to all,
    I'm a beginner , so I need your help , please! .I want to play with 3 LEDs with pwm control . For begin I tried to compile a example from Darrel Taylor's page : http://www.darreltaylor.com/DT_INTS-14/SPWM.html .
    the compilation was succesfull for 18F's and work perfectly.
    I use MCS 3.0.7.0 and MAPSM v5.42 compiler . I want to compile the sorce code for 12F683 and I have this error:

    Error[101] C:\LUCRU\TEST_SPWM_INT.ASM 238 : ERROR: (wsave variable not found,)
    Error[101] C:\LUCRU\TEST_SPWM_INT.ASM 204 : ERROR: (" Add:" wsave VAR BYTE $20 SYSTEM)
    Error[101] C:\LUCRU\TEST_SPWM_INT.ASM 259 : ERROR: (Chip has RAM in BANK1, but wsave1 was not found.)
    Error[101] C:\LUCRU\TEST_SPWM_INT.ASM 211 : ERROR: (" Add:" wsave1 VAR BYTE $A0 SYSTEM)


    I use this 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

    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: ; Simple Demo to fade/flash some LED's
    DutyVar1 = 5 ; Start with 3 LED's at different
    DutyVar2 = 50 ; brightness
    DutyVar3 = 150
    pause 3000

    FOR LoopCount = 1 to 4 ; Reapeat 4 times
    for DutyVar1 = 0 to 150 ; Fade LED1 UP
    pause 10
    RANDOM RandVar
    DutyVar3 = RandVar & $3F ; Give LED3 a random dutycycle
    next DutyVar1

    for DutyVar1 = 150 to 0 STEP -1 ; Fade LED1 Down
    pause 10
    RANDOM RandVar
    DutyVar2 = RandVar & $3F ; Give LED2 a random dutycycle
    next DutyVar1
    NEXT LoopCount
    GOTO Main




    Can somedody help me to finish my ideea ?

    1000xthx

  2. #2
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,116


    Did you find this post helpful? Yes | No

    Default Re: Instant Interrupts - Revisited

    The answer is in the Error messages:

    Quote Originally Posted by midali View Post
    hi to all,
    Error[101] C:\LUCRU\TEST_SPWM_INT.ASM 238 : ERROR: (wsave variable not found,)
    Error[101] C:\LUCRU\TEST_SPWM_INT.ASM 204 : ERROR: (" Add:" wsave VAR BYTE $20 SYSTEM)
    Error[101] C:\LUCRU\TEST_SPWM_INT.ASM 259 : ERROR: (Chip has RAM in BANK1, but wsave1 was not found.)
    Error[101] C:\LUCRU\TEST_SPWM_INT.ASM 211 : ERROR: (" Add:" wsave1 VAR BYTE $A0 SYSTEM)
    It says, " Add:" wsave VAR BYTE $20 SYSTEM
    and also " Add:" wsave1 VAR BYTE $A0 SYSTEM

    So, your code might look like this now:

    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:                               ; Simple Demo to fade/flash some LED's
        DutyVar1 = 5                        ; Start with 3 LED's at different
        DutyVar2 = 50                       ; brightness
        DutyVar3 = 150
        pause 3000
         
        FOR LoopCount = 1 to 4              ; Reapeat 4 times
            for DutyVar1 = 0 to 150         ; Fade LED1 UP
                pause 10
                RANDOM  RandVar             
                DutyVar3 = RandVar & $3F          ; Give LED3 a random dutycycle
            next DutyVar1
             
            for DutyVar1 = 150 to 0 STEP -1 ; Fade LED1 Down
                pause 10
                RANDOM  RandVar
                DutyVar2 = RandVar & $3F         ; Give LED2 a random dutycycle
            next DutyVar1
        NEXT LoopCount     
    GOTO Main
    Ioannis

  3. #3
    Join Date
    Jan 2014
    Posts
    84


    Did you find this post helpful? Yes | No

    Default Re: Instant Interrupts - Revisited

    1000 X Ioannis ! Now its ok !

  4. #4
    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

  5. #5
    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

  6. #6
    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

  7. #7
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,116


    Did you find this post helpful? Yes | No

    Default Re: Instant Interrupts - Revisited

    How fast is the led blinking?

    Ioannis

  8. #8
    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

  9. #9
    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

  10. #10
    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.

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 : 10

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