This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

usb communication f28377s

Other Parts Discussed in Thread: TMS320F28335, CONTROLSUITE

Hi,


I want to send and receive data between the PC and f28377s evaluation card.


In the Example_28377SLaunchPad demo, where STOUD is used for sending data to the PC (I have no problem with it), I have tried to receive data from de PC using STDIN, but I can't.


In the usb_dev_serial_cpu01 example, I think I have to buy a "Control Card". But I Just want to use the USB connection, I understand that the control card have the micro and mini usb connection available.


In the sci_echoback_cpu01 example. It says that I have to connect de GPIO28 and GPIO29 to a DB9 cable (I can’t find that pins), as I say I just want to use the USB connection. I think I have to change the boot mode with the switches, maybe it allows me to use SCIA via usb connection, but I’m not sure. I have seen that is used for programming the flash or booting the f28377s.


Editing the sci_echoback_cpu01 example I have tried to use de SCIB with the GPIO87 and GPIO86, but nothing appear in the oscilloscope.


In the chapter 9 of Texas Instruments teaching materials TMS320F2833x, I found an example, where the SCI is used with ISR, it doesn’t need any connections. I copied the code and tested it, there were some errors, but I fixed it quite easily, when I download the program nothing appear in the terminal, using putty, Hercules, terminal in code composer studio, Arduino monitor serie. I will let you the code if you want to check it.


If anyone can help me, telling me the way I don’t need to use an extra connection, or if it is possible share with me any simple code. I have spent days trying to receive a data from the PC.

//

//      Lab9_4: TMS320F28335

//      (c) Frank Bormann

//

//###########################################################################

//

// FILE:     Lab9_4.c

//

// TITLE:    DSP28 SCI - Communication to PC - Terminal

//                  SCI-Setup: 9600 Baud, 8 Bit , ODD Parity , 1 Stopbit

//                  SCI - TX and RX - Interrupt are used in this Lab

//                  SCI - TX and RX - FIFO are used in this Lab

//                  DSP waits for "Texas" and answers with "Instruments"

//                  Watchdog active , serviced solely in main-loop

//###########################################################################

//  Ver | dd mmm yyyy | Who  | Description of changes

// =====|=============|======|===============================================

//  3.0 | 08 Jul 2009 | F.B. | adapted for ControlCard28335 @ 20MHz

//  3.1 | 15 Nov 2009 | F.B  | Lab9_4 for F28335 @30MHz and PE revision 5

//###########################################################################

#include "F28x_Project.h"

#include <string.h>

 

/*// External Function prototypes

extern void InitSysCtrl(void);

extern void InitPieCtrl(void);

extern void InitPieVectTable(void);*/

 

// Prototype statements for functions found within this file.

void Gpio_select(void);

void SCIA_init(void);

interrupt void SCIA_TX_isr(void); // SCI-A Transmit Interrupt Service

interrupt void SCIA_RX_isr(void); // SCI-A Receive  Interrupt Service

 

// Global Variables

char message[]={" Instruments! \n\r"};

char buffer[16];

 

unsigned long int c1=0, c2=0;

//###########################################################################

//                                      main code

//###########################################################################

void main(void)

{

       InitSysCtrl();      // Basic Core Initialization

                                  // SYSCLK=150MHz, HISPCLK=75MHz, LSPCLK=37.5MHz

       EALLOW;

       //SysCtrlRegs.WDCR= 0x00AF;               // Re-enable the watchdog

       WdRegs.WDCR.all = 0x00AF;

       EDIS;               // 0x00E8  to disable the Watchdog , Prescaler = 1

                                  // 0x00AF  to NOT disable the Watchdog, Prescaler = 64

 

       Gpio_select();      // GPIO9, GPIO11, GPIO34 and GPIO49 as output

                                  // to 4 LEDs at Peripheral Explorer

 

       InitPieCtrl();             // default status of PIE; in DSP2833x_PieCtrl.c

 

       InitPieVectTable(); // init PIE vector table; in DSP2833x_PieVect.c

 

       // re-map PIE - entry for SCI-A-TX and SCI-A-RX

       EALLOW;

       //PieVectTable.SCITXINTA = &SCIA_TX_isr;

       //PieVectTable.SCIRXINTA = &SCIA_RX_isr;

       PieVectTable.SCIA_TX_INT = &SCIA_TX_isr;

       PieVectTable.SCIA_RX_INT = &SCIA_RX_isr;

       EDIS;

 

       SCIA_init();  // Initalize SCI

 

    // Enable SCI-A TX Interrupt Group9 interupt 2

       PieCtrlRegs.PIEIER9.bit.INTx2 = 1;

       // Enable SCI-A RX Interrupt Group9 interupt 1

       PieCtrlRegs.PIEIER9.bit.INTx1 = 1;

 

       // Enable INT9 for SCIA-TX and SCIA-RX:

    IER = 0x100;

 

       // Enable global Interrupts and higher priority real-time debug events:

       EINT;   // Enable Global interrupt INTM

       ERTM;   // Enable Global realtime interrupt DBGM

 

       while(1)

       {

              EALLOW;

             //SysCtrlRegs.WDKEY = 0x55;                    // Service watchdog #1

             //SysCtrlRegs.WDKEY = 0xAA;                    // Service watchdog #2

              WdRegs.WDKEY.bit.WDKEY = 0x55; //.bit.WDKEY

              WdRegs.WDKEY.bit.WDKEY = 0xAA; //.bit.WDKEY

             EDIS;

       }

}

 

void Gpio_select(void)

{

       EALLOW;

       GpioCtrlRegs.GPAMUX1.all = 0;                  // GPIO15 ... GPIO0 = General Puropse I/O

       GpioCtrlRegs.GPAMUX2.all = 0;                  // GPIO31 ... GPIO16 = General Purpose I/O

 

       GpioCtrlRegs.GPAMUX2.bit.GPIO28 = 1;    // SCIRXDA

       GpioCtrlRegs.GPAMUX2.bit.GPIO29 = 1;    // SCITXDA

 

       GpioCtrlRegs.GPBMUX1.all = 0;                  // GPIO47 ... GPIO32 = General Purpose I/O

       GpioCtrlRegs.GPBMUX2.all = 0;                  // GPIO63 ... GPIO48 = General Purpose I/O

       GpioCtrlRegs.GPCMUX1.all = 0;                  // GPIO79 ... GPIO64 = General Purpose I/O

       GpioCtrlRegs.GPCMUX2.all = 0;                  // GPIO87 ... GPIO80 = General Purpose I/O

 

       GpioCtrlRegs.GPADIR.all = 0;

       GpioCtrlRegs.GPADIR.bit.GPIO9 = 1;             // peripheral explorer: LED LD1 at GPIO9

       GpioCtrlRegs.GPADIR.bit.GPIO11 = 1;            // peripheral explorer: LED LD2 at GPIO11

 

       GpioCtrlRegs.GPBDIR.all = 0;                   // GPIO63-32 as inputs

       GpioCtrlRegs.GPBDIR.bit.GPIO34 = 1;     // peripheral explorer: LED LD3 at GPIO34

       GpioCtrlRegs.GPBDIR.bit.GPIO49 = 1; // peripheral explorer: LED LD4 at GPIO49

 

       GpioCtrlRegs.GPCDIR.all = 0;                   // GPIO87-64 as inputs

       EDIS;

}

 

void SCIA_init()

{

       SciaRegs.SCICCR.all =0x0027;      // 1 stop bit,  No loopback

                                        // ODD parity,8 char bits,

                                        // async mode, idle-line protocol

       SciaRegs.SCICTL1.all =0x0003;     // enable TX, RX, internal SCICLK,

                                        // Disable RX ERR, SLEEP, TXWAKE

 

       // SYSCLOCKOUT = 150MHz; LSPCLK = 1/4 = 37.5 MHz

       // BRR = (LSPCLK / (9600 x 8)) -1

       // BRR = 487  gives 9605 Baud

       //SciaRegs.SCIHBAUD    = 487 >> 8;             // Highbyte

       //SciaRegs.SCILBAUD    = 487 & 0x00FF;  // Lowbyte

       SciaRegs.SCIHBAUD.all    = 487 >> 8;           // Highbyte //.bit.BAUD

       SciaRegs.SCILBAUD.all    = 487 & 0x00FF; // Lowbyte  //.bit.BAUD

 

       SciaRegs.SCICTL2.bit.TXINTENA = 1;             // enable SCI-A Tx-ISR

       SciaRegs.SCICTL2.bit.RXBKINTENA = 1;    // enable SCI_A Rx-ISR

 

       SciaRegs.SCIFFTX.all = 0xC060;    // bit 15 = 1 : relinquish from Reset

                                                            // bit 14 = 1 : Enable FIFO

                                                            // bit 6 = 1 :  CLR TXFFINT-Flag

                                                            // bit 5 = 1 :  enable TX FIFO match

                                                            // bit 4-0 :  TX-ISR, if TX FIFO is 0(empty)

       SciaRegs.SCIFFCT.all = 0x0000;    // Set FIFO transfer delay to 0

 

       SciaRegs.SCIFFRX.all = 0xE065;    // Rx interrupt level = 5

 

       SciaRegs.SCICTL1.all = 0x0023;    // Relinquish SCI from Reset

}

 

// SCI-A Transmit Interrupt Service

interrupt void SCIA_TX_isr(void)

{

       unsigned int i;

       // copy 16 character into SCI-A TX buffer

       //for(i=0;i<16;i++) SciaRegs.SCITXBUF= message[i];

       for(i=0;i<16;i++) SciaRegs.SCITXBUF.all= message[i]; //SCITXBUF.bit.TXDT

       // Acknowledge this interrupt to receive more interrupts from group 9

    PieCtrlRegs.PIEACK.all = PIEACK_GROUP9;

    c1++;

}

 

// SCI-A Receive Interrupt Service

interrupt void SCIA_RX_isr(void)

{

       int i;

       //for (i=0;i<16;i++) buffer[i]= SciaRegs.SCIRXBUF.bit.RXDT;

       for (i=0;i<16;i++) buffer[i]= SciaRegs.SCIRXBUF.bit.SAR;

       if (strncmp(buffer, "Texas", 5) == 0)

       {

             SciaRegs.SCIFFTX.bit.TXFIFOXRESET =1;  // enable TXFIFO

             SciaRegs.SCIFFTX.bit.TXFFINTCLR = 1 ;  // force TX-ISR

       }

 

       SciaRegs.SCIFFRX.bit.RXFIFORESET = 0;   // reset RX-FIFO pointer

       SciaRegs.SCIFFRX.bit.RXFIFORESET = 1;   // enable RX-operation

       SciaRegs.SCIFFRX.bit.RXFFINTCLR = 1;    // clear RX-FIFO INT Flag

       PieCtrlRegs.PIEACK.all = PIEACK_GROUP9;

       c2++;

}

 

//===========================================================================

// End of SourceCode.

//===========================================================================

  • Hi,

    The USB module on the F2837x silicon is not exposed to the MiniUSB connector on the LaunchPad. You will need to use a Control Card which has a micro-USB connector which is connected to the USB module on chip.  You may be able to use GPIO pin connections for USB communication on the Launchpad but I am not sure if the USB GPIO pins are pinned out on the LaunchPad.

    The LaunchPad has GPIO 84/85 pinned out to the mini-USB connector. These pins are routed through an FTDI chip which enables serial (SCI/UART) communication through the USB connector to your PC.

    To get sci_echoback working, change the pins from 28/29 to 84/85.  You may also need to change the baudrate dividers if using the external oscillator (XTAL) because I think the LaunchPad uses a 10MHz external oscillator and the example in controlSUITE is designed for the controCard which uses a 20MHz external oscillator.

    sal

  • Hi Sal,

    I am trying to do the same thing I believe, and have the code working up to the point where I need to re-adjust the baud rates. According to the schematics, the crystal powering the FTDI is a 12MHz crystal, while the system clock seems to be the 10MHz crystal. Which of these are we supposed to use?

    Thanks,
    -Adam
  • It would depend on the SYSCLK and Low Speed Peripheral Clock. Please see the SCI chapter of the TRM. The Launchpad I believe has a 10MHz external crystal. It also as 2 internal oscillators at 10MHz. The LSPCLK is by default the SYSCLK / 4.

    Hope this helps.

    sal
  • Hi Sal,

    Thank you for your response on this reasonably old topic. I configured GPIO73 on my F28377S LaundPad to be XTALOUT, with the SYSCLK selected and a divider of 1 (please see below):

    EALLOW;
    ClkCfgRegs.CLKSRCCTL3.bit.XCLKOUTSEL = 0; // Should set clock src to SYSCLK (200MHz)
    ClkCfgRegs.XCLKOUTDIVSEL.bit.XCLKOUTDIV = 0; // Set divider to 1
    GpioCtrlRegs.GPCMUX1.bit.GPIO73 = 3; // GPIO73 -> XTALOUT
    EDIS;

    However, when I probe GPIO73 (pin 12 on JP2), I see a 100MHz wave instead of my expected 200MHz. The SYSCLK should be 200MHz based on the comments I've read from the code (I am working with ControlSuite's echo_back example), and this portion here defines it pretty well:

    //  Example:   200 MHz devices:
    //             CLKIN is a 10 MHz crystal or internal 10 MHz oscillator
    //
    //             In step 1 the user specified the PLL multiplier = 40 for a
    //             200 MHz CPU clock (SYSCLKOUT = 200 MHz).
    //
    //             In this case, the CPU_RATE will be 5.000L
    //             Uncomment the line: #define CPU_RATE 5.000L
    //
    
    #define CPU_RATE   5.00L   // for a 200MHz CPU clock speed (SYSCLKOUT)

    I have the XTAL_OSC oscillator selected (10MHz) an IMULT of 40, an FMULT of 0, and a PLLCLK_BY_2 which strangely has a value of 1

        //  PLLSYSCLK = (XTAL_OSC) * (IMULT + FMULT) / (PLLSYSCLKDIV)
        //
    #ifdef _LAUNCHXL_F28377S
        InitSysPll(XTAL_OSC,IMULT_40,FMULT_0,PLLCLK_BY_2);

    Do you know why I am seeing my SYSCLK output as 100MHz instead of my expected 200MHz?

  • I am not sure. I would suggest double-checking the TRM and bit definitions and what is being written to those registers by the set-up code.

    If you cannot correct it, I suggest opening up another thread so it can be assigned to the more appropriate engineer here and the title would more accurately reflect the issue.

    Thanks!
    sal