Instant Interrupts - Revisited


Closed Thread
Results 1 to 40 of 773

Hybrid View

  1. #1
    willem's Avatar
    willem Guest


    Did you find this post helpful? Yes | No

    Question DT_INTS-14 and Multi_SPWM

    Dear readers,

    Although DT_INTS-14 and Multi_SPWM working great if using seperate, I can't get them running combined ....
    I included them together with ReEnterPBP.bas getting errors like

    ERROR Line 10: Redefinition of VAR. (Multi_SPWM.pbp)
    ERROR Line 13: Redefinition of VAR. (Multi_SPWM.pbp)
    ERROR Line 14: Redefinition of VAR. (Multi_SPWM.pbp)
    ERROR Line 18: Redefinition of VAR. (Multi_SPWM.pbp)
    ERROR Line 20: Redefinition of VAR. (Multi_SPWM.pbp)

    (if the order I included them is changed I got about same errors by DT_INTS-14)
    I guess it's because same variables (psave, wsave etc) used in both of them but I don't have the ASM experience to solve the problem and would appreciate any advise/tips.
    Also tips to use another way to interrupt (INT_INT on RB0) Multi_SPWM are welcome...

    Thank you !

    Willem

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


    Did you find this post helpful? Yes | No

    Default

    Hi willem,

    It's a little more than the duplicate variables. They also both want exclusive use of the interrupt vector, and they handle the interrupts in a different way too.

    I've thought about writing a version for DT_INTS, but just haven't had the time. It's quite doable, but it definately takes some ASM.

    Sorry for the bad news,
    DT

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


    Did you find this post helpful? Yes | No

    Cool Software PWM for DT_INTS-xx

    Ok Willem,

    Well, I decided to forget about the things I should have done this weekend, and went ahead and re-wrote the SPWM program to work with the Instant Interrupt system.

    I've added a few things, and it works a little different this time around. So, be sure to look close at the example.

    It'll work with either the 18F or 14-bit versions, even though I only put it in the DT_INTS-14 section for now.

    SPWM_INT
    http://www.darreltaylor.com/DT_INTS-14/SPWM.html

    Enjoy,
    DT

  4. #4
    Baddzso's Avatar
    Baddzso Guest


    Did you find this post helpful? Yes | No

    Default EUSART int

    hi all! hi Darrel!
    I have a question: with these int handler routines can i use hserin with interrupt? because i think the on interrupt command too slow, i have to wait about 1 ms after first char to the pic jump to int routine and receive other chars with hserin.
    many thanks!

    pic: 16f690, intosc, ~7,3728MHz

    (I don't have time to read everything, sorry if this question are answered...)
    Attached Files Attached Files
    Last edited by Baddzso; - 3rd October 2006 at 00:17.

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


    Did you find this post helpful? Yes | No

    Default

    Well,

    With the example given, Sure!

    But with 16F's, if it gets more complicated, you might have problems. The problem is that when you have more than 1 interrupt source, the HSERIN will stop the others from happening while it waits for the data to come in. But if you only intend to use the one interrupt from the USART. No Problem.

    If you were using an 18F with multiple INT sources, then the HSERIN could be in a Low Priority Interrupt without any problems at all.
    <br>
    DT

  6. #6
    willem's Avatar
    willem Guest


    Did you find this post helpful? Yes | No

    Thumbs up

    Hi Darrel,

    Great you decide to spent some weekend time on it! I'll hope you did enjoy your weekend anyway..
    I will check out the new Multi_SPWM version ASAP and post the results.
    Tnx a lot for your kind help.

    Regards,
    Willem

  7. #7
    Baddzso's Avatar
    Baddzso Guest


    Did you find this post helpful? Yes | No

    Smile

    Thank you for fast reply!
    And YES, YES, YES!!!
    It works! You are my rescuer!
    Thank You!
    Last edited by Baddzso; - 3rd October 2006 at 12:46.

  8. #8
    Join Date
    Jul 2005
    Posts
    93


    Did you find this post helpful? Yes | No

    Question Dt_ints-18 18f4550 usb_int usb bootloader

    I realize i'm likely behind about 2 years on this one.. i've been trying to modify Mister E / Darrel's USBDEMO code so that it works with my existing setup (a vb app that aquires 8 bit a/d result from the chip over usb cdc com port and also relays it to a serially connected 16F767.

    Can anyone make comment or point me to the appropriate thread discussing the DT INTS & Microchip bootloader on an 18F4550. I can't seem to get it going.. i'm doing a cdc device that otherwise works fine with the standard "usbservice" everywhere method.. so I know I don't have a hardware issue... basically what occurs with the new program is nothing. and stuff freezes too (Hyperterminal, my application) without getting any data (or so it seems).

    The device i'm building (i'm not showing you it's a total hackjob - that works) is "self powered" (i think) It runs off either a Max756 or a 7805C output or USB power, which on my hackjob of a board, is selected with jumpers. I've been attempting to detect the state of the usb connection, with limited success.. which currently involves 1x 100k and 1x 10k resistors to ground and USBV+ (5v from the usb cable) meeting in the middle at PORTB.0 which i've named "USBCONNECTED".

    Do I need the INTERRUPT_ORG defines, something else? I'd also like to implement a "SLEEP" command when the cable isnt connected, if anyone can tell me how to properly detect the cable and connection as this is a self powered device which will run off battery / solar power. I've done some research and have a working device but I think my newbish methods for doing things is limiting the speed and using more power than it needs to (logic draws about 60-120mA running full tilt while not connected to USB (no sleep)


    Basically I suppose my question is what should I do in addition to this code in order to use Darrels Interrupt system and use the Microchip Bootloader.


    The Instant Interrupts modified code, sorry for the long post:

  9. #9
    Join Date
    Jul 2005
    Posts
    93


    Did you find this post helpful? Yes | No

    Default the code

    Code:
    '   
        '   RCUSB     ; Edited 'USBDEMO' from Steve and Darrel
        '   =======
        '   
        '   File name  : RCUSBCOMM_INT.pbp
        '   Company    : Rytech Computing 
        '   Programmer : Steve Monfette, Darrel Taylor, Ryan Barrett
        '   Date       : November 23, 2008
        '   Device     : PIC18F4550 & 20MHZ crystal
        '
        '
        '   USB I/O 
        '
        '   Hardware:
        '   ---------
        '       ACTLED PORTB.1 
        '       INTERNAL DEBUG LEDS PORTD.0-3
        '       5v Logic A/D Monitor AN0 USB/Max756/7805 output
        '       Max756v AA/AAA input A/D Monitor AN1 5v max
        '       12v voltage/4 divider A/D Monitor AN2 20v max 7805C input
        '       Max4172 LOAD A/D Monitor AN3 5A max 
        '       Max4172 CHARGE A/D Monitor AN4 2A max
        '       USB Sense PORTB.0 USB Active High
        '       20 MHZ crystal & all the usual USB stuff
        '       Internal button PORTB.4
        '
        '
        '
        '   Pic Configuration
        '   =================
              asm
        __CONFIG    _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L  
        __CONFIG    _CONFIG1H, _FOSC_HSPLL_HS_1H & _FCMEN_OFF_1H & _IESO_OFF_1H 
        __CONFIG    _CONFIG2L, _PWRT_ON_2L & _BOR_ON_2L  & _BORV_2_2L  & _VREGEN_ON_2L   
        __CONFIG    _CONFIG2H, _WDT_OFF_2H 
        __CONFIG    _CONFIG3H, _MCLRE_ON_3H & _LPT1OSC_OFF_3H & _PBADEN_OFF_3H & _CCP2MX_ON_3H 
        __CONFIG    _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _ICPRT_OFF_4L  & _XINST_OFF_4L & _DEBUG_OFF_4L 
        endasm
        DEFINE OSC 48   
        DEFINE LOADER_USED 1
        DEFINE RESET_ORG 800h       
        Define    ADC_BITS      8    
        Define    ADC_CLOCK       3
        Define    ADC_SAMPLEUS  100
    
        DEFINE CCP1_REG PORTC 
        DEFINE CCP1_BIT 2 
        DEFINE CCP2_REG PORTC 
        DEFINE CCP2_BIT 1 
        '
        '   Hardware configuration
        '   ======================    
            '
            '   I/O and PORTs
            '   -------------  
        PORTB   =   0
        PORTC   =   0
        PORTD   =   0
        PORTE   =   0
        TRISB   =   %00010001
        TRISC   =   0
        TRISA   =   %11111111
        TRISD   =   %00000000
        TRISE   =   0
            '
            '   A/D converter
            '   -------------       
        ADCON0  =   %00000001       
        ADCON1  =   %00001000        
        ADCON2  =   %00000111      
            '
            '   CCP/PWM
            '   -------
    '    CCP1CON =   %00001100       ' CCP1, PWM mode
    '    CCP2CON =   %00001100       ' CCP2, PWM mode
    '    PR2     =   249             ' 12khz PWM Freq
    '    T2CON   =   %00000101       ' TMR2 on, prescaler 1:4
            '
            '   USB module
            '   ----------
       ' UCFG    var byte EXT        ' include UCFG register... Yeah Melabs didn't :o(
        ucfg    =   %00010100       ' enable internal USB pull-up, Full speed USB
    
        '   
        '   Interrupt definition
        '   ====================
            '   USB interrupt used to keep USB connection alive
    INCLUDE "DT_INTS-18.bas"    ' Base Interrupt System
    
    ASM
    INT_LIST  macro    ; IntSource,          Label,  Type, ResetFlag?
            INT_Handler    USB_INT,  _DoUSBService,   ASM,  yes
        endm
        INT_CREATE               ; Creates the interrupt processor
    endasm
    
    
        '   
        '   Variables & constants definition 
        '   ================================
        USBBufferSizeTX     con 16       ' input 
        USBBufferSizeRX     con 16       ' output
        USBBufferCount      Var Byte    '
        USBBufferIn         var byte[16] ' store incomming USB data
        USBBufferOut        Var Byte[16] ' store outgoing USB data       
        DataToSend          var byte[16] ' store ADCs & pushButton data to send to USB
        usb_device_state   var byte EXT
        CONFIGURED_STATE   CON EXT
        String1            var byte[16] ' hold 'USB DEMO' string       
            string1[0]="R"
            string1[1]="C"
            string1[2]="U"
            string1[3]="S"
            string1[4]="B"
            string1[5]="C"
            string1[6]="O"                                                                        
            string1[7]="M"  
            String1[8]="M"
            String1[9]="_"
            String1[10]="V"
            String1[11]="1"
            string1[12]="a"
            string1[13]=" "
            string1[14]=" "
            string1[15]=" "
        adval   Var    Byte[8]
        pwmduty var BYTE[4]
        PKTSUM  var byte
        QUAL    con 229
        ACTLED  var PORTB.1 
        spout   var PORTB.7
        DLED1   VAR PORTD.0
        DLED2   VAR PORTD.1
        DLED3   VAR PORTD.2
        DLED4   VAR PORTD.3
        USBCONNECTED var PORTB.0
    
           
        '   Constants definition 
        '   ====================
        GoDone              var ADCON0.1 ' ADC conversion
    
        '
        '   Macro(s) definition
        '   ===================
        asm 
    
    SendUSB macro array
        ;   Use to Copy an specific array to USBBufferOut AND send it
        ;   to USB bus
        variable i=0
        while i<16
            MOVE?BB (array+i),(_USBBufferOut+i)
    i+=1
        endw
        L?CALL _DoUSBOut
        endm
        endasm
    
        '   
        '   Software/Hardware initialisation
        '   ================================
    SwHwInit:
            HIGH DLED1
            Pause 490
            LOW DLED1
            Pause 500
            HIGH DLED1
            Pause 500
            LOW DLED1
            Pause 500
            HIGH DLED1
            Pause 500
            LOW DLED1
            Pause 500
            HIGH DLED1
            adval[0]= 0
            adval[1]= 0
            adval[2]= 0
            adval[3]= 0
            adval[4]= 0
            adval[5]= 0
            adval[6]= 0
            adval[7]= 0
            pwmduty[0]= 0
            pwmduty[1]= 0
            pwmduty[2]= 0
            pwmduty[3]= 0
            gosub DoUSBinit:
        '
        '   Main program start
        '   ==================
    Start: 
        '   
        '   ------------------------------------------------------------ 
            if (PORTB.4)!=0 then
    @       SendUSB _String1
            TOGGLE DLED2               
            endif
        toggle actled
    'GOSUB GetAD:
    'GOSUB toLCD:
    datatosend[0] = "A"
    DataToSend[1] = "V"
    DataToSend[2] = "B"
    Datatosend[3] = adval[0]
    Datatosend[4] = "C"
    Datatosend[5] = adval[2]
    Datatosend[6] = "D"
    Datatosend[7] = adval[3]
    Datatosend[8] = "E"
    Datatosend[9] = adval[4]
    DataToSend[10]= "F"
    Datatosend[11]= "Z"
    Datatosend[12]= "G"
    Datatosend[13]= "Y"
    Datatosend[14]= "Z"
    Datatosend[15]= "Z"
    @   SendUSB _DataToSend 
    gosub dousbin:
    GOTO START:
    
        '
        '                           Subroutines area
        '                           ================        
        '
        '
    DoUSBIn:
        '
        '   Check and receive data from the USB bus                            
        '   =======================================
    @  INT_DISABLE USB_INT
        USBBufferCount = USBBufferSizeRX                ' RX buffer size
        USBService                                      ' keep connection alive
        USBIn 1, USBBufferin, USBBufferCount, Timeout   ' read data, if available
    Timeout:                                            '
    @  INT_ENABLE USB_INT
        pwmduty[0]  = USBBUFFERIN[0] ' output to PORTB
        pwmduty[1]  = USBBufferin[1]
        pwmduty[2]  = USBBufferIn[2]
        pwmduty[3]  = USBBufferIn[3]
        return
        '
        '
        '
    DoUSBOut:
        '
        '   Send data to the USB bus & Wait for USB interface to attach                         
        '   ===========================================================
    @  INT_DISABLE USB_INT
        WaitPC:                                         '
        USBBufferCount = USBBufferSizeTX                ' TX buffer size
        USBService                                      ' keep connection alive
        USBOut 1, USBBufferOut, USBBufferCount, Waitpc  ' if bus available, transmit data
    @  INT_ENABLE USB_INT
        return
    
    ;_____________________________________________________________________________
    
    ;_______________________________________________________________________________________________________
    DoUSBinit:
        pause 500
        usbinit ' initialise USB...
        repeat  ' kick-start it
            usbservice
        until usb_device_state = CONFIGURED_STATE
    @   INT_ENABLE  USB_INT
    return
    ;_______________________________________________________________________________________________________
    DoUSBService:
        usbservice
    @   INT_RETURN
    ;_______________________________________________________________________________________________________
    GetAD:
    ADCON0=%00000001:Gosub GetSample:adval[0]=ADRESH 'get AN0 into adval[0] (7805 5v source voltage)
    toggle actled
    'ADCON0=%00001001:Gosub GetSample:adval[2]=ADRESH '12v Voltage -skip over AN1 (max756) get AN2 (12v battery source voltage divider output) into adval[2]
    'toggle actled
    'ADCON0=%00001101:Gosub GetSample:adval[3]=ADRESH   ' 12v Current -AN3 into adval[3] (max4172 12v battery current out)  
    'toggle actled
    'ADCON0=%00010001:Gosub GetSample:adval[4]=ADRESH   'AN4 into adval[4] (12v Input current)
    RETURN
    ;_______________________________________________________________________________________________________
    GetSample:
    PAUSEUS 100
    GoDone=1
    While GoDone=1:Wend
    Return
    ;_______________________________________________________________________________________________________
    ToLCD:
    SerOut2 spout,16468,[DEC3 QUAL,DEC3 adval[0],dec3 adval[2],Dec3 adval[3],dec3 pwmduty[0],dec3 pwmduty[1],dec3 pwmduty[2],DEC3 pwmduty[3],13,10]
    RETURN
    Last edited by ScaleRobotics; - 2nd December 2010 at 08:35.

  10. #10
    Join Date
    Jul 2005
    Posts
    93


    Did you find this post helpful? Yes | No

    Default

    thought i'd post my setup:

    MPASM 5.20
    PBP 2.50b
    MCS 3.0.0.5

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


    Did you find this post helpful? Yes | No

    Default

    What!
    You're trying to use a HID program with CDC?

    Well, you can start by using endpoint 3.

    Wouldn't be surprised if there are more problems though.
    <br>
    DT

  12. #12
    Join Date
    Jul 2005
    Posts
    93


    Did you find this post helpful? Yes | No

    Default

    I wasnt aware that the interrupt system was specifically for HID devices... anyways i'm back to trying to make my code work... it's really annoying.. the device works as expected, until i try and aquire a/d and send a serout2 in my main loop.. then it's device not recognized.. i think my brain might explode soon.

  13. #13
    Join Date
    Jul 2005
    Posts
    93


    Did you find this post helpful? Yes | No

    Default

    ahh i see what ur saying darrel.. i' used your code which points to endpoint 1.. i'm going to try it changing it to 3

Similar Threads

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

Members who have read this thread : 6

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