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.

MSP432P401R: UART DMA send samples at 48kHz

Part Number: MSP432P401R
Other Parts Discussed in Thread: PCM2903C

Hi,

i am having some trouble to send 48kHz sample with UART via DMA.

I am sending blocks of values of 510 samples via DMA UART TX.

The problem is that on the other side i am not receiving all samples. In more or less 10 seconds of time i am sending 5457 blocks of values and on the other side only receiving 904.

I think the UART TX configuration is not fast enought: (Baud 460800)

const eUSCI_UART_Config uartConfig =
{
     EUSCI_A_UART_CLOCKSOURCE_SMCLK,          // SMCLK Clock Source
     6,
     8,
     32,
     EUSCI_A_UART_NO_PARITY,
     EUSCI_A_UART_LSB_FIRST,
     EUSCI_A_UART_ONE_STOP_BIT,
     EUSCI_A_UART_MODE,
     EUSCI_A_UART_OVERSAMPLING_BAUDRATE_GENERATION
};

Can UART baudrate be more than 460800? If yes what is the values for BRDIV, UCxBRF UCxBRS?

Edit: i was able to change the baudrate to 921600 with BRDIV=3, UCxBRF=4 and UCxBRS=2, but i am losing 2 block of data every 3 blocks send out

  • Hi Michael,

    I'm not sure if I understand your issue, but according to 'my' math sending 545 blocks of 510 samples per second over UART, where each sample is a byte, needs at minimum 545*510*10 = 2779500 baud, which is much more then your 921600 baud.


    BR
    Christoph
  • Hi Christoph,

    what do you mean 545 Blocks per second?
    If i get 48000 samples per second and 510 is one block of them, then i need to send 94 blocks per second right?
  • Hi Michael,

    I think I understand. In your first post you wrote "In more or less 10 seconds of time i am sending 5457 blocks of values ...". So I calculated 5457/10 blocks per second ...
    However, what is the the size of a 'sample' in bytes?

    BR
    Christoph
  • Hi,
    so i can set it to its maximum 1000000bps with BRDIV=3, UCxBRF=0 and UCxBRS=0
    Still losing packages 2 out of 3.

    Now what i dont understand is why can it handle it?
    48000 samples/s x 48bits = 2304000 bits/s -> this can be handle at 288000 Bautrate right?

    At maximum speed from 1.000.000bps it can handle up to 8.000.000 bits/s right?
  • Hi Christoph,

    thanks for pointing that. I think there my be something wrong on my code. It shouldnt be so much block of data.
    My DMA is not working properly then.
    Let me check
  • Hi,

    so DMA is ok, i have change now from 510 to 1020 values per block.
    It is sending now 270 Blocks/s * 1020 Bytes which is 275400 Bytes/s .

    275400 Bytes/s are 3 values of 16bit from ADC.

    Sampling rate is not exactly 48000Hz but almost 46000Hz thats why 275400/(6 values) = 45900 (8Bit)Samples/s

    But 275400Bytes/s is equal to 275400bps right? If one baud 8bit transfer is by MSP432.

    So how come cant it hanle it even when it is set it up as 1.000.000 bps?
  • "bps" (not-quite-correctly "baud") is bits/second, not Bytes/second. A UART byte is (1+8+1)=10 bits [one stop bit].

    Computing slightly differently: 48000 samples/sec * 3 samples * 2 Bytes/sample * 10 bits/Byte = 2880000 bits/second, i.e. 2.88Mbps. I've run the MSP432 UART at 3Mbps (check your FTDI chip -- I recall older ones can't match this), but I didn't find a receiver (Windows software) capable of keeping up. (I suppose I could have written one.)
  • Hi Bruce,
    i thought 1 Byte is 8bits right?
    So why do you multiply by 10bit/Byte?

    How can i set MSP432 UART at 3Mbps?

    I have made a custom software running with Qt and i can change the Baudrate on the code with no problem.

    I am using the FT231X and in its datasheet it says:
    "The FT231X supports all standard baud rates and non-standard baud rates from 183 Baud up to 3Mbaud."
  • To get 3Mbps from SMCLK=24MHz, divide by 8 (no oversampling). I've heard there's a spreadsheet floating around to do this, but this particular combination is pretty simple.
  • Hi Bruce,

    i change the Baudrate to 3Mbps and it looks like when i send a command from PC the MSP432 is not receiving all bytes.

    There is some bytes missing.  Is this because the MSP432 UART limitation is at 1MBps?

    I am runnigs at PCM_VCORE1 is this ok?

        GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_PJ, GPIO_PIN2 | GPIO_PIN3, GPIO_PRIMARY_MODULE_FUNCTION);
        CS_setExternalClockSourceFrequency(32768,48000000);
        PCM_setCoreVoltageLevel(PCM_VCORE1);
        FlashCtl_setWaitState(FLASH_BANK0, 2);
        FlashCtl_setWaitState(FLASH_BANK1, 2);
        CS_startHFXT(false);
    
        CS_initClockSignal(CS_MCLK , CS_HFXTCLK_SELECT, CS_CLOCK_DIVIDER_1);
        CS_initClockSignal(CS_SMCLK, CS_HFXTCLK_SELECT, CS_CLOCK_DIVIDER_2);

  • I don't know of a MSP432 UART limitation at 1Mbps. Is this documented somewhere?

    The Rx and Tx sides run at the same speed, so you've sped up Rx as well. That means that (for back-to-back bytes) your Rx ISR has (48/3*10=160) clocks to put away an Rx byte before the next one arrives. That sounds like a lot, but data manipulations (strcmp, memset) in the ISR add up. Consider doing those in main() instead.

    The UART ISR will also be delayed if you're doing things in the SPI+DMA ISRs [ref other threads].

    I suspect that UART Rx data is relatively rare/sporadic in this application. Your simplest workaround (at least for now) might be to pace the data at the sender, i.e. put an artificial delay between bytes.
  • Hi Bruce,

    PC and MSP432 are set at 3Mbps, i dont know if it is the PC, FTDI chip next to MSP432 or the MSP432 itself or the 1m USB cable lengths that cannot RX at this speed.
    I will disable ADC for now and test just UART at 3Mbps with very simple values to check communication.
    Were you able communicate MSP432 UART at 3Mbps with PC?
  • Which direction is losing bytes?

    I don't have my materials here, but over in this thread:

    e2e.ti.com/.../2262639

    I adapted the OP's program and the UART ran flawlessly at 4Mbps, full duplex, (almost-)continuous for about a half-hour (until I got bored). That program used DMA and loopback (at the pins), which factors out the USB, the cable, the PC, and (mostly) the MSP432 firmware, testing only the USCI.

    In that case -- as, I suspect, in this one -- the problem was in turnaround, i.e. the gap between the end of one transaction and the beginning of the next. That gap shrinks as you speed up the UART.
  • Hi Bruce,
    so maybe UART RX EUSCIA0_IRQHandler is too slow to pic up the values.

    I configure UART RX with DMA and DMA triggers DMA_INT3 once 5 Bytes has been send.
    So PC is limited of 5 Bytes to send to MSP432 which is ok.

    Now the MSP432 receives all bytes from PC!

    But my UART DMA TX is losing 4 packages(4x 1020Bytes) when 10.000 packages are send out.
    8 packages when 20.000 packages are send out.

    i cannot increase the TX to 4Mbps because the FDTI chip can only handle 3Mbps. Maybe i have to schrink the bytes to be transfare or use a quicker UARTto USB serial converter.

    Edit: PL2303HXD can drive Baudrate up to 12Mbps

  • Hi,

    is there a way MSP432 UART to use handshake communication with FTDI chip?

    I know that MSP432 is really sending all bytes out but on PC. I have measured it with DMA_TX interrupt for UART and count the times i set

    But a few seconds some bytes get lost.
    I am simply sending the same buffer the whole time with 200 Bytes. And i can see that sending at 5kHz everything is ok bit at 11kHz bytes are getting lost.
  • Michael,
    The eUSCI peripheral does not support the handshake for UART. I am afraid that the overhead associated with handling the CTS/RTS would prohibit the higher throughput.

    Chris
  • FYI. The eUSCI Baud Rate calculator is availabe at the link below.
    -Bob L.

    software-dl.ti.com/.../index.html
  • Hi,

    so i tested now with the MSP432 Launchpad Red and compare both the FT231x and the build in UART from launchpad.
    I use Tera Term to check the receive bytes and set the Baudrate at 3Mpbs.

    I am sending the same 204Bytes packages at 46kHz. (array[204]={0,1,2,3,4,5,6,7..203})
    Both UARTs, the launchpad user UART and FDTI, seems to handle it with no problem and on the tera term i see all bytes coming with no loss.

    I think the issue is in my Qt Application receiving the serial data, but i cannot see anything on tera term i only see the packages and they look all the same at first.

    Best regards,

    Michael
  • Hi,

    so this issue is not from my QT application.
    I looked into the tera term output and i saw that the Lanchpad MSP432 (RED) is sometimes sending more data then 204 bytes:

    But the MSP432 is sending all bytes and i am not overwriting the DMA channel:

    if( !DMA_isChannelEnabled(DMA_CH0_EUSCIA0TX))//Check if DMA TX is ready
    {
        DMA_setChannelControl (UDMA_PRI_SELECT | DMA_CH0_EUSCIA0TX, UDMA_SIZE_8 | UDMA_SRC_INC_8 | UDMA_DST_INC_NONE | UDMA_ARB_1);
        DMA_setChannelTransfer(UDMA_PRI_SELECT | DMA_CH0_EUSCIA0TX, UDMA_MODE_BASIC, m_buffer/*data_array1[swapbuffer]*/, 
        (void*)UART_getTransmitBufferAddressForDMA(EUSCI_A0_BASE), SIZE_BUFF_TX);
        DMA_enableChannel(0);
    }

    Any idea? Could it be the MSP somehow? Memory issue on the buffer?

  • Is this the correct way to get a DMA error message? Enabling the DMA_INTERR and check if the DMA handler is called?

    Interrupt_enableInterrupt(DMA_INTERR);
    }
    ...
    void DMA_ERR_IRQHandler(void)
    {
        errorDMA = DMA_getErrorStatus();
    }

    I dont know whereelse to look, the FDTI and the onboard user UART are doing this issue at 3Mpbs. I think this might be a MSP432 memory problem

  • Hi Michael,

    as you mention Tera Term, I suppose you are using Microsoft Windows as Host OS for your client Applikation.

    In that case you should try to tweak the USB settings of the serial port, as I fear that the default USB packet size for the desired transmission speed is far to small( Example: WIndows 7).

    HTH

    Christoph

  • Hi Christoph,

    it didnt helped. It was already at maximum.
  • Michael,

       As you increase the baud rate the error will also increase.    So even if you increase BRCLK to the maximum allowed (24Mhz) would still not be able to get much beyond 460800 without introducing a lot of error.

       By using higher baud rates your are actually using what was intended for low-frequency mode because the relationship between BRCLK and the baud rate is not greater than 16x.

    Regards,

    Chris

  • Hi Chris,

    thanks for your answer. I was trying to use MSP432 as a sound card but using UART wont be a good idea.
    I am using the PCM2903C instead that has USB already and MSP432 for other things.


    Best regards,

    Michael

**Attention** This is a public forum