UART-USB using MSP430

Discussion in 'Embedded Systems and Microcontrollers' started by CrackJack, May 9, 2011.

  1. CrackJack

    Thread Starter Active Member

    Aug 7, 2009
    127
    0
    hello everyone,
    i WOULD like to send data from a flash to computer using UART-USB converter... i have a TI-MSP430f2619 micro-controller.

    Can anyone please give me heads up how to get started? which UART-USB should i use? i know TI have their own TUSB3410, but i found tat was very complex as compared to MCP2210 and Silicon Labs 21xx.

    Is there a compulsion that i have to use only TI UART-USB for development with
    MSP430? or i can use any??

    thankss..
     
  2. HallMark

    Member

    Apr 3, 2011
    89
    5
    Means you want to send the data from Microcontroller to PC/Laptop?
     
  3. CrackJack

    Thread Starter Active Member

    Aug 7, 2009
    127
    0
    yes... and i would like to save the contents of my MSP430 into a file over USB.
    can i do that?
     
  4. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    I took a very quick glance at your MCU specs. It has non usb ports (that is as far I can see, I can be wrong here) But it has 4 serial ports. I have used USB converter chips from FTDI like this. http://www.ftdichip.com/Products/ICs/FT232H.htm very simple to use.
     
  5. terra

    New Member

    May 12, 2011
    13
    0
    Option No1: Sending data through UART and convert the UART-USB at the PC using FTDI or other available cable and it is easy

    Option 2 : Use UART to USB chip from TI, SiLab etc then send to USB
    Either option as a programmer you no need to send a data through UART

    Option 3; Chane to MCU which has inbuilt USB then write the USB driver for the Chip and send through USB
     
  6. HallMark

    Member

    Apr 3, 2011
    89
    5
    Don't know perfectly that writing directly into USB drive is possible or not but yes i have used Data Logger from VDrive to write into USB stick. :)
     
  7. CrackJack

    Thread Starter Active Member

    Aug 7, 2009
    127
    0
    At everyone, thanks a lot, i actually bought a demo kit from MAXIM to perform SPI-USB interface using MAXIM3420e.
    I tried their enumeration code, but somehow, i was unable to get through it.

    has anyone used this chip MAX3420e with MSP430? Can anyone please suggest me how to proceed with it?

    I have made some changes in the enumeration code that Maxim has provided... however, i could not get through the SPI_Test function... please help, attached is the code...
    Code ( (Unknown Language)):
    1. void SPI_Init(void)
    2. {
    3.   unsigned int i;
    4.  
    5.   WDTCTL = WDTPW+WDTHOLD;                   // Stop watchdog timer
    6.  /* if (CALBC1_8MHZ ==0xFF || CALDCO_8MHZ == 0xFF)                                    
    7.   {  
    8.     while(1);                               // If calibration constants erased
    9.                                             // do not load, trap CPU!!
    10.   }  
    11.   BCSCTL3 |= XCAP_3;                        // Configure load caps*/
    12.   BCSCTL1 = CALBC1_8MHZ;                    // Set DCO to 8MHz
    13.   DCOCTL = CALDCO_8MHZ;
    14.   // Wait for xtal to stabilize
    15.  /* do
    16.   {
    17.   IFG1 &= ~OFIFG;                           // Clear OSCFault flag
    18.   for (i = 0x47FF; i > 0; i--);             // Time for flag to set
    19.   }
    20.   while ((IFG1 & OFIFG));                   // OSCFault flag still set?
    21.   for(i=2100;i>0;i--);                      // Now with stable ACLK, wait for
    22.   */                                          // DCO to stabilize.
    23.  // UCA1CTL1 &= UCSWRST;                      // reset SPI mode
    24.  
    25.  
    26.  
    27.   ///port settings///
    28.   SPI_MOSI;                                 // Assign port 3.6 in MOSI mode
    29.   SPI_MISO;                                 // Assign port 3.7 in MISO mode
    30.   SPI_CLK;                                  // Assign port 5.0 as SPI clk
    31.   Slave_Select;                             // Assign port 5.1 as SS#
    32.   INT_From_Slave;                           // Assign port 5.2 as Intr from slave
    33.  
    34.  
    35.  
    36.   ///// D I R E C T I O N  ////////////
    37.   MISO_DIR_INPUT;
    38.   MOSI_DIR_OUTPUT;
    39.  
    40.   SPI_CLK_DIR_OUTPUT;                       // Assign SPI Clk as Output
    41.   Slave_Intrpt_DIR_IN;                      // Assign P5.0 as input
    42.   Slave_Select_DIR_OUT;                     // Assign P5.1 as output
    43.  
    44.  
    45.  
    46.   ///// register settings///
    47.   UCA1CTL0 |= UCMST+UCSYNC+UCMSB;           // 3-pin, 8-bit SPI master
    48.   UCA1CTL1 |= UCSSEL_2;                     // SMCLK
    49.   UCA1BR0 = 0x02;                           // 2
    50.   UCA1BR1 = 0;                              //
    51.   UCA1MCTL = 0;                             // No modulation
    52.   UC1IE |= UCA1TXIE + UCA1RXIE;
    53.  
    54.   UCA1CTL1 &= ~UCSWRST;                     // **Initialize USCI state machine**
    55.  
    56.   Slave_Reset;                              // ss low
    57.   UCA1TXBUF = 0x01;
    58.   Slave_Set;                                //ss high
    59.  
    60. }
    61. void wreg(BYTE reg, BYTE dat)
    62. {
    63.   BYTE dum;
    64.   unsigned int i;
    65.   Slave_Reset;                   // Set SS# low
    66.  
    67.   UCA1TXBUF = reg+2;             // send the register number with the DIR bit (b1) set to WRITE
    68.   while (UCA1STAT & UCBUSY);     // loop if data still being sent
    69.  
    70.   dum = UCA1RXBUF;
    71.  
    72.   UCA1TXBUF = dat;               // send the data
    73.   while (UCA1STAT & UCBUSY);     // loop if data still being sent
    74.  
    75.   dum = UCA1RXBUF;
    76.  
    77.   for (i = 0x2; i > 0; i--);   // little time to put CS in high state
    78.   Slave_Set;                     // set SS# high
    79. }
    80.  
    81. BYTE rreg(BYTE reg)
    82. {
    83. BYTE dum;
    84.   int i;
    85.   P5OUT &= ~0x02;
    86.  // Slave_Reset;  
    87.   UCA1TXBUF = reg;               // reg number w. dir=0 (IN)
    88.   while (UCA1STAT & UCBUSY);     // loop if data still being sent
    89.   dum = UCA1RXBUF;               // NECESSARY TO RE-ENABLE THE INPUT BUFFER in BYTE MODE
    90.   UCA1TXBUF=0x00;                // data is don't care, we're clocking in MISO bits
    91.   while (UCA1STAT & UCBUSY);     // loop if data still being sent
    92.   for (i = 0x2; i > 0; i--);   // little time to put CS in high state
    93.   P5OUT |= 0x02;
    94.   //Slave_Set;  
    95.   return(UCA1RXBUF);
    96. }
    97.  
    98.  
    99. void test_SPI(void)         // Use this to check your versions of the rreg and wreg functions
    100. {
    101. BYTE j,wr,rd;
    102. SPI_Init();                 // Configure and initialize the uP's SPI port
    103. wreg(rPINCTL,bmFDUPSPI);    // MAX3420: SPI=full-duplex
    104. wreg(rUSBCTL,bmCHIPRES);    // reset the MAX3420E
    105. wreg(rUSBCTL,0);            // remove the reset
    106. wr=0x01;                    // initial register write value
    107. for(j=0; j<8; j++)
    108.   {
    109.   wreg(rUSBIEN,wr);
    110.   rd = rreg(rUSBIEN);          
    111.   wr <<= 1;       // Put a breakpoint here. Values of 'rd' should be 01,02,04,08,10,20,40,80
    112.   _NOP();
    113.   }
    114. }
    115.  
    116.  
    117.  
    the complete code is available online as well from the link... http://pdfserv.maxim-ic.com/en/an/AN3690.pdf
     
  8. CrackJack

    Thread Starter Active Member

    Aug 7, 2009
    127
    0

    Have you ever tried the Maxim ones? i have spent too much time on Maxim now, and would like to continue using them...
    what are your suggestions over it??

    Please help...
     
  9. CrackJack

    Thread Starter Active Member

    Aug 7, 2009
    127
    0
    heeloo... anyone has any replies yet???
     
  10. GetDeviceInfo

    Senior Member

    Jun 7, 2009
    1,571
    230
    I've had good success with the MAXIM3420e, although I'm not sure what support it will have going forward, due to the peripheral being common place on many micros.

    I'm not familiar with the TI-MSP430f2619, preffering Atmels 8051/AVRs, but that shouldn't be a hindrance.

    I've found this to be the required code to initialize the device. Managing the toggle is the other headache, but once properly coded, you can move on.

    Code ( (Unknown Language)):
    1.  
    2. void Reset_MAX(void)
    3. {
    4.  wMAX(rPINCTL,(bmFDUPSPI|bmINTLEVEL)); // MAX3421E: Full duplex mode, INTLEVEL=0, POSINT=1 for pos edge interrupt pin
    5.  wMAX(rUSBCTL,bmCHIPRES);  // chip reset This stops the oscillator
    6.  wMAX(rUSBCTL,0x00);       // remove the reset
    7.  while(!(rMAX(rUSBIRQ) & bmOSCOKIRQ)) ;  // hang until the PLL stabilizes
    8.  wMAX(rIOPINS2,0x00);
    9.  sendserial(sprintf(serialbuffer,"- MAX3421 has been reset \n"));
    10. }
    11.  

    OOPs, I lied, I'm using the host (MAX3421), not the device (20e) device.
     
    Last edited: May 19, 2011
    CrackJack likes this.
Loading...