Multi Slow speed PWM and Instant Interrupts


Closed Thread
Results 1 to 9 of 9

Hybrid View

  1. #1
    Join Date
    Dec 2007
    Location
    Paris
    Posts
    101


    Did you find this post helpful? Yes | No

    Default

    Trying to get that setup working too, PIC18F14K50 and these:

    Code:
    INCLUDE "cdc_desc.bas"
    INCLUDE "DT_INTS-18.bas"
    INCLUDE "ReEnterPBP-18.bas" 
    INCLUDE "SPWM_INT.bas"
    INCLUDE "USB_ASM_Service.pbp"
    
    ASM
    ;----[High Priority Interrupts]-------------------------
    INT_LIST  macro     ; IntSource,          Label,  Type, ResetFlag?
            INT_Handler     INT0_INT,   _ButtonPressed,   PBP,  Yes
            INT_Handler   TMR1_INT,  SPWMhandler,  ASM,  yes
            INT_Handler     USB_INT,  _DoUSBSERVICE,   PBP,  yes
        endm
        INT_CREATE ; Creates the High Priority interrupt processor
    ENDASM
    However I'm having a hard time to get a smooth PWM output that is not perturbed by the DoUSBSERVICE routine... So far the best results I got is by inserting INT_DISABLE USB_INT / INT_ENABLE USB_INT into the SPWMhandler, however the output still flicker quite a bit. I also tried to turn USB_INT into a lower priority interrupt but that doesn't work (the PIC does crash).

    Is there a particular solution to make them work together? any hint on this would be greatly appreciated.

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


    Did you find this post helpful? Yes | No

    Default

    USB_INT should be an ASM "type" interrupt. I think we talked about that before.
    Make it low priority.

    How many SPWMints, what freq, what resolution.
    Not enough information, and I'd guess you are maxed out.

    Remember ... 25,600 interrupts per second for SPWM_RES 256 @ 100hz.
    DT

  3. #3
    Join Date
    Dec 2007
    Location
    Paris
    Posts
    101


    Did you find this post helpful? Yes | No

    Default

    Yes I understand that it is very CPU intensive... Here's the settings for the PWM:

    CPU @ 48Mhz 3 PWM channels with
    DEFINE SPWM_FREQ 100 'SPWM Frequency
    DEFINE SPWM_RES 256 'SPWM Resolution

    I tried dropping SPWM_FREQ to 40 and SPWM_RES 100 but it is still very irregular. It works well when de D+/D- lines are disconnected, so there's good chances the USB interrupt does takes too much time.

    USB INT does contains much more than just USBSERVICE. There's about a dozen PBP instructions to update de status of "Plugged, RX_READY and TX_READY" and this is why I have it as a PBP interrupt. Tried turning it into an ASM interrupt and it does work too, but that's very confusing to me??!
    Last edited by aberco; - 2nd November 2010 at 11:20.

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


    Did you find this post helpful? Yes | No

    Default

    It's called "USB_ASM_Service" for a reason.
    It's ASM compatible, even though it uses some PBP syntax.

    Those PBP statements don't use any of PBP's system registers.

    When you made it ASM, was it also Low Priority?
    DT

  5. #5
    Join Date
    Dec 2007
    Location
    Paris
    Posts
    101


    Did you find this post helpful? Yes | No

    Default

    Hey Darrel, ok I understand "ASM" better.

    I have everything as high priority interrupt and deleted all my little tweaking attempt. I got it to work nicely now, even with SPWM_FREQ 200. I however don't understand why at first it was not working as is, must have done something wrong

    Anyway thanks for your help! this is a great routine!

Similar Threads

  1. 18F2420, instant interrupts, and TMR0
    By dhickman in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 11th March 2009, 18:33

Members who have read this thread : 1

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