Data transfer to serial port via USB - Example with ADuCM350

Hello,

I am working with the ADuCM350 and I have to transfer a data array from the microcontroller to the serial port of my computer via USB. Could you provide a very rough example ? I am asking because there is only something very complex in the microcontroller SDK called "uCOS-II-USBD-x" and that need Micrium installation.

I honestly I am not the only one who need such an example.

Thanks in advance.

Best,

Jimmy

  • 0
    •  Analog Employees 
    on Dec 6, 2020 9:10 PM 2 months ago

    Hi Jimmy,

      Check out the following code for transferring an array of data via USB (Bulk transfer):-

    #include "ADuCM350_device.h"

    pADI_USB->DMA_ADDR0 = 0Xyyyy; /*0xyyyy = Memory address of the data block to send*/

    pADI_USB->DMA_CNT0 = 0Xzzzz; /*0xzzzz = Data block size*/

    pADI_USB->DMA_CTL0 |= 0X0F; /*DMA enable (D0) = 1; direction (D1) = 1; DMA mode (D2) = 1; interrupt enable (D3) = 1;*/

    pADI_USB->INTRTXE |= 0x1; /*Assuming endpoint 0*/

    pADI_USB->TXCSR |= 0x9400;/*Set the AUTOSET (D15), DMAREQEN (D12), and DMAREQMODE (D10)  to 1*/

    When the FIFO in the USB controller becomes available, the DMA controller requests the bus mastership and transfers a packet to the FIFO. With AUTOSET set, the USB controller automatically sets the TXPKTRDY bit. This process continues until the entire data block has been transferred to the USB controller. (Refer to pg.181 of ADUCM350 HRM)

     Regrads,

    Akila

  • Hi Akila,

    Thanks a lot. But there is no possibility to "select DMA_ADDR0" for instance. The struct "p_ADI_USB" only contains the following pointer:

      pADI_USB->DMA->ADDR
    

    Should I use this one ?

    This is the same with "pADI_USB->TXCSR" that does not exist, but this variant exists:

    pADI_USB->EP->TXCSR_P |= 0x9400;

    Another question, how can I set the speed and a defined port in the serial COM port for communication with the PC ?

    Best,

    Jimmy

  • 0
    •  Analog Employees 
    on Jan 11, 2021 5:58 PM 1 month ago in reply to JimmySIP

    Hi Jimmy,

           That's right. Use 

     pADI_USB->DMA->ADDR = 0xyyyy;  

     pADI_USB->DMA->CNT = 0xzzzz; 

     pADI_USB->DMA->CTL |= 0x0F;

    and

     pADI_USB->EP->TXCSR_P |= 0x9400;

  • Hi Akila,

    Thanks a lot for that.

    I am also wondering how I could send data to the serial COM port of the computer ? Can I set a baudrate, fixed port, and so on ?

    Best Regards,

    Jimmy

  • 0
    •  Analog Employees 
    on Jan 12, 2021 5:43 PM 1 month ago in reply to JimmySIP

    Hi Jimmy,

                      Are you using USB to RS232/RS422 converter, connecting USB end to microcontroller and RS232 end to COM port of PC? Is this the setup?

    Or is it the RS232 COM port connected to UART port of microcontroller?..