USB CDC with DT_INTS


Closed Thread
Results 1 to 8 of 8

Hybrid View

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

    Default Re: USB CDC with DT_INTS

    Tachyon,

    USBSERVICE is a PBP statement, not an ASM statement. So it can't be in an ASM/ENDASM block.
    It must be like this ...
    Code:
    '----[Interrupt handler -- Service USB]--------------------------------------------------
    USBServiceISR:
            USBSERVICE
    @   INT_RETURN
    Then add an underscore in the INT_Handler statement.
    Code:
    '---[Interrupts List]---
    ASM
    INT_LIST  macro   ;Source,   Label,          Type,  ResetFlag?
        INT_Handler   USB_INT,  _USBServiceISR,  ASM,   yes
        endm
        INT_CREATE
    ENDASM
    You can only have 1 USBINIT in your program.
    And there should never be a USBSERVICE after the interrupt has been enabled.
    Interrupting a USBSERVICE to do a USBSERVICE can cause bad things to happen.
    Code:
    '---[Initialize Chip]--------------------------------------------------------------------
    InitChip:
    	PAUSE 100
    	USBINIT
    	USBSERVICE
    	UIE = $7F
    	UEIE = $9F
    ;	PAUSE 500
    ;	USBINIT
    ;	USBSERVICE
    	@ INT_ENABLE USB_INT
    ;	USBSERVICE
    The following program works perfectly here on a LAB-XUSB with an 18F4550.
    Code:
    '***************************************************************************************
    '	Title:		USB CDC and DT_INTS Testing
    '	CPU:		18F4458
    '   Clock:		20 MHz External Clock
    '
    '****************************************************************************************
    
    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    _CONFIG1H, _FOSC_ECPLLIO_EC_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
    	__CONFIG    _CONFIG2L, _PWRT_OFF_2L & _BOR_ON_2L & _BORV_2_2L & _VREGEN_ON_2L
    	__CONFIG    _CONFIG2H, _WDT_OFF_2H & _WDTPS_512_2H
    	__CONFIG    _CONFIG3H, _CCP2MX_ON_3H & _PBADEN_OFF_3H & _LPT1OSC_OFF_3H & _MCLRE_OFF_3H
    	__CONFIG    _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _XINST_OFF_4L & _DEBUG_OFF_4L
    ENDASM
    
    
    DEFINE OSC 48
    DEFINE NO_CLRWDT 1
    DEFINE USB_BUS_SENSE PORTD,3
    
    INCLUDE "cdc_desc.bas"
    INCLUDE "DT_INTS-18.bas"
    
    '---[Interrupts List]---
    ASM
    INT_LIST  macro   ;Source,   Label,          Type,  ResetFlag?
        INT_Handler   USB_INT,  _USBServiceISR,  ASM,   yes
        endm
        INT_CREATE
    ENDASM
    
    
    	goto InitChip
    
    
    '----[Interrupt handler -- Service USB]--------------------------------------------------
    USBServiceISR:
    	USBSERVICE
    @	INT_RETURN
    
    
    
    '---[Initialize Chip]--------------------------------------------------------------------
    InitChip:
    	PAUSE 100
    	USBINIT
    	USBSERVICE
    	UIE = $7F
    	UEIE = $9F
    	@ INT_ENABLE USB_INT
    
    	PORTA = 0
    	PORTB = 0
    	PORTC = 0
    	PORTD = 0
    	PORTE = 0
    
    	'setup port i/o
    	TRISA = %00000000
    	TRISB = %11111111
    	TRISC = %00110000
    	TRISD = %00001000
    	TRISE = %00000000
    
    	'all dig
    	ADCON1 = %00001111
    	
    	'enable port b pullups
    	INTCON2.7 = 0
    
    	
    
    Main:
    	goto Main
    
    
    	end
    Make sure you have 0.1uF bypass capacitors from VDD to VSS.
    And some people say that you also need 0.1uF from the USB +5V to VSS, but I've never had to do that.
    DT

  2. #2
    Join Date
    Feb 2011
    Location
    Michigan, USA
    Posts
    33

    Default Re: USB CDC with DT_INTS

    Hello Darrel,
    Sorry but that code is not connecting either. I copied everything over. And it compiles OK.
    What is also concerning me is the version I have with the timer interrupt is also dropping the connection after about a half hour. This is after I shortened the interrupt time to 1.3ms. Should I shorten the time even more? Is it because its a USB 1.1 computer? I haven't seen
    it drop the connection on a USB 2.0 computer yet.

    I've tried all I could think of on the USB Interrupt version. I might have to give up on that one
    for now and just focus on the timer interrupt version.

    So I'll increase the size of cap on Vusb pin and see if that helps.

    Do you think shortening the interrupt time will help?

    Thank you for all your help.
    Regards,
    Mike

  3. #3
    Join Date
    Feb 2011
    Location
    Michigan, USA
    Posts
    33

    Default Re: USB CDC with DT_INTS

    Just an update if anyone is interested. The PIC on the USB 2.0 computer is over 6 hours and
    has not dropped its connection. The same PIC on the USB 1.1 computer could not hold its
    connection for longer than 20 minutes or so.
    I am using a timer interrupt (0.6ms) to execute the USBSERVICE routine. If I ever find an
    answer why than I will post it back here.

    As far as the USB interrupt using DT-INTS-18 v34 for CDC, I haven't a clue why it won't
    connect for me. I know the interrupt is not happening at all. And I know my hardware
    works with the timer interrupt. If I find what I'm missing than I'll post that also.

    Mike

  4. #4
    Join Date
    Feb 2011
    Location
    Michigan, USA
    Posts
    33

    Default Re: USB CDC with DT_INTS

    Eureka! Yes I'm that happy. I found the reason why the USB interrupt was not working.
    It was the line I uncommented in the cdc_desc.bas file (#define USE_USB_BUS_SENSE_IO).

    I read somewhere, don't remember where, when using self powered circuit one should
    define a Vbus sense I/0 and uncomment the line above in the cdc_desc file. This is supposed to make the design more USB compliant. If the user unplugs the USB cable, the 3V reg. is turned off. I verified this with a meter and peeked how it is done in the assembly USBSERVICE routine.

    I don't mind if the 3V reg. stays on in my design. I am using a power supply. But I guess
    it might be a concern in a battery powered design.

    I should have mentioned the uncommenting bit in my post. I ASSUMED....

    Anyway, thanks Darrel for giving me my timer back.
    This is fantastic -
    Mike

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