USBSERVICE + serout2 problem


Closed Thread
Results 1 to 40 of 52

Hybrid View

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

    Default

    If you are trying to tie together USB_ASM_Service and the routine I gave in this thread, it won't work as is.

    CDC uses a different endpoint than HID.
    DT

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

    Default

    Well, I managed to make it all work... possibly partially but so far so good!

    I can send and receive 32 bytes packets. However as you said I may have not modofied everything which makes TX_Ready and RX_Ready non functional. However they are tied to USB registers and should not be dependent to endpoints if my understanding of the datasheet was correct...



    I'm pasting here part of the main code that I used:

    Code:
    INCLUDE "cdc_desc.bas"
    INCLUDE "EEPROM_detect.pbp"
    
    '*******************************************************
    'Init the interrupt handling system
    '*******************************************************
    INCLUDE "DT_INTS-18.bas"     ; Base Interrupt System
    INCLUDE "ReEnterPBP-18.bas"     ; Include if using PBP interrupts
    
    ASM
    INT_LIST  macro     ; IntSource,          Label,  Type, ResetFlag?
            INT_Handler     USB_INT,  _DoUSBSERVICE,   PBP,  yes
            INT_Handler     TMR1_INT,   _TempCheck,   PBP,  Yes
            INT_Handler     INT0_INT,   _USBAttached,   PBP,  Yes
        endm
        INT_CREATE ; Creates the Low Priority interrupt processor
    ENDASM
    
    INCLUDE "USB_ASM_Service.pbp"
    Last edited by Darrel Taylor; - 10th October 2010 at 17:56. Reason: Incorrect Mod

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

    Default

    Last edited by Darrel Taylor; - 10th October 2010 at 16:56. Reason: Incorrect Mod
    Well ok, but what does makes it incorrect?

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

    Default

    Ok, there's indeed something that relates to endpoint. I understand that you use two bytes located within the USB RAM space to get the TX and RX reports.

    BD1STATOUT = _USBMEMORYADDRESS + 8 ; 408h or 208h
    BD1STATIN = _USBMEMORYADDRESS + 0Ch ; 40Ch or 20Ch
    Now I'm clueless about what this refers to... tried to look at the hid_desc.pbp/asm code and compare it with cdc_desc.pbp/asm, and also to look on the net for RAM endpoint allocation at these two address but no luck so far

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

    Default

    Follow up on the monologue, and after a day of digging through literature, I now have a slightly deeper understanding of the USB protocol. The more helpful was Microchip datasheet, within the USB section related to BDT RAM.



    200h is start of USB RAM for PIC18F1xK50, 400h for 18Fx550/x455/x450.

    I moved the allocations to Endpoint 3 for CDC usage:

    RXOWNED VAR BD3STATOUT.7 ; Out report Owned (OUT is PC to PIC)
    TXOWNED VAR BD3STATIN.7 ; IN report Owned (IN is PIC to PC)
    -------------------------------------------------------------------------------------------------------
    BD3STATOUT = _USBMEMORYADDRESS + 18h ; 418h or 218h
    BD3STATIN = _USBMEMORYADDRESS + 1Ch ; 41Ch or 21Ch
    Bit 7 of BDxSTAT states which device (SIE or CPU) owns the right to write or read into the dual ported USB RAM space, so this is what is used for the TX and RX ready flag.

    For some reason the compiler doesn't like the 3 in "BD3STATOUT and BD3STATIN" (Bad data type error). CONFIGURED_STATE should not differs between HID or CDC as it is not endpoint dependent.
    Last edited by aberco; - 13th October 2010 at 22:36.

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

    Default

    Quote Originally Posted by aberco View Post
    I moved the allocations to Endpoint 3 for CDC usage:
    ...
    For some reason the compiler doesn't like the 3 in "BD3STATOUT and BD3STATIN"
    You missed the EXT vars ...

    Code:
    BD3STATOUT         VAR BYTE EXT      ; OUT report status byte
    BD3STATIN          VAR BYTE EXT      ; IN report status byte
    DT

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

    Default

    Ah thanks! that was just above, an easy fix.

    RX_Ready seems to work! but TX_Ready is always true... maybe because the time when the OUT endpoint is owned by the SIE is so short that I can't see it? However if I do a loop that sends data as soon as the SIE is ready I have huge data loss.
    Right now I have to add a 200ms delay between each 32Bytes packets I send in order to avoid data transmission loss. It is rather slow... reading a 24LC512 at this speed would take a bit less than 4h.

    Am I missing something here?
    Last edited by aberco; - 13th October 2010 at 23:28.

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