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

    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

  2. #2
    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.

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

    Default

    My shipping container just arrived yesterday with all my stuff from California, still unloading it.
    Hopefully I can get some computers setup soon to be able to work on this stuff again.

    Can't sit in the forum at work, just too busy during the day.

    If you haven't figured it out by next week, I'll be back on it.
    Sorry, I haven't been much help.
    DT

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

    Default

    No Darrel, you have been very helpful so far, at least to set me on the right course to fix issues.

    I'm much more of an hardware person, getting better and better at programming but some time simple software tricks are not obvious to me... However when it comes to reading datasheets and understanding hardware peripherals, registers and configuration bits I feel at home.

    I will carry on progress one step at a time

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

    Default

    I think that most of my USB problems are solved now!

    I rewrote the USB Out routine as such:

    Code:
    '*******************************************************
    'Writing data to USB port
    '*******************************************************
    DoUSBOut:
    
    USBBufferSizeTX = 0
    FOR Counter = 1 TO USBBufferSizeMax 'Calculate number of valid bytes within the string
    IF USBBuffer [Counter - 1] > 0 THEN USBBufferSizeTX = USBBufferSizeTX + 1
    NEXT Counter
    
    IF TX_READY THEN 'USB data can be transmitted
        TX_READY = 0 'Clear USB data send flag
        USBOUT 3, USBBuffer, USBBufferSizeTX, DoUSBOut
    ENDIF
    
    FOR Counter = 1 TO USBBufferSizeMax 'Clear the USB buffer after data has been sent
    USBBuffer [Counter - 1] = 0
    NEXT Counter
    
    RETURN
    - Fist step is to calculate how many bytes are used in the string (not = 0)
    - Second, sending data
    - third, blanking the data buffer for next operation

    I have no more garbage data in my strings, and I was able to remove the Pause without any data loss. Transmission is very fast now, with over 10kB/s (I have large conversion routines between my DoUSBOut, could even be faster without these).

    Now onto other problems, especially getting all the interrupts to work together,and implementing ADC and ultra-low power routine.

    What about publishing the generic code for CDC? I'll let you decide since it is actually minor modification to code you have written.

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

    Default Re: USBSERVICE + serout2 problem

    And everything collapsed!

    The CDC USB routine was working well until now. It is working very well on my early prototypes, I made 3 more identical one and the PIC just stop running randomly after a few seconds up to several minutes. USB communication stops and LEDs turns off. It still respond to the INT0 interrupt though, and resume normal operation after reset... until it crashes again randomly.

    I am puzzled as the hardware is strictly identical, the only difference I could spot is in the silicon revision of the PIC18LF14K50, says 0000006 on the working batch and 0000005 on the batch that crashes. I have inserted a simple blinking LED loop routine at the very beginning of my code, and it still crashes and stop blinking. Removing part of the program related to USB solve the crashing problem so I would think that there is something wrong in the USB CDC code I have modified.

    Problem is that in the revision errata there is nothing linked to the USB SIE, and I am totally clueless about where to start to debug this issue. What could be wrong to have the PIC crash at a random time interval? some kind of buffer overflow?

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

    Default Re: USBSERVICE + serout2 problem

    A bit more debugging, it seems that only the USBIN side does crash.

    Code:
    '*******************************************************
    'Reading incoming data from USB port
    '*******************************************************
    DoUSBIn:
    
    FOR counter = 1 TO USBBufferSizeMax 'Clear the USB buffer before data is received
        USBBuffer [counter - 1] = 0
    NEXT COUNTER
    
    WHILE !RX_READY                                                                   
        GOSUB UpdateLEDStatus
    WEND
                                       
    IF RX_READY THEN
        RX_READY = 0 'Clear USB data received flag
        USBBufferCount = USBBufferSizeRX
        USBIn 3, USBBuffer, USBBufferCount, DoUSBIn    
    ENDIF
    
    RETURN
    At random the UpdateLEDStatus subroutine stop to be serviced, and the USBIN does not receive anymore data. When it crashes, RX_READY = 0, then if I send data RX_READY = 1 and just stay there, without being cleared. the USBOUT side toes work well though, even when the IN side has crashed.

    Might have something to do with USB_ASM_Service.pbp not working properly?

    -> A bit more debug introducing some LED blink to see if the USB_ASM_Service is being called: it stops being called when it crashes...
    Last edited by aberco; - 10th December 2011 at 20:15.

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