DT Instant Interrupts


Closed Thread
Results 1 to 39 of 39

Hybrid View

  1. #1
    Join Date
    Sep 2007
    Posts
    50


    Did you find this post helpful? Yes | No

    Default

    I have SPWM_INT working really well. I am doing 16 ch of PWM on a pic 18F2410 32 MHz. The pwm is running at 100Hz 8 bit resolution.

    Quote Originally Posted by Darrel Taylor View Post

    SPWM_INT uses Timer1, so if you also want a Blinky light, you'll need to use a different Timer. (0, 2 or 3)
    <br>
    Here is where I am having trouble. I tried to add a blinky from the DT_INTS-18 example and change it to timer0 with no success. Darrel, can you point me in the correct direction?
    Best Regards,

    Kurt A. Kroh
    KrohTech

    “Goodbye and thanks for all the fish”

  2. #2
    Join Date
    Sep 2007
    Posts
    50


    Did you find this post helpful? Yes | No

    Default

    here is my current code, changed to 101 PWM resolution to reduce overhead

    Code:
    '-----------------------------SPWM INT-----------------------------
    CLEAR
    
    INCLUDE "DT_INTS-18.bas"            ; Base Interrupt System
    INCLUDE "SPWM_INT.bas"              ; Software PWM module
    INCLUDE "ReEnterPBP-18.bas"    ; Include if using PBP interrupts
    
    LED2 VAR PORTA.5
    
    DEFINE SPWM_FREQ  100                ; SPWM Frequency
    DEFINE SPWM_RES   101               ; SPWM Resolution
    
    DutyVars   VAR BYTE[16]              ; 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]
      DutyVar4 VAR DutyVars[3]
      DutyVar5 VAR DutyVars[4]
      DutyVar6 VAR DutyVars[5]
      DutyVar7 VAR DutyVars[6]
      DutyVar8 VAR DutyVars[7]
      DutyVar9 VAR DutyVars[8]          
      DutyVar10 VAR DutyVars[9]         
      DutyVar11 VAR DutyVars[10]
      DutyVar12 VAR DutyVars[11]
      DutyVar13 VAR DutyVars[12]
      DutyVar14 VAR DutyVars[13]
      DutyVar15 VAR DutyVars[14]
      DutyVar16 VAR DutyVars[15]
      
    ASM
    SPWM_LIST  macro                    ; Define Pin's to use for SPWM
         SPWM_PIN  PORTB, 0, _DutyVar1  ; and the associated DutyCycle variables
         SPWM_PIN  PORTB, 1, _DutyVar2  ; Notice the underscore before variables
         SPWM_PIN  PORTB, 2, _DutyVar3
         SPWM_PIN  PORTB, 3, _DutyVar4
         SPWM_PIN  PORTB, 4, _DutyVar5
         SPWM_PIN  PORTB, 5, _DutyVar6
         SPWM_PIN  PORTB, 6, _DutyVar7
         SPWM_PIN  PORTB, 7, _DutyVar8
         SPWM_PIN  PORTC, 0, _DutyVar9 
         SPWM_PIN  PORTC, 1, _DutyVar10 
         SPWM_PIN  PORTC, 2, _DutyVar11
         SPWM_PIN  PORTC, 3, _DutyVar12
         SPWM_PIN  PORTC, 4, _DutyVar13
         SPWM_PIN  PORTC, 5, _DutyVar14
         SPWM_PIN  PORTC, 6, _DutyVar15
         SPWM_PIN  PORTC, 7, _DutyVar16 
         endm
      SPWM_INIT  SPWM_LIST              ; Initialize the Pins
    ENDASM
    
    ASM
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
            INT_Handler   TMR1_INT,  SPWMhandler,  ASM,  yes
            INT_Handler   TMR0_INT,  _ToggleLED2,  PBP,  yes
    
        endm
        INT_CREATE                      ; Creates the interrupt processor
    ENDASM
    
    T0CON = %10010010             ; T0 = 16-bit, Prescaler 8
    @ INT_ENABLE  TMR1_INT        ; enable Timer 1 interrupts
    @ INT_ENABLE  TMR0_INT        ; enable Timer 0 interrupts
    
    
    '-----------------------------Main Program-----------------------------
    Main:
    Best Regards,

    Kurt A. Kroh
    KrohTech

    “Goodbye and thanks for all the fish”

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


    Did you find this post helpful? Yes | No

    Default

    I think the Cut&Paste didn't catch everything.

    Can you post the Main: and Handler parts?
    Thanks.
    DT

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


    Did you find this post helpful? Yes | No

    Default

    OH!, nevermind!

    ADCON1 = $0F

    DT

  5. #5
    Join Date
    Sep 2007
    Posts
    50


    Did you find this post helpful? Yes | No

    Default

    Thanks Darrel,

    That worked, I think I need to learn that register, TIME TO HIT THE DATA SHEET...
    Best Regards,

    Kurt A. Kroh
    KrohTech

    “Goodbye and thanks for all the fish”

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


    Did you find this post helpful? Yes | No

    Thumbs up

    That's a good one to learn.
    You'll need some variation of it in almost every program you write.

    Also, Since the TMR0_INT handler is only toggling a pin, it's not using any PBP system variables.

    You can change the TMR0_INT's "Type" to ASM.
    Then it won't be saving all the system variables when it doesn't need to. Time is critical with that many simultaneous PWM's.

    Then you can remove the ReEnterPBP-18.bas include file, which will save some RAM and Code space.
    DT

  7. #7
    Join Date
    Sep 2007
    Posts
    50


    Did you find this post helpful? Yes | No

    Default

    Thanks again Darrel,

    I just fully tested the SPWM_INT running 16 channels @ 100Hz 0-100 resolution. I tested each channel with a 7 amp led cluster (Agilight Brightstrip see below) of typical sign led strips powered through a MOSFET. This worked great. I am able to dim all the way down to 1% without any flicker and smoothly fade up to 100% with no flicker or noticeable stair stepping effect. This is smoother than when I used the older multi SPWM program.

    I really appreciate you help

    http://www.agilight.com/brightstrip/index.htm
    Best Regards,

    Kurt A. Kroh
    KrohTech

    “Goodbye and thanks for all the fish”

  8. #8
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,133


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    ...
    You can change the TMR0_INT's "Type" to ASM.
    Then it won't be saving all the system variables when it doesn't need to. Time is critical with that many simultaneous PWM's.

    Then you can remove the ReEnterPBP-18.bas include file, which will save some RAM and Code space.
    I may missed that little but critical details. Are these described somewhere Darrel?

    And may be others too that I am not aware off...

    Thanks,
    Ioannis

Similar Threads

  1. DT instant interrupts with mister_e keypad
    By Tomexx in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 26th November 2008, 20:02
  2. DT Instant Interrupts help
    By perides in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 26th November 2008, 18:41
  3. 12F683 and DT Instant Interrupts
    By jderson in forum mel PIC BASIC Pro
    Replies: 26
    Last Post: - 22nd November 2008, 12:47
  4. 18F1220 and DT Instant Interrupts
    By jderson in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 30th June 2008, 05:37
  5. Replies: 1
    Last Post: - 1st November 2006, 03:11

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