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.

use the DMA ( in order to receive block of data) and still filter failures of parity error

Other Parts Discussed in Thread: MSP430F5438A

hello,

I'm using msp430F5438a,
 writing in c and my IDE is CCs 5.3

I am interested in working with the DMA .
in order to read data ( to read block of data) through the UART.
but, how i deal with errors of parity error.
in the user guide (slau 208m.pdf) it's write:
"When any of the UCFE, UCPE, UCOE, UCBRK, or UCRXERR bit is set,
the bit remains set until user
software resets it or UCAxRXBUF is read"

hence,  as the DMA read ( in burst mode , read the UCAxRXBUF )
I reset the parity error and loose important information.

so,how  i could use the DMA ( in order to receive block of data)
and still filter failures of parity error?

thanks.
Asher.

 

  • Well, you can use DMA when and where you want (for example I'm using DMA with my USB stack), but I didn't found (and spend some time in trying) how DMA can improve (on any way) UART RX (receiving). At the end I finished at starting point, using RX interrupt instead of DMA for UART receiving side. This was related to my MSP430F5xx 4 Mbps USB-UART bridge.

    http://forum.43oh.com/topic/3350-msp430f550x-based-usb-uart-bridge

    http://forum.43oh.com/topic/3413-msp430-uart-benchmark

  • Hi Asher,

    Do you want to discard characters with errors like FE and PE?  If so, set UCRXEIE =0 (default) in UCAxCTL1.  Then DMA won't pick up characters with errors.

    DMA works great as long as you want to ignore breaks and characters with FE and PE.

    Jeff

  • Hi Jeff,

    In my case I do need to get errors alerted , raise a flag, and then ignore those bytes (discard those characters with errors).

    is there solution for this case??

    if i understand your answer correct,  the DMA can not provide  a solution in this case .

    Asher.

  • DMA can move data without CPU. But it cannot do anything else that CPU does.

  • asher bara said:

    Hi Jeff,

    In my case I do need to get errors alerted , raise a flag, and then ignore those bytes (discard those characters with errors).

    is there solution for this case??

    if i understand your answer correct,  the DMA can not provide  a solution in this case .

    Asher.

    And you are using DMA on UART RX side because of ...

    And what MCLK, what baudrate you are using for transfer, 1 Mbps?

  • Hi ,


    Using DMA is to receive messages and to achieve better work efficiency and minimize software interrupts.

    The baud-rate will be 57600.

    About the hardware itself, the hardware is still in the planning stages. I guess the frequency of the processor will 1Mhz (not clear if it will be possible to reach such frequency with the internal oscillator, but the subject is in test).

    If no choice, the solution may be to return using software receive interrupt. instead the DMA. Or to waive the benefit of pe and to prefer checksum test.

    Asher

  • asher bara said:

    Using DMA is to receive messages and to achieve better work efficiency and minimize software interrupts.

    If you are receiving by UART not-constant len messages (and circular buffer is must), than DMA will not improve anything.

    asher bara said:

    The baud-rate will be 57600.

    About the hardware itself, the hardware is still in the planning stages. I guess the frequency of the processor will 1Mhz (not clear if it will be possible to reach such frequency with the internal oscillator, but the subject is in test).

    If no choice, the solution may be to return using software receive interrupt. instead the DMA. Or to waive the benefit of pe and to prefer checksum test.

    I am working on USB-UART MSP430F5xx bridge, with MCLK 24 MHz, on 4 Mbps baudrate. If you scale this down to 1 MHz, it still be able to have 166667 bps. It should be possible to work on 57600 without any problem (and without DMA). Just remember, that UART receiving side must be always ready, without possibility to be blocked by other interuppts.

  • Based on what you claim that there is no advantage to work with the DMA?

    Based on the literature? Or from experience?

    How do you evaluate that work with interrupt is much more rapid?

     If it from the literature, then in the user guide(slau.odf) it write: that only the RTI is between 5 MCLK Cycles (6.5.1.5 MSP430 Instruction Execution) , and about the interrupt itself

    1.3.4.1 Interrupt Acceptance

    “ The interrupt latency is six cycles, starting with the acceptance of an interrupt request, and lasting until the

    start of execution of the first instruction”

    if I add the move command  ( between 1 to 4  MCLK cycles) … and  I sum it all together it will result at least  6 – 8   MCLK cycles for each character that I accept using interrupt.

     

    Instead, there is the DMA , that “Requires only two MCLK clock cycles per transfer”

    “The DMA controller requires one or two MCLK clock cycles to synchronize before each single transfer or complete block or burst-block transfer. Each byte/word transfer requires two MCLK cycles after synchronization, and one cycle of wait time after the transfer”

     

    the DMA take about 2 (Without the part of the synchronization and wait time after the block).

     

    Seems significant savings…

     

    Thanks.

    Asher

     

     

  • asher bara said:

    Based on what you claim that there is no advantage to work with the DMA?

    Based on the literature? Or from experience?

    How do you evaluate that work with interrupt is much more rapid?

    I claim that if DMA is used for UART RX side, where more bytes (unknown not-fixed number) will be received and stored multiple times, there will not be any advanted over standard UART RX ISR. I am using DMA in my USB stack for copyng 32 words (fixed len) from USB RAM to non-USB RAM, and there is no better/faster way to do it.

    For me literature is starting reference point. Final result depend on how algorithm is implemented and can be in comletaly differen direction from literature.

    If I made 2 versions, one with UART RX ISR, and another with UART RX DMA, and version with DMA don't improve anything but give me more troubles, than my conclusion is that there is no reason for using UART RX DMA in my project.

    asher bara said:

     If it from the literature, then in the user guide(slau.odf) it write: that only the RTI is between 5 MCLK Cycles (6.5.1.5 MSP430 Instruction Execution) , and about the interrupt itself

    1.3.4.1 Interrupt Acceptance

    “ The interrupt latency is six cycles, starting with the acceptance of an interrupt request, and lasting until the

    start of execution of the first instruction”

    if I add the move command  ( between 1 to 4  MCLK cycles) … and  I sum it all together it will result at least  6 – 8   MCLK cycles for each character that I accept using interrupt.

    Instead, there is the DMA , that “Requires only two MCLK clock cycles per transfer”

    “The DMA controller requires one or two MCLK clock cycles to synchronize before each single transfer or complete block or burst-block transfer. Each byte/word transfer requires two MCLK cycles after synchronization, and one cycle of wait time after the transfer”

    the DMA take about 2 (Without the part of the synchronization and wait time after the block).

    Seems significant savings…

    Yes, but this is if you are have simple picture in front of you. Let say that you are receiving from UART few commands, with 3 byte len, 6 byte len and 8 byte len. In this case there are must be some way of circular buffer. With DMA transfer will go in 2 cycles, but there are also will be DMA ISR (that eat cycles like any other ISR) for reconfiguring DMA (prepareing for filling up circular buffer with new commmand).

  • DMA is good for fire-and-forget operations where there is no possible error condition.
    Using DMA for TX a string will work fine.
    SPI (where there is no way to detect failure except by a probability check of the data itself) is a good candidate as wel (I use SPI to send a 512 bytes dsata block from or to SD card)

    But if you want to detect RX errors, you cannto use DMA. Besides the already mentioned fact that you don't know beforehand how much data is coming (so you had to constantly check the DMA counter to see whether new data has arrived and how much), there is only one single IFG bit for RX. Which is used to trigger the DMA. You won't get an interrupt in which you could check for a PE or FE. And once the next byte has arrived, any flags from the previous transfer are cleared, so evne polling form main won't show you.

    Sorry, no way to eat the cake and keep it.

  • Can eat the cake and keep it…
    UCRXEIE (Receive erroneous-character interrupt enable) give the possibility to  choose between the two options
    or :
    Erroneous characters rejected and UCRXIFG is not set
    Or:
    Erroneous characters received set UCRXIFG.
     
    If I choose to work with the last option (that was mention), then
    The SW will receive the DATA via the DMA,
    Although that DMA will not reject any errors, but the SW will know
    that there was  error while receiving the last message/data ( interrupt will occur, and will set a  flag).
     
    And in that way, the SW can receive data and know whether parity error was occur
    And to decide what to do with the last message/data that was received.
     
     
     
     
  • asher bara said:
    Can eat the cake and keep it…
    UCRXEIE (Receive erroneous-character interrupt enable) give the possibility to  choose between the two options
    or :
    Erroneous characters rejected and UCRXIFG is not set
    Or:
    Erroneous characters received set UCRXIFG.
     
    If I choose to work with the last option (that was mention), then
    The SW will receive the DATA via the DMA,
    Although that DMA will not reject any errors, but the SW will know
    that there was  error while receiving the last message/data ( interrupt will occur, and will set a  flag).

    Are you sure? Did you try?

    UCRXEIE will cause UCRXIFG to be set on error. However, to call the ISR, UCRXIE needs to be set too, which in turn will disable the DMA.
    Setting this bit will cause the DMA to transfer faulty bytes, but you can't have both, ISR called and DMA transfer.

    Personally, I think the names UCRXEIE and UCBRKIE are misleading because they don't have an associated separate IFG bit, while all other IE bits on the MSP have.

**Attention** This is a public forum