USBSERVICE + serout2 problem


Closed Thread
Results 1 to 40 of 52

Hybrid View

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

    Default

    Hi mackrackit and thanks for your attention,

    "When using Darrel's includes do not add any USBInit"

    Yes I know that, however if I comment USBInit and USBService it kill the program. It still run but it is not seen by the computer anymore. The include seems to be effective as I can use the PLUGGED, RX_READY and TX_READY variables inside my program without declaring them. They all read 0 whatever is happening though...

    Was it tested on a 13/14K50 before? With CDC profile? or am I doing something wrong? The usage seems pretty straightforward though...

    rsocor01, it is nice to know that all these can be used. Darrel's code for handling the USB is a nice time saver over handling USBService manually. It's just a nightmare when the program gets complicated.

    Thanks to both of you,
    Antoine.
    Last edited by aberco; - 25th August 2010 at 02:47.

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default

    Quote Originally Posted by aberco View Post
    Was it tested on a 13/14K50 before? With CDC profile? or am I doing something wrong? The usage seems pretty straightforward though...
    I never have but I am sure Darrel did...

    Code:
    buffer[0] = buffer
    That will not work.
    Dave
    Always wear safety glasses while programming.

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

    Default

    Ok, let's just go back to the original demo without any alteration:

    Code:
    ' USB sample program for PIC18F4550 CDC serial port emulation
    '  Requires PBP 2.60 or later
    
    '  Compilation of this program requires that specific support files be
    '  available in the source directory.  For detailed information, see
    '  the file PBP\USB18\USB.TXT.
    
    ASM
    CONFIG CPUDIV=NOCLKDIV ; CPU runing at full speed
    CONFIG USBDIV=OFF ; Low speed USB clock diviser disabled, not used here
    CONFIG FOSC=HS ; Use of High Speed crystal oscillator
    CONFIG PLLEN=ON ; Enable PLL multiplier, 12Mhz oscilator x 4
    CONFIG PCLKEN=ON ; Primary clock source is enabled
    CONFIG FCMEN=OFF ; Failsafe clock off
    CONFIG IESO=OFF ; Oscillator switchover mode disabled
    CONFIG WDTEN=ON ; Watchdog timer on
    CONFIG WDTPS=512 ; Watchdog divider is 512
    CONFIG MCLRE=OFF ; Disable MCLR pin, enable RC3
    CONFIG STVREN=ON ; Stack full/underflow will cause reset
    CONFIG LVP=OFF ; Low voltage programming disabled
    CONFIG BBSIZ=OFF ; 512kW block boot size
    CONFIG XINST=OFF ; Extended instruction mode disabled
    ENDASM
    
    Include	"cdc_desc.bas"	' Include the CDC descriptors
    INCLUDE "USB_ASM_Service.pbp"  ' USB Init and Service interrupt routines
    
    'Define pin function
    TRISA = %00000000 'PortA all digital output
    TRISB = %00000000 'PortB all digital output
    TRISC = %00000000 'PortC all digital output
    
    ANSEL = %00000000 'Disable analog input on other pins
    ANSELH = %00000000 'Disable analog input on other pins
    
    'Define weak pullups
    WPUA = %00000000 'No weak pullup on portA
    WPUB = %00000000 'No weak pullup on portB
        
    Define  OSC     48
    
    buffer	Var	Byte[16]
    cnt	Var	Byte
    
    'Pin function declaration
    
    Pause 10
    
    '	USBInit			' Get USB going
    
    ' Wait for USB input
    idleloop:
    '	USBService		' Must service USB regularly
    	cnt = 16		' Specify input buffer size
    	USBIn 3, buffer, cnt, idleloop
    
    ' Message received
    	buffer[0] = "H"
    	buffer[1] = "e"
    	buffer[2] = "l"
    	buffer[3] = "l"
    	buffer[4] = "o"
    	buffer[5] = " "
    	buffer[6] = "W"
    	buffer[7] = "o"
    	buffer[8] = "r"
    	buffer[9] = "l"
    	buffer[10] = "d"
    	buffer[11] = 13
    	buffer[12] = 10
    	buffer[13] = 0
    
    outloop:
    '	USBService		' Must service USB regularly
    	USBOut 3, buffer, 14, outloop
    
    	Goto idleloop		' Wait for next buffer
    ... does not work.

    I must say that after 2 days of digging the forum and the internet I am starting to get clueless about what to do to solve it. Is there a timer or an interrupt register to set up manually in order to run it properly? I could try to run it on a 18F4550 board I have but that won't solve the problem for my 13K50 project.

    Also, I found out that USB_ASM_Service.pbp does not work in conjunction with INDT_INTS-18.bas and SPWM_INT.bas from Darell. I will need at least the latter, so maybe I should find another solution than actually trying to use USB_ASM_Service.pbp.

    Any idea for troubleshooting this? or pointing to an interrupt solution that I could use? I'm starting to get clueless. Any help greatly appreciated!

    BTW, I'm running PBP 2.60 in MCS 4.0.0.0, in conjunction with MPLAB 8.53.

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default

    Looks like we will have to wait till Darrel gets back to help with his includes, I do not see where the problem is.

    If you do not use USB_ASM_Service.pbp the USB works?
    Dave
    Always wear safety glasses while programming.

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

    Default

    Yes, it does not matters if I comment USB_ASM_Service.pbp or not. The demo does work perfectly with USBINIT and USBService, but as soon as I comment these I loose USB enumeration.

    I also wish to use USB_ASM_Service.pbp in conjunction with Darrel's SPWM_INT.bas which does not seems possible right now (it gives an INTHAND symbol cannot be refefined error, which is normal because it appears twice). I could do the USBService interrupt with the SPWM interrupt at the same time... I do not have tight frequency requirements for the PWM signal (about 100Hz or more), what I'm interested in is the duty cycle. The main idea of my project is based on controlling the brightness of 3 LEDs by sending serial commands through USB CDC. I have to use the 13K50 for this application, but there's only one ECCP module.

    But first things first, making USB_ASM_Service.pbp work with the demo! Hopefully Darrel can spare a little time to check what is going wrong here.

  6. #6
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default

    I am not at a place to test this to see if it makes a difference or not...

    I (for no good reason) have this after all DEFINES and Variable declarations.
    Code:
    Include	"cdc_desc.bas"	' Include the CDC descriptors
    INCLUDE "USB_ASM_Service.pbp"  ' USB Init and Service interrupt routines
    Which is where your first USBInt is...

    And maybe for the other ISR.
    From USB_ASM_SERVICE.pbp
    To use other high priority interrupts you can add the define *
    '* DEFINE INT_HOOK handlers *
    '* handlers will be called on each high priority interrupt *
    '* The handlers must be ASM Interrupt compatible
    Dave
    Always wear safety glasses while programming.

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

    Default

    I can easily do the test, moved the includes just before the start of the main program with the same result, does not enumerate . Still work like a charm the old way though.

    Tomorrow I will get my 18F4550 board out and try.

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